Commit Graph

208 Commits

Author SHA1 Message Date
Michal Meloun
59f46e34cf sys/tools: Add a tool for generating arm and arm64 kernel images.
This tool can generate kernel images without changing the offsets in
the final executable. It replaces the ELF header by properly sized zeroed
block then emits a relative jump to _start(for  'v7jump' or 'v8jump' option)
or the booti header (for 'v8booti' option) to the beginning of the converted file.
Submited by:	ian
2020-12-30 13:22:04 +01:00
John Baldwin
a095390344 Use a template assembly file for firmware object files.
Similar to r366897, this uses the .incbin directive to pull in a
firmware file's contents into a .fwo file.  The same scheme for
computing symbol names from the filename is used as before to maximize
compatiblity and not require rebuilding existing .fwo files for
NO_CLEAN builds.  Using ld -o binary requires extra hacks in linkers
to either specify ABI options (e.g. soft- vs hard-float) or to ignore
ABI incompatiblities when linking certain objects (e.g.  object files
with only data).  Using the compiler driver avoids the need for these
hacks as the compiler driver is able to set all the appropriate ABI
options.

Reviewed by:	imp, markj
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27579
2020-12-17 20:31:17 +00:00
Emmanuel Vadot
4a63c1c1ed Brand our DTS with the Linux version it was imported from
DTS must be synced with the kernel, add a freebsd,dts-version string in
the root node of each DTS that we compile so we can later in the kernel
check that it contain a correct value.

Reviewed by:	imp, mmel
Differential Revision:	https://reviews.freebsd.org/D26724
2020-10-10 07:18:51 +00:00
Edward Tomasz Napierala
586bd2de78 Make makesyscalls.lua initialize 'struct sysent' entries using c99
designated initializers.  This makes it easier to modify 'struct sysent'
layout.

Reviewed by:	kevans
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26530
2020-09-25 09:34:00 +00:00
Michal Meloun
95a85c125d Add NetBSD compatible bus_space_peek_N() and bus_space_poke_N() functions.
One problem with the bus_space_read_N() and bus_space_write_N() family of
functions is that they provide no protection against exceptions which can
occur when no physical hardware or device responds to the read or write
cycles. In such a situation, the system typically would panic due to a
kernel-mode bus error. The bus_space_peek_N() and bus_space_poke_N() family
of functions provide a mechanism to handle these exceptions gracefully
without the risk of crashing the system.

Typical example is access to PCI(e) configuration space in bus enumeration
function on badly implemented PCI(e) root complexes (RK3399 or Neoverse
N1 N1SDP and/or access to PCI(e) register when device is in deep sleep state.

This commit adds a real implementation for arm64 only. The remaining
architectures have bus_space_peek()/bus_space_poke() emulated by using
bus_space_read()/bus_space_write() (without exception handling).

MFC after:	1 month
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D25371
2020-09-19 11:06:41 +00:00
Kyle Evans
0bc1c0786b makesyscalls.lua: improve syscall ordering validation
There were two separate issues here:

1.) #if/#else wasn't taken into account at all for maxsyscall figures, but
2.) We didn't validate contiguous syscall numbers anyways...

This kind of inconsistency is bad as we don't currently ensure explicit
indexing of, e.g., the sysent array if one syscall is unimplemented/missing.
This could be fixed and might be more robust, but it's also good to have the
"documentation" that comes from being explicit as to what the missing
syscalls are.

The new version looks much like the awk version; stash off the current
'last highest syscall seen' if we hit an #if, restore to that if we hit an
#else, and make sure that we're explicitly always defining the next syscall.

The logic at the tail end of process_syscall_def that moves maxsyscall has
been 'cleaned up' a little since we're now ensuring that it's monotonically
increasing earlier in the function. At the moment I think it's unlikely we'd
see range-definitions that are not UNIMPL, but there's no reason to
specifically handle that case for bumping maxsyscall there.

This change was provoked by reading the commit message for r363832 and
realizing that this validation hadn't been included in the initial rewrite
to lua.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D25945
2020-08-04 21:49:13 +00:00
Mateusz Guzik
848f8effdd vfs: inline vops if there are no pre/post associated calls
This removes a level of indirection from frequently used methods, most notably
VOP_LOCK1 and VOP_UNLOCK1.

Tested by:	pho
2020-07-30 15:50:51 +00:00
Mateusz Guzik
8a6f5fd50c vfs: stop null checking routines in vop wrappers
Calls to vop_bypass pass the same argument, but type casted to something else.
Thus by replacing NULL routines with vop_bypass we avoid a runtime check.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23357
2020-01-26 00:41:38 +00:00
Justin Hibbits
de8dd262c4 Add a 'SINGLETON' directive to kobj interface definition
Summary:
This makes the interface described in the definition file act like a
pseudo-IFUNC service, by caching the found method locally.

Applying this to the PowerPC MMU definitions, it yields a significant
(15-20%) performance improvement, seen in both a 'make buildworld' and a
parallel build of LLVM, on a POWER9 system.

Reviewed By:	imp
Differential Revision:	https://reviews.freebsd.org/D23245
2020-01-18 02:39:38 +00:00
Kyle Evans
554f71e2b3 makesyscalls.lua: generate all files in /tmp, write into place at the end
This makes makesyscalls.lua more parallel-friendly, or at least not as
hostile to the idea. We get into situations where we're running parallel if
we end up with MAKE_JOBS>1 entering any of the sysent targets, since each
output file is recognized a distinct build step that needs to be executed.

Another commit will add some .ORDER to further improve the situation.

Reported by:	jhb
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D23098
2020-01-10 18:22:14 +00:00
Mateusz Guzik
61f67f32c7 vfs: allow tail call optimisation in vops in the common case
Most frequently used vops boil down to checking SDT probes, doing the call and
checking again. There is no vop_post/pre in their case but the check after the
call prevents tail call optimisation from taking place. Instead, check once
upfront. Kernels with debug or vops with non-empty vop_post still don't short
circuit.

Reviewed by:	kib
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D22739
2019-12-16 00:07:51 +00:00
Mateusz Guzik
6fa079fc3f vfs: flatten vop vectors
This eliminates the following loop from all VOP calls:

while(vop != NULL && \
    vop->vop_spare2 == NULL && vop->vop_bypass == NULL)
        vop = vop->vop_default;

Reviewed by:	jeff
Tesetd by:	pho
Differential Revision:	https://reviews.freebsd.org/D22738
2019-12-16 00:06:22 +00:00
Kyle Evans
0d80770c71 makesyscalls.lua: trim trailing spaces/commas from args
These are insignificant as far as declarations go, and we've historically
allowed it. fhlinkat in ^/sys/kern/syscalls.master, for example, currently
has a trailing comma after its final argument that this version of
makesyscalls is ignoring (not by conscious decision).

Fix it for now by actively stripping off trailing whitespace/commas until
we decide to actively prohibit it.
2019-12-11 19:32:52 +00:00
Kyle Evans
0d9048c3c2 makesyscalls.lua: improve config processing
The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

- Strip only whole-line comments on every single iteration
- Abort if we see a malformed line that doesn't match the key=value format
- For quoted (backtick or double quote) strings, we'll advance to the end of
  the key=value pair and make sure there's not extra stuff left over
- For unquoted key=value pairs, we'll strip any trailing comments and verify
  there's no internal whitespace

This has revealed the caveat that key/value pairs can't even include escaped quotes (and haven't been able to). I don't know if this is actually problematic, as we're usually looking at cases like "#include <foo>" or raw identifiers.The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

Reviewed and noticed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D22698
2019-12-06 22:45:36 +00:00
Kyle Evans
d3276301ab Add makesyscalls.lua, a rewrite of makesyscalls.sh
This currently requires a suitable lua + luafilesystem + luaposix from the
ports tree to build. Discussion is underway in D21893 to add a suitable lua
to the base system, cleverly disguised and out of the way of normal
consumers.

makesyscalls.sh is a good target for rewrite into lua as it's currently a
sh+sed+awk script that can be difficult to add on to, at times. For
instance, adding a new COMPAT* option (that mimicks the behaivor of most
other COMPAT* options) requires a fairly substantial amount of copy/paste;
see r352693 for instance. Attempts to generate part of the awk script for
COMPAT* handling was (very kindly) rejected with a desire to just rewrite
the script in a single language that can handle all of it.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D21775
2019-11-17 14:08:19 +00:00
Ed Maste
9a069ff5ae fw_stub.awk: use @generated tag in generated files
Multiple tools use @generated to identify generated files (for example,
in a review Phabricator will by default hide diffs in enerated files).
Use the @generated tag in makesyscalls.sh as we've done for other
generated files.
2019-09-11 13:35:22 +00:00
Bjoern A. Zeeb
67ca7330cf Add SDIO support.
Add a CAM-Newbus SDIO support module.  This works provides a newbus
infrastructure for device drivers wanting to use SDIO.  On the lower end
while it is connected by newbus to SDHCI, it talks CAM using the MMCCAM
framework to get to it.

This also duplicates the usbdevs framework to equally create sdiodev
header files with #defines for "vendors" and "products".

Submitted by:	kibab (initial work, see https://reviews.freebsd.org/D12467)
Reviewed by:	kibab, imp (comments on earlier version)
MFC after:	6 weeks
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19749
2019-06-08 16:26:56 +00:00
Ed Maste
52bcb118a9 Avoid literal @generated tag in file-generating scripts
We don't want the generator itself tagged as a generated file.

Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20182
2019-05-08 13:35:51 +00:00
Ed Maste
6e0e532a90 Use @generated tag in generated files
Multiple tools use @generated to identify generated files (for example,
in a review Phabricator will by default hide diffs in generated files).
Use the @generated tag in makeobjops.awk and vnode_if.awk as we've done
for other generated files.

Sponsored by:	The FreeBSD Foundation
2019-05-07 13:04:26 +00:00
Alex Richardson
0a65536cab make_dtb.sh: Use $CPP instead of assuming that cpp is in $PATH
This fixes building in CheriBSD with a strict tmp path since we don't
bootstrap a cpp but pass the full path to clang-cpp instead.

While touching this file also fix all shellcheck warnings in make_dtb.sh.

Reviewed By:	manu
Differential Revision: https://reviews.freebsd.org/D18376
2018-12-14 23:53:28 +00:00
Kyle Evans
13cf5074d0 Use ${ECHO} in dtb/dtbo build, pass in from dtb.mk for -s
Reported by:	sbruno
MFC after:	3 days
2018-11-09 18:56:40 +00:00
Ed Maste
97a7bf3070 embed_mfs.sh: replace some compound statements with conventional ifs
Use the more readable form - there's no need to try being clever.
2018-11-02 21:07:06 +00:00
Konstantin Belousov
8ff7fad1d7 Only call sigdeferstop() for NFS.
Use bypass to catch any NFS VOP dispatch and route it through the
wrapper which does sigdeferstop() and then dispatches original
VOP. NFS does not need a bypass below it, which is not supported.

The vop offset in the vop_vector is added since otherwise it is
impossible to get vop_op_t from the internal table, and I did not
wanted to create the layered fs only to wrap NFS VOPs.

VFS_OP()s wrap is straightforward.

Requested and reviewed by:	mjg (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D17658
2018-10-23 21:43:41 +00:00
Emmanuel Vadot
5695558451 make_dtb: Always add root directory in the include path
Some arch like arm and arm64 share DTS files, add the root dts directory
to the include paths.
2018-08-23 13:23:21 +00:00
Emmanuel Vadot
c2f5940db3 Add dtb overlays support
DTB Overlays are useful to change/add nodes to a dtb without the need to
modify it.
Add support for building dtbo during buildkernel.
The goal of DTBO present in the FreeBSD source tree is to fill a gap in
time when we submit changes upstream (Linux). Instead of waiting 2 to 4 months
we can add a DTBO in tree in the meantime.
This is not for adding DTBO for capes/hat/addon boards, those will be
better to put in a ports.
This is also not for enabling a i2c/spi/pwm controller on certain pins,
each user have a different use case for those (which pins to use etc ...)
and we cannot have all possible configuration.

Add a dtbo for sun8i-h3-sid which add the SID node missing in upstream dts.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D14782
2018-03-24 21:30:24 +00:00
Warner Losh
eef186f8f5 Avoid using \$. It's an unknown escape sequence. Some awks warn about
that. Instead, simply remove the sequence entirely because we never
commit the generated files.
2018-01-28 05:13:08 +00:00
Ed Maste
47b5c71929 embed_mfs: correctly test grep return value
Reported by:	br
MFC with:	r326992
Sponsored by:	The FreeBSD Foundation
2018-01-03 19:22:10 +00:00
Colin Percival
a21a2da599 Teach makeobjops.awk to accept PROLOG and EPILOG blocks before
METHOD and STATICMETHOD declarations; that code will be inserted
into the dispatch function before and after the method call.

Use this functionality and the TSLOG framework to record DEVICE_ATTACH
and DEVICE_PROBE entry/exit timestamps.
2017-12-31 09:23:19 +00:00
Ed Maste
2dd51e16ca embed_mfs: support embedding mfs into loader
The script originally supported embedding an mfs into ELF files or any
other type of file, because it searched for magic strings to mark the
beginning and end of the embeddable section. It was later modified to
read the section offset and length via readelf, which made it work for
ELF only. Restore the ability to update arbitrary file types by using
the readelf technique for ELF, and the magic string technique for all
others (including PE/COFF files like loader.efi).

Submitted by:	Zakary Nafziger <worldofzak@gmail.com>
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12746
2017-12-19 19:44:06 +00:00
Pedro F. Giffuni
fe267a5590 sys: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:23:17 +00:00
Pedro F. Giffuni
51369649b0 sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:43:44 +00:00
Warner Losh
2e36db147e Move sys/boot/fdt/dts to sys/dts and adjust scripts.
Sponsored by: Netflix
2017-11-14 21:03:57 +00:00
Ed Maste
0bf94a089d embed_mfs: add error handling, usage
Ensure that we are called with two arguments, and that the output file
is writable. Also, if we cannot find the mfs section report the output
file name rather than "kernel", as this script may be used with other
than kernels.

Sponsored by:	The FreeBSD Foundation
2017-10-17 21:13:26 +00:00
Emmanuel Vadot
46375c65f6 make.conf: Add the possibility to use another DTC
Add a make.conf DTC variable that control which DTC (Device Tree Compiler)
to use.

Reviewed by:	bdrewery, imp
Differential Revision:	https://reviews.freebsd.org/D9577
2017-06-17 23:34:53 +00:00
Hans Petter Selasky
3f9dcc588d Declare the "snd_fxdiv_table" once. This shaves around 24Kbytes of
binary data from sound.ko and the kernel.

MFC after:		3 days
2017-05-25 05:23:47 +00:00
Hans Petter Selasky
0f86d40bf5 Increase the allowed maximum number of audio channels from 31 to 127
in the PCM feeder mixer. Without this change a value of 32 channels is
treated like zero, due to using a mask of 0x1f, causing a kernel
assert when trying to playback bitperfect 32-channel audio. Also
update the AWK script which is generating the division tables to
handle more than 18 channels. This commit complements r282650.

MFC after:		3 days
2017-05-24 21:42:48 +00:00
Oleksandr Tymoshenko
5faab58bd0 [fdt] Make DTBs generated by make_dtb.sh overlay-ready
Generate symbols node when compiling dts files so they can be modified
during boot-time by applying overlays.
2017-03-10 22:45:07 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Li-Wen Hsu
0a50238935 Replace using of objdump with elfdump
In-tree objdump is too old to dump new ELF headers.  But for example if we
use: `make CROSS_TOOLCHAIN=riscv64-gcc TARGET_ARCH=riscv64` and do not specify
CROSS_BINUTILS_PREFIX in env, embed_mfs.sh cannot find the correct objdump.
This patch just replaces using of objdump with elfdump to collect needed
information.

Later we may also put an ELFDUMP in CROSSENV and use it in embed_mfs.sh .

Reviewed by:	emaste, br
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D9062
2017-01-10 18:46:40 +00:00
Ruslan Bukin
3cd77f5416 Consider CROSS_BINUTILS_PREFIX environment variable so we use correct
objdump.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-08-10 13:49:17 +00:00
Adrian Chadd
f4c1f0b9eb Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified
MD_ROOT_SIZE and embed_mfs.sh were basically retired as part of
https://reviews.freebsd.org/D2903 .
However, when building a kernel with 'options MD_ROOT_SIZE' specified, this
results in a non-working MFS, as within sys/dev/md/md.c we fall within the
wrong # ifdef.

This patch implements the following:

* Allow kernels to be built without the MD_ROOT_SIZE option, which results
  in a kernel built as per D2903.
* Allow kernels to be built with the MD_ROOT_SIZE option, which results
  in a kernel built similarly to the pre-D2903 way, with the following
  differences:
  * The MFS is now put in a separate section within the kernel (oldmfs,
    so it differs from the mfs section introduced by D2903).
  * embed_mfs.sh is changed, so it looks up the oldmfs section within the
    kernel, gets its size and offset, sees if the MFS will fit within the
    allocated oldmfs section and only if all is well does a dd of the MFS
    image into the kernel.

Submitted by:	Stanislav Galabov <sgalabov@gmail.com>
Reviewed by:	brooks, imp
Differential Revision:	https://reviews.freebsd.org/D5093
2016-02-02 07:02:51 +00:00
Bryan Drewery
cada39d8dd Rename the /usr/share/doc/legal files to driver.LICENSE to work around
bug of installing 'realtek' and 'intel_iwn' as files rather then as
a 'LICENSE' file in their directories.

Also add obsolete entries for the older names and names that existed in head
for a period of time.

Suggested by:	jmg
X-MFC-With:	r289391
MFC after:	3 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-10-16 00:38:05 +00:00
Andriy Gapon
2f2f522b5d save some bytes by using more concise SDT_PROBE<n> instead of SDT_PROBE
SDT_PROBE requires 5 parameters whereas SDT_PROBE<n> requires n parameters
where n is typically smaller than 5.

Perhaps SDT_PROBE should be made a private implementation detail.

MFC after:	20 days
2015-09-28 12:14:16 +00:00
Ian Lepore
1ec2d237e0 Allow the make_dtb script to work outside of a "make buildkernel" context
by setting MACHINE from uname -m if it's not set already.

Reviewed by:	imp, tuexen
2014-08-30 22:39:15 +00:00
Rui Paulo
4f1156ca62 Call cpp with -P to avoid printing line markings. 2014-06-10 06:24:01 +00:00
Warner Losh
382b6bbafe Fix logic error. <blush>
Submitted by: ian@
2014-04-30 20:52:38 +00:00
Warner Losh
56d78e82f0 Turns out this .if evaluated not in the context of the makedtb target
sometimes due to Makefile expansion rules. Make the test for things
being NULL elsewhere...
2014-04-30 20:47:40 +00:00
Warner Losh
0edb735169 Allow FDT_DTS_FILE to be a list, either in the makedtb target, or in a
kernel config file. If you also want to have a static DTB compiled
into your kernel, however, it cannot be a list. We have no mechanism
in the kernel for picking one, so that doesn't make sense and will
result in a compile-time error.
2014-04-30 18:02:04 +00:00
Ed Maste
0fcefb433d Update NetBSD Foundation copyrights to 2-clause BSD
The NetBSD Foundation states "Third parties are encouraged to change the
license on any files which have a 4-clause license contributed to the
NetBSD Foundation to a 2-clause license."

This change removes clauses 3 and 4 from copyright / license blocks that
list The NetBSD Foundation as the only copyright holder.

Sponsored by:	The FreeBSD Foundation
2014-03-18 01:40:25 +00:00
Warner Losh
8b86933acc Use proper include path for dtc as well as cpp. 2014-02-28 22:37:35 +00:00
Warner Losh
eeb913c99f Integrate device-tree upstream files into the build process:
(1) Invoke cpp to bring in files via #include (although the old
    /include/ stuff is supported still).
(2) bring in files from either vendor tree or freebsd-custom files
    when building.
(3) move all dts* files from sys/boot/fdt/dts to
    sys/boot/fdt/dts/${MACHINE} as appropriate.
(4) encode all the magic to do the build in sys/tools/fdt/make_dtb.sh
    so that the different places in the tree use the exact same logic.
(5) switch back to gpl dtc by default. the bsdl one in the tree has
    significant issues not easily addressed by those unfamiliar with
    the code.
2014-02-28 18:29:09 +00:00
Andriy Gapon
d9fae5ab88 dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE
In its stead use the Solaris / illumos approach of emulating '-' (dash)
in probe names with '__' (two consecutive underscores).

Reviewed by:	markj
MFC after:	3 weeks
2013-11-26 08:46:27 +00:00
Attilio Rao
54366c0bd7 - For kernel compiled only with KDTRACE_HOOKS and not any lock debugging
option, unbreak the lock tracing release semantic by embedding
  calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined
  version of the releasing functions for mutex, rwlock and sxlock.
  Failing to do so skips the lockstat_probe_func invokation for
  unlocking.
- As part of the LOCKSTAT support is inlined in mutex operation, for
  kernel compiled without lock debugging options, potentially every
  consumer must be compiled including opt_kdtrace.h.
  Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the
  dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES
  is linked there and it is only used as a compile-time stub [0].

[0] immediately shows some new bug as DTRACE-derived support for debug
in sfxge is broken and it was never really tested.  As it was not
including correctly opt_kdtrace.h before it was never enabled so it
was kept broken for a while.  Fix this by using a protection stub,
leaving sfxge driver authors the responsibility for fixing it
appropriately [1].

Sponsored by:	EMC / Isilon storage division
Discussed with:	rstone
[0] Reported by:	rstone
[1] Discussed with:	philip
2013-11-25 07:38:45 +00:00
John Baldwin
593efaf9f7 Further refine the handling of stop signals in the NFS client. The
changes in r246417 were incomplete as they did not add explicit calls to
sigdeferstop() around all the places that previously passed SBDRY to
_sleep().  In addition, nfs_getcacheblk() could trigger a write RPC from
getblk() resulting in sigdeferstop() recursing.  Rather than manually
deferring stop signals in specific places, change the VFS_*() and VOP_*()
methods to defer stop signals for filesystems which request this behavior
via a new VFCF_SBDRY flag.  Note that this has to be a VFC flag rather than
a MNTK flag so that it works properly with VFS_MOUNT() when the mount is
not yet fully constructed.  For now, only the NFS clients are set this new
flag in VFS_SET().

A few other related changes:
- Add an assertion to ensure that TDF_SBDRY doesn't leak to userland.
- When a lookup request uses VOP_READLINK() to follow a symlink, mark
  the request as being on behalf of the thread performing the lookup
  (cnp_thread) rather than using a NULL thread pointer.  This causes
  NFS to properly handle signals during this VOP on an interruptible
  mount.

PR:		kern/176179
Reported by:	Russell Cattelan (sigdeferstop() recursion)
Reviewed by:	kib
MFC after:	1 month
2013-02-21 19:02:50 +00:00
Oleksandr Tymoshenko
7fc3ae51f3 Fix build on ARM (and probably other platforms) 2012-12-28 06:52:53 +00:00
Jeff Roberson
4c44811c9d - Add new machine parsable KTR macros for timing events.
- Use this new format to automatically handle syscalls and VOPs.  This
   changes the earlier format but is still human readable.

Sponsored by:	EMC / Isilon Storage Division
2012-12-19 20:10:00 +00:00
Kevin Lo
9823d52705 Revert previous commit...
Pointyhat to:	kevlo (myself)
2012-10-10 08:36:38 +00:00
Kevin Lo
a10cee30c9 Prefer NULL over 0 for pointers 2012-10-09 08:27:40 +00:00
Mikolaj Golub
f62f6c88ee Make vnode_if.awk parse vnode operations with underscores, like VOP_FOO_BAR.
Reviewed by:	kib
MFC after:	1 week
2012-02-21 19:35:59 +00:00
Ed Schouten
5cac9fa00e Restore the comment that I removed by accident.
The comment still applies to this block of code.
2011-11-09 13:26:59 +00:00
Ed Schouten
d09ebcec17 Simplify the code emitted by makeobjops.awk slightly.
Just place the default kobj_method inside the kobjop_desc structure.
There's no need to give these kobj_methods their own symbol. This shaves
off 10 KB of a GENERIC kernel binary.
2011-11-09 11:00:29 +00:00
Ed Schouten
3f3f6bc302 Make kobj_methods constant.
These structures hold no information that is modified during runtime. By
marking this constant, we see approximately 600 symbols become
read-only (amd64 GENERIC). While there, also mark the kobj_method
structures generated by makeobjops.awk static. They are only referenced
by the kobjop_desc structures within the same file.

Before:

	$ ls -l kernel
	-rwxr-xr-x  1 ed  wheel  15937309 Nov  8 16:29 kernel*
	$ size kernel
	    text    data     bss      dec    hex filename
	12260854 1358468 2848832 16468154 fb48ba kernel
	$ nm kernel | fgrep -c ' r '
	8240

After:

	$ ls -l kernel
	-rwxr-xr-x  1 ed  wheel  15922469 Nov  8 16:25 kernel*
	$ size kernel
	    text    data     bss      dec    hex filename
	12302869 1302660 2848704 16454233 fb1259 kernel
	$ nm kernel | fgrep -c ' r '
	8838
2011-11-08 15:38:21 +00:00
Ryan Stone
04af6e9603 GNU awk does not output escaped newlines in multi-line printc statements. This
leads to compile errors when trying to compile firmware(9) stubs created with
gawk, as multiple #include statements end up on the same line.  Replace the
multi-line printc statement that outputs all of the #includes with one printc
per #include.  This allows modules compatible with firmware(9) to be cross-built
from a Linux machine without requiring the one true awk to be installed.

I've intentionally done the minimal set of changes necessary to make gawk
produce valid (but not pretty) C code, to reduce the churn and keep fw_stubs.awk
as readable as possible.

Approved by:	emaste (mentor)
MFC after:	2 weeks
2011-03-31 21:33:33 +00:00
Rui Paulo
79856499bd Add an extra comment to the SDT probes definition. This allows us to get
use '-' in probe names, matching the probe names in Solaris.[1]

Add userland SDT probes definitions to sys/sdt.h.

Sponsored by:	The FreeBSD Foundation
Discussed with:	rwaston [1]
2010-08-22 11:18:57 +00:00
Rafal Jaworowski
847ae21203 Flattened Device Tree helper scripts.
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-06-02 17:22:38 +00:00
Rui Paulo
f91c218bf8 Output a comment on top of each generated file explaining where it came
from.
2009-10-25 09:48:21 +00:00
Ed Maste
97aa4d9845 Rename default to default_function, for compatibility with GNU awk.
(For cross-compiling out-of-tree kernel modules, for example.)
2009-10-22 20:57:17 +00:00
Max Khon
b352b7ccb9 Allow KMOD with hypens and dots.
MFC after:	1 week
2009-10-20 11:54:06 +00:00
Ariff Abdullah
96831ae59b - Increase dynamic range of filter coefficients from 28bit to 30bit.
This cause dramatic effect in overall precision and conversion quality
  by pushing down most aliasing artifacts around -180 dB.

  Spectrogram analysis/comparison:

  	http://people.freebsd.org/~ariff/z_comparison/z_28vs30/

- Guard against possible 64bit overflow during accumulation process by
  slightly normalize and saturate sample and coefficient multiplication,
  possible during extreme 32bit downsampling (eg. 380KHz -> 8KHz) with
  custom preset that require more than ~7000 taps filter (which is
  overkill).

- Add knobs through FEEDER_RATE_PRESETS to set dynamic range of filter
  coefficients/accumulator and prefered polynomial interpolator:

  	COEFFICIENT_BIT:X
	(where 1 <= X <= 30, default: 30)

	ACCUMULATOR_BIT:X
	(where 32 <= X <=64, default: 58)

	INTERPOLATOR:I
	(where I = ZOH, LINEAR, QUADRATIC, HERMITE, BSPLINE,
 	           OPT32X, OPT16X, OPT8X, OPT4X, OPT2X)

Approved by:	re (kib)
2009-07-05 18:15:06 +00:00
Ariff Abdullah
0162436974 Slightly increase amount of bandwidth of resampling filter for
feeder_rate_quality=3. This have the benefit of reducing aliasing
artifacts due to alias masking.

Spectrogram analysis:

 o Old preset (100:36:0.90)
	http://people.freebsd.org/~ariff/z_comparison/z_q3_old.png

 o New preset (100:36:0.92):
	http://people.freebsd.org/~ariff/z_comparison/z_q3_new.png

Approved by:	re (kib)
2009-07-02 10:02:10 +00:00
Ariff Abdullah
164e1f20ec - Add a way to change filter oversampling factor through
FEEDER_RATE_PRESET "OVERSAMPLING_FACTOR:X .. .." where
  X = log2(oversampling factor).

- Lower down default filter oversampling factor from 128
  (log2 = 7) to 32 (log2 = 5), saving worth of 80 Kb.
  The use of better polynomial interpolator will raise
  its conversion quality/accuracy to match (or slightly
  better) with previous settings.

- Bump driver version.
2009-06-15 04:31:34 +00:00
Ariff Abdullah
0f40c3f162 Move all sound related scripts to its own 'sound' subdir.
Suggested by:	jmallett
2009-06-10 06:49:45 +00:00
Ariff Abdullah
90da2b2859 Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
	[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .

Summary of changes includes:

1 Volume Per-Channel (vpc).  Provides private / standalone volume control
  unique per-stream pcm channel without touching master volume / pcm.
  Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
  backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
  instead of /dev/mixer.  Special "bypass" mode is enabled through
  /dev/mixer which will automatically detect if the adjustment is made
  through /dev/mixer and forward its request to this private volume
  controller.  Changes to this volume object will not interfere with
  other channels.

  Requirements:
    - SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
      require specific application modifications (preferred).
    - No modifications required for using bypass mode, so applications
      like mplayer or xmms should work out of the box.

  Kernel hints:
    - hint.pcm.%d.vpc (0 = disable vpc).

  Kernel sysctls:
    - hw.snd.vpc_mixer_bypass (default: 1).  Enable or disable /dev/mixer
      bypass mode.
    - hw.snd.vpc_autoreset (default: 1).  By default, closing/opening
      /dev/dsp will reset the volume back to 0 db gain/attenuation.
      Setting this to 0 will preserve its settings across device
      closing/opening.
    - hw.snd.vpc_reset (default: 0).  Panic/reset button to reset all
      volume settings back to 0 db.
    - hw.snd.vpc_0db (default: 45).  0 db relative to linear mixer value.

2 High quality fixed-point Bandlimited SINC sampling rate converter,
  based on Julius O'Smith's Digital Audio Resampling -
  http://ccrma.stanford.edu/~jos/resample/.  It includes a filter design
  script written in awk (the clumsiest joke I've ever written)
    - 100% 32bit fixed-point, 64bit accumulator.
    - Possibly among the fastest (if not fastest) of its kind.
    - Resampling quality is tunable, either runtime or during kernel
      compilation (FEEDER_RATE_PRESETS).
    - Quality can be further customized during kernel compilation by
      defining FEEDER_RATE_PRESETS in /etc/make.conf.

  Kernel sysctls:
    - hw.snd.feeder_rate_quality.
      0 - Zero-order Hold (ZOH).  Fastest, bad quality.
      1 - Linear Interpolation (LINEAR).  Slightly slower than ZOH,
          better quality but still does not eliminate aliasing.
      2 - (and above) - Sinc Interpolation(SINC).  Best quality.  SINC
          quality always start from 2 and above.

  Rough quality comparisons:
    - http://people.freebsd.org/~ariff/z_comparison/

3 Bit-perfect mode.  Bypasses all feeder/dsp effects.  Pure sound will be
  directly fed into the hardware.

4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
  be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.

5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
  vchans in order to make digital format pass through.  It also makes
  vchans more dynamic by choosing a better format/rate among all the
  concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
  becomes sort of optional.

6 Exclusive Stream, with special open() mode O_EXCL.  This will "mute"
  other concurrent vchan streams and only allow a single channel with
  O_EXCL set to keep producing sound.

Other Changes:
    * most feeder_* stuffs are compilable in userland. Let's not
      speculate whether we should go all out for it (save that for
      FreeBSD 16.0-RELEASE).
    * kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
    * pull out channel mixing logic out of vchan.c and create its own
      feeder_mixer for world justice.
    * various refactoring here and there, for good or bad.
    * activation of few more OSSv4 ioctls() (see [1] above).
    * opt_snd.h for possible compile time configuration:
      (mostly for debugging purposes, don't try these at home)
        SND_DEBUG
        SND_DIAGNOSTIC
        SND_FEEDER_MULTIFORMAT
        SND_FEEDER_FULL_MULTIFORMAT
        SND_FEEDER_RATE_HP
        SND_PCM_64
        SND_OLDSTEREO

Manual page updates are on the way.

Tested by:	joel, Olivier SMEDTS <olivier at gid0 d org>, too many
          	unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
Robert Watson
ff8a07fda2 Add SDT DTrace probes for VFS vnode operations in the vfs:vop
provider namespace.  These are inserted dynamically into the
VOP_..._AP() functions created from vnode_if.src.  Each VOP has
entry and return probes, as arg0 the primary vnode, arg1 the
vnode operation argument structure pointer, providing access to
IN and OUT arguments, and for return probes, arg2 the return
value.

MFC after:	1 month
Sponsored by:	Google, Inc.
2009-03-29 03:30:15 +00:00
John Baldwin
c439bdd86f Remove some unused and broken code that attempted to not invoke locking
asserts on NULL vnode pointers.  All the vnode assertion routines already
check for NULL vnode pointers.
2008-11-03 19:57:40 +00:00
Rafal Jaworowski
fcfdd827d0 Introduce a standalone shell script for embedding MFS image.
This allows to fix a problem with ARM kernel.bin not having the MFS image
embedded: it is objcopied from the kernel.noheader temporary ELF file, which
was not subject to embedding the MFS image previously.

Reviewed by:	imp
Approved by:	cognet (mentor)
2008-02-05 10:46:30 +00:00
Jung-uk Kim
2be4e4713a Catch up with ACPI-CA 20070320 import. 2007-03-22 18:16:43 +00:00
Florent Thoumie
7bd6fde395 - Add Intel firmwares for Intel PRO/Wireless LAN 2100/2200/2915 cards in a
uuencoded format along with their respective LICENSE files.
- Add new share/doc/legal directory to BSD.usr.dist mtree file. This is the
place we install LICENSE files for restricted firmwares.
- Teach firmware(9) and kmod.mk about licensed firmwares. Restricted firmwares
won't load properly unless legal.<name>.license_ack is set to 1, either
via kenv(1) or /boot/loader.conf.

Reviewed by:	mlaier, sam
Permitted by:	Intel (via Andrew Wilson)
MFC after:	1 month
2007-03-02 11:42:56 +00:00
Florent Thoumie
4af453db2c Fix obvious typo (use long name if short name isn't provided).
Reviewed by:	sam
MFC after:	3 days
2007-02-27 16:52:27 +00:00
Luigi Rizzo
33d5497079 Cleanup and document the implementation of firmware(9) based on
a version that i posted earlier on the -current mailing list,
and subsequent feedback received.

The core of the change is just in sys/firmware.h and kern/subr_firmware.c,
while other files are just adaptation of the clients to the ABI change
(const-ification of some parameters and hiding of internal info,
so this is fully compatible at the binary level).

In detail:
- reduce the amount of information exported to clients in struct firmware,
  and constify the pointer;

- internally, document and simplify the implementation of the various
  functions, and make sure error conditions are dealt with properly.

The diffs are large, but the code is really straightforward now (i hope).

Note also that there is a subtle issue with the implementation of
firmware_register(): currently, as in the previous version, we just
store a reference to the 'imagename' argument, but we should rather
copy it because there is no guarantee that this is a static string.
I realised this while testing this code, but i prefer to fix it in
a later commit -- there is no regression with respect to the past.

Note, too, that the version in RELENG_6 has various bugs including
missing locks around the module release calls, mishandling of modules
loaded by /boot/loader, and so on, so an MFC is absolutely necessary
there.  I was just postponing it until this cleanup to avoid doing
things twice.

MFC after: 1 week
2007-02-15 17:21:31 +00:00
John Baldwin
c3e7da2b4c Check for errors when registering and unregistering firmware modules. This
prevents the unfortunate situation whereby one might kldload a firmware
module by hand and later kldunload it while a driver still has an open
reference to it.

MFC after:	1 week
Glanced at by:	iedowse
2006-06-16 21:06:03 +00:00
Diomidis Spinellis
44d6e87b07 - Add two checks for syntax errors
- Improve error reporting
- Remove redundant conditionals
2006-05-30 21:13:28 +00:00
Diomidis Spinellis
f69ec7af12 Assertion code specifications are introduced using special character
sequences that are distinct from comments. %% is used for argument
locks; %! for pre- and post-conditions.
2006-05-30 20:49:54 +00:00
Diomidis Spinellis
3cd6252069 Update usage comment to match reality. 2006-05-26 07:13:26 +00:00
Max Laier
6afd356ecf Fix a leftover "iwi_boot" string.
Submitted by:	gallatin
2006-01-30 16:32:08 +00:00
Max Laier
6aec1278dc firmware(9) is a subsystem to load binary data into the kernel via a
specially crafted module.  There are several handrolled sollutions to this
problem in the tree already which will be replaced with this.  They include
iwi(4), ipw(4), ispfw(4) and digi(4).

No objection from:	arch
MFC after:		2 weeks
X-MFC after:		some drivers have been converted
2006-01-29 02:52:42 +00:00
Dag-Erling Smørgrav
0430a5e289 Eradicate caddr_t from the VFS API. 2005-12-14 00:49:52 +00:00
Dag-Erling Smørgrav
e26b05cf44 Nuke vnodeop_desc.vdesc_transports, which has been unused since the dawn
of time (or the inception of ncvs, whichever came last)
2005-12-14 00:15:11 +00:00
Poul-Henning Kamp
6db1c434a4 Add convenience macros for bus_space usage that doesn't require specification
of bus tag+handle.

Instead of
	bus_space_write_1(sc->tag, sc->handle, ...)
this macros offer
	bus_write_1(sc->resource, ...)

The name+argument transformation is constant and the the macros are
generated (by hand) by the script in tools/bus_macro.sh.
2005-09-24 20:11:07 +00:00
Suleiman Souhlal
679985d03a Allow EVFILT_VNODE events to work on every filesystem type, not just
UFS by:
- Making the pre and post hooks for the VOP functions work even when
DEBUG_VFS_LOCKS is not defined.
- Moving the KNOTE activations into the corresponding VOP hooks.
- Creating a MNTK_NOKNOTE flag for the mnt_kern_flag field of struct
mount that permits filesystems to disable the new behavior.
- Creating a default VOP_KQFILTER function: vfs_kqfilter()

My benchmarks have not revealed any performance degradation.

Reviewed by:	jeff, bde
Approved by:	rwatson, jmg (kqueue changes), grehan (mentor)
2005-06-09 20:20:31 +00:00
Jeff Roberson
680a1ec631 - Add the character "E" to the understood lock types. This means
the VOP requires an exclusive lock.

Sponsored by:	Isilon Systems, Inc.
2005-04-11 15:15:03 +00:00
Poul-Henning Kamp
119798b384 Add VOP_FOO_APV() which takes a pointer to the vop_vector.
This allows stacked or partitioned filesystems to say "Continue
the normal resolution from here", for instace from FFS to UFS.

Use VNASSERT() instead of KASSERT().
2005-02-08 12:54:32 +00:00
Poul-Henning Kamp
de8a6c067a Get rid of the VDESC() macro while the pot is boiling anyway, it is
only used from generate files now, so we might as well generate the
right stuff from the start.
2005-01-13 08:05:20 +00:00
Poul-Henning Kamp
63f89abf4a Change the generated VOP_ macro implementations to improve type checking
and KASSERT coverage.

After this check there is only one "nasty" cast in this code but there
is a KASSERT to protect against the wrong argument structure behind
that cast.

Un-inlining the meat of VOP_FOO() saves 35kB of text segment on a typical
kernel with no change in performance.

We also now run the checking and tracing on VOP's which have been layered
by nullfs, umapfs, deadfs or unionfs.

    Add new (non-inline) VOP_FOO_AP() functions which take a "struct
    foo_args" argument and does everything the VOP_FOO() macros
    used to do with checks and debugging code.

    Add KASSERT to VOP_FOO_AP() check for argument type being
    correct.

    Slim down VOP_FOO() inline functions to just stuff arguments
    into the struct foo_args and call VOP_FOO_AP().

    Put function pointer to VOP_FOO_AP() into vop_foo_desc structure
    and make VCALL() use it instead of the current offsetoff() hack.

    Retire vcall() which implemented the offsetoff()

    Make deadfs and unionfs use VOP_FOO_AP() calls instead of
    VCALL(), we know which specific call we want already.

    Remove unneeded arguments to VCALL() in nullfs and umapfs bypass
    functions.

    Remove unused vdesc_offset and VOFFSET().

    Generally improve style/readability of the generated code.
2005-01-13 07:53:01 +00:00
Warner Losh
60727d8b86 /* -> /*- for license, minor formatting changes 2005-01-07 02:29:27 +00:00
Warner Losh
3c20c603ca dheader and hheader were the same function, really, so rename one of
them to header, kill the other and use both with a different arg...
2004-12-31 21:12:17 +00:00
Warner Losh
70eefcc55b Use functions to make the program clearer. 2004-12-31 21:02:43 +00:00
Warner Losh
2fe2cbd59b Allow -d and -h as command line flags. These are used to generate
only the .h or _data.h files respectively.  Restructure code to allow
for this.
2004-12-30 23:18:34 +00:00
Warner Losh
57c75b8f1a Rather than casting through a (void *) to avoid the aliasing warning,
do things correctly from an aliasing perspective.  Put the
vop_generic_args element as the first element for all the vop_*_args
and adjust the code to take the address of that instead of the
structure.

OK'd based on a vague description by: phk
2004-12-13 07:23:34 +00:00
Warner Losh
98a67cd840 Cast from the specific vop_*_args to vop_generic_args via a (void *)
pointer to eliminate the hundreds of warnings that we have in tree at
the moment.

# Chances are good that all the struct vop_*_args should have, as its
# first element, the struct vop_generic_args, and when necessary to
# reference it, we just take its address rather than going through
# this double case.
2004-12-13 06:13:52 +00:00