Commit Graph

85 Commits

Author SHA1 Message Date
Kyle Evans
83d7ed8af3 config: drop dependency on libsbuf
Use an std::stringstream instead.  get_word() and get_quoted_word() both
return a buffer that's presumed to not need release, so solve this by
returning a new special configword type that holds a string or eof/eol
state.  This cleans up caller checking for EOF/EOL to make it more
explicit what they're doing, at least in the EOL cases which previously
checked for NULL.

Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38276
2023-02-08 22:56:10 -06:00
Kyle Evans
2ffdc21324 config: make changes to allow some parts to build as C++
Highlights:
- Avoid keywords (this, not) as variable names
- Move yyparse into config.h with other declarations
- All declarations in config.h are assumed guilty until proven innocent
- Some const-correctness
- Casting malloc/calloc returns

Note that we're not building any C++ here yet, this will be introduced
in other commits to replace some of the lib dependencies.  Reducing the
number of FreeBSD-specific dependencies we have reduces some friction
for building our bootstrap tools independently in other environments.

Reviewed by:	imp
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38274
2023-02-08 00:09:10 -06:00
Konstantin Belousov
69efe3695d config(8): remove support for -p
and other equivalent ways to request mcount-based profiling, like
'profile N' in kernel config.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D29529
2021-04-02 15:41:51 +03:00
Bryan Drewery
5dda1d0b82 config: Add no-ctfconvert support.
Bump CONFIGVERS to 600018 for this support.

Some files may purposely have debug info disabled or are *source files*
that attempt to run ctfconvert on them. Currently ctfconvert ignores
these errors but I have a change to make the errors real so we can
catch real problems like exceeding type limits.

Sponsored by:		Dell EMC
Reviewed by:		imp, cem, kevans
Differential Revision:	https://reviews.freebsd.org/D24535
2020-04-28 16:09:22 +00:00
Kyle Evans
a33e986417 config(8): fixes for -fno-common
Move this handful of definitions into main.c, properly declare these as
extern in config.h. This fixes the config(8) build with -fno-common.

Unexplained in my previous commit to gas, -fno-common will become the
default in GCC10 and LLVM11, so it's worth addressing these in advance.

MFC after:	3 days
2020-03-28 04:02:00 +00:00
Emmanuel Vadot
91221f548e config: Only warn if duplicate option/device comes from the same file
This is useful for arm (possibly other arches too) where we want to have
a GENERIC kernel that only include files for the different SoC. Since
multiple SoCs/Board needs the same device we would need to do either :

    Include the device in a generic file
    Include the device in each file that really needs it

Option 1 works but if someone wants to create a specific kernel config
(which isn't uncommon for embedded system), he will need to add a lots
of nodevice to it.

Option 2 also works but produce a lots of warnings.

Reviewed by:	kevans
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19424
2019-04-16 20:08:19 +00:00
Kyle Evans
8e62839eb1 config(8): Add compatibility shims for r335998
Plumb the %VERSREQ from Makefile.<arch> through to the rest of config(8).
We've recorded the config(8) version that we're calling "the end of
envmode and hintmode," and we'll write them out for earlier versions. Later
kernel version bumps will remove envmode/hintmode from the kernel as needed,
which is OK since the current kernel does not use them at all.

These compatibility shims really need to go away when the major version
rolls over...

Discussed with:	imp
2018-07-17 14:14:53 +00:00
Kyle Evans
39d44f7f15 kern_environment: use any provided environments, evict hintmode/envmode
At the moment, hintmode and envmode are used to indicate whether static
hints or static env have been provided in the kernel config(5) and the
static versions are mutually exclusive with loader(8)-provided environment.
hintmode *can* be reconfigured later to pull from the dynamic environment,
thus taking advantage of the loader(8) or post-kmem environment setting.

This changeset fixes both problems at once to move us from a semi-confusing
state to a consistent state: if an environment file, hints file, or
loader(8) environment are provided, we use them in a well-known order of
precedence:

- loader(8) environment
- static environment
- static hints file

Once the dynamic environment is setup this becomes a moot point. The
loader(8) and static environments are merged (respecting the above order of
precedence), and the static hints are merged in on an as-needed basis after
the dynamic environment has been setup.

Hints lookup are changed to respect all of the above. Before the dynamic
environment is setup, lookups use the above-mentioned order and fallback to
the next environment if a matching hint is not found. Once the dynamic
environment is setup, that is used on its own since it captures all of the
above information plus any dynamic kenv settings that came up later in boot.

The following tangentially related changes were made to res_find:

- A hintp cookie is now passed in so that related searches continue using
  the chain of environments (or dynamic environment) without relying on
  global state
- All three environments will be searched if they actually have valid hints
  to use, rather than just choosing the first environment that actually had
  a hint and rolling with that only

The hintmode sysctl has been ripped out. static_{env,hints}.disabled are
still honored and will disable their respective environments from being used
for hint lookups and from being merged into the dynamic environment, as
expected.

MFC after:	1 month (maybe)
Differential Revision:	https://reviews.freebsd.org/D15953
2018-07-05 16:30:32 +00:00
Kyle Evans
e28687347f Revert r335995 due to accidental changes snuck in 2018-07-05 16:28:43 +00:00
Kyle Evans
8ef5886303 kern_environment: use any provided environments, evict hintmode/envmode
At the moment, hintmode and envmode are used to indicate whether static
hints or static env have been provided in the kernel config(5) and the
static versions are mutually exclusive with loader(8)-provided environment.
hintmode *can* be reconfigured later to pull from the dynamic environment,
thus taking advantage of the loader(8) or post-kmem environment setting.

This changeset fixes both problems at once to move us from a semi-confusing
state to a consistent state: if an environment file, hints file, or
loader(8) environment are provided, we use them in a well-known order of
precedence:

- loader(8) environment
- static environment
- static hints file

Once the dynamic environment is setup this becomes a moot point. The
loader(8) and static environments are merged (respecting the above order of
precedence), and the static hints are merged in on an as-needed basis after
the dynamic environment has been setup.

Hints lookup are changed to respect all of the above. Before the dynamic
environment is setup, lookups use the above-mentioned order and fallback to
the next environment if a matching hint is not found. Once the dynamic
environment is setup, that is used on its own since it captures all of the
above information plus any dynamic kenv settings that came up later in boot.

The following tangentially related changes were made to res_find:

- A hintp cookie is now passed in so that related searches continue using
  the chain of environments (or dynamic environment) without relying on
  global state
- All three environments will be searched if they actually have valid hints
  to use, rather than just choosing the first environment that actually had
  a hint and rolling with that only

The hintmode sysctl has been ripped out. static_{env,hints}.disabled are
still honored and will disable their respective environments from being used
for hint lookups and from being merged into the dynamic environment, as
expected.

MFC after:	1 month (maybe)
Differential Revision:	https://reviews.freebsd.org/D15953
2018-07-05 16:25:48 +00:00
Kyle Evans
4edfa9085a config(8): Make 'env' files consistent with other file-accepting options
Previously, only one 'env' file could be specified. Later 'env' directives
would overwrite earlier 'env' directives. This is inconsistent with every
other file-accepting directives which process files in order, including
hints.

A caveat applies to both hints and env that isn't mentioned: they're
concatenated in the order of appearance, so they're not actually applied in
the way one might think by supplying:

hints x
hints y

Hints in x will take precedence over same-name hints in y due to how
the kernel processes them, stopping at the first line that matches the hint
we're searching for. Future work will flip the order of concatenation so
that later files may still properly override earlier files.

In practice, this likely doesn't matter at all due to the nature of the
beast.
2018-06-26 03:56:10 +00:00
Kyle Evans
3b31596dc8 config(8): Add envvar support
envvar allows adding individual environment variables to the kernel's static
environment without the overhead of pulling in a full file. envvar in a
config looks like:

envvar some_var=5

All envvar-provided variables will be added after the env file is processed,
so envvar keys that exist in the previous env will be overwritten by
whatever value is set here in the kernel configuration directly.

As an aside, envvar lines are intentionally tokenized differently from
basically every other line. We used a named state when ENVVAR is encountered
to gobble up the rest of the line, which will later be cleaned and validated
in post-processing by sanitize_envline. This turns out to be the simplest
and cleanest way to allow the flexibility that kenv does while not
compromising on silly hacks.

Reviewed by:	ian (also contributor of sanitize_envline rewrite)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D15962
2018-06-25 17:17:47 +00:00
Pedro F. Giffuni
8a16b7a18f General 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:49:47 +00:00
Bryan Drewery
1bf59a71c7 Fix 'local' to not look in the source tree for the file.
Usually 'local' is used along with other rules such as 'no-implicit-rule' or
'dependency' which avoids this problem.  It's possible to need to use 'local'
while relying on the default rules though for a file which is not in the source
tree nor generated in the kernel.

Sponsored by:	Dell
Differential Revision:	https://reviews.freebsd.org/D13125
2017-11-17 18:34:14 +00:00
Nick Hibma
cc5cd33264 Typo in filename in comment. 2017-09-28 12:43:25 +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
Eitan Adler
463a577b27 Fix a ton of speelling errors
arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
2015-10-21 05:37:09 +00:00
Alan Somers
ae0944614d Fix kern/187712: config(8) does not respect KERNCONFDIR.
The impact of this bug is that you cannot build a kernel if both of the
following are true:
1) The kernel config file is in a non-default location
2) The kernel config file uses the "include" statement from config(5).

usr.sbin/config/main.c
usr.sbin/config/config.8
usr.sbin/config/config.h
usr.sbin/config/lang.l
	Added a "-I path" option to config(8).  By analogy to cc(1), it adds
	an extra path in which the "include" statement will search for
	files.

Makefile.inc1
	Pass "-I ${KERNCONFDIR}" to config(8).

PR:		kern/187712
Reviewed by:	will, imp (previous version)
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corporation
2014-03-20 17:30:09 +00:00
Baptiste Daroussin
5e2a209a27 Fix world after byacc import:
- old yacc(1) use to magicially append stdlib.h, while new one don't
- new yacc(1) do declare yyparse by itself, fix redundant declaration of
  'yyparse'

Approved by:	des (mentor)
2012-05-22 16:33:10 +00:00
Jeff Roberson
e4cd31dd3c - Merge changes to the base system to support OFED. These include
a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND,
   and other miscellaneous small features.
2011-03-21 09:40:01 +00:00
Warner Losh
90aa4f9e8c Move checking the version up from Makefile generation to just after
we've parsed the config file.  Makefile generation is too late if
we've introduce changes to the syntax of the metafiles to warn about
version skew, since we have to try to parse them and we get an parse
error that's rather baffling to the user rather than a 'your config is
too old, upgrade' which we should get.

We have to defer doing it until after we've read the user's config
file because we define machinename there.  The version required to
compile the kernel is encoded in Makefile.machinename.  There's no
real reason for this to be the case, but changing it now would
introduce some logistical issues that I'd rather avoid for the moment.
I intend to revisit this if we're still using config in FreeBSD 10.

This also means that we cannot introduce any config metafile changes
that result in a syntax error or other error for the user until 9.0 is
released.  Otherwise, we break the upgrade path, or at least reduce
the usefulness of the error messages we generate.

# This implies that the config file option mapping will need to be redone.

MFC after:	3 days
2010-04-27 05:04:32 +00:00
Warner Losh
e1a4e3fa37 Allow option aliasing. Lines of the form:
OLD_OPT = NEW_OPT

in options* files will now map OLD_OPT to NEW_OPT with a friendly
message.  This is indented for situations where we need to preserve an
interface in the config file in an upwards compatible fashion on a
stable branch.

Reviewed by:	nwhitehorn@
MFC after:	3 days
2010-04-15 15:10:46 +00:00
Andrew Thompson
2880daeb77 Allow multiple makeoption lines to be used with the += operator, this permits
the following syntax in the kernel config.

 makeoptions MODULES_OVERRIDE=foo
 makeoptions MODULES_OVERRIDE+=bar
 makeoptions MODULES_OVERRIDE+=baz

Bump config minor version to 600007.
2008-11-22 21:12:47 +00:00
Warner Losh
c1f4dd9355 Fix some problems that affect multiple file inclusion. Bruce found
this bug and submitted these patches to dunstan@.  He sent them to me
to test, and I discovered they were needed for the atmel kernel config
files.  Since we were playing with them in the terminal room after the
developer's summit today, I thought I'd go ahead and commit them to
allow those folks that now have atmel hardware (thanks Andre) a chance
to try it out w/o my help.  Since dunstan@ is asleep right now, risk
stepping on his toes a little by going ahead and committing this
change.

Submitted by: dunstan@, bde@
Tested by: bde@
2007-05-17 04:53:52 +00:00
Wojciech A. Koszek
744b947ef8 Improve INCLUDE_CONFIG_FILE support.
This change will let us to have full configuration of a running kernel
available in sysctl:

	sysctl -b kern.conftxt

The same configuration is also contained within the kernel image. It can be
obtained with:

	config -x <kernelfile>

Current functionality lets you to quickly recover kernel configuration, by
simply redirecting output from commands presented above and starting kernel
build procedure. "include" statements are also honored, which means options
and devices from included files are also included.

Please note that comments from configuration files are not preserved by
default. In order to preserve them, you can use -C flag for config(8). This
will bring configuration file and included files literally; however,
redirection to a file no longer works directly.

This commit was followed by discussion, that took place on freebsd-current@.
For more details, look here:

	http://lists.freebsd.org/pipermail/freebsd-current/2007-March/069994.html
	http://lists.freebsd.org/pipermail/freebsd-current/2007-May/071844.html

Development of this patch took place in Perforce, hierarchy:

	//depot/user/wkoszek/wkoszek_kconftxt/

Support from:	freebsd-current@ (links above)
Reviewed by:	imp@
Approved by:	imp@
2007-05-12 19:38:18 +00:00
Warner Losh
86418d0cef End my resistance to jmg's multiple hints files and bring in support
for having multiple hints files generate a correct hints.c (eg, with
all the specified ones catenated together).
2006-10-24 00:31:59 +00:00
Ruslan Ermilov
22025511b4 Clean up most of the "XXX"-tagged items:
- The code that creates hints.c and env.c from the skeleton files
  moved into separate functions.

- Sanity checks for missing "ident" and "cputype" directives moved
  into main(), alongside the existing check for "machine".

PR:		bin/90310
Submitted by:	Matt Emmerton <matt@gsicomp.on.ca>
2005-12-30 15:29:50 +00:00
Ruslan Ermilov
61ede7eeac Clean some code that became obfuscated over the years:
Don't keep duplicate files in the files list just to
mark the device as "known" later.  XXX: Since the
device list isn't unique (there can be two "device foo"
directives, as this the case with LINT+DEFAULTS), we
have to traverse it all to mark all copies of the same
device as "used", but this is not worse than it was.
2005-11-25 22:25:34 +00:00
John Baldwin
dfdbf9be00 Optionally include a DEFAULTS config file if it is present in the current
directory before the specified config file.  This is implemented by
opening DEFAULTS as stdin if it exists, and if so resetting stdin to the
actual config file when DEFAULTS is fully parsed via yywrap().  In short,
this lets us create DEFAULTS kernel configs in /sys/<arch>/conf that can
enable certain options or devices by default and allow users to disable
them via 'nooptions' or 'nodevice' rather than having to create kludge
NO_FOO options.

Requested by:	scottl
Reviewed by:	scottl
2005-10-27 17:13:23 +00:00
Warner Losh
51c1297a48 Allow one to specify a second parameter to the machine line. This
allows us to specify the machine_arch as well as machine.  If
specified then a second link will be made, similar to machine, from
$MACHINE_ARCH to $S/$MACHINE_ARCH/include.

This is for ports where MACHINE != MACHINE_ARCH (pc98 today, others in
the future?).

Reviewed by: arch@, nyan@
2005-04-01 22:54:22 +00:00
Peter Wemm
f37a929ca1 Kill count device support from config. I've changed the last few
remaining consumers to have the count passed as an option.  This is
i4b, pc98/wdc, and coda.

Bump configvers.h from 500013 to 600000.

Remove heuristics that tried to parse "device ed5" as 5 units of the ed
device.  This broke things like the snd_emu10k1 device, which required
quotes to make it parse right.  The no-longer-needed quotes have been
removed from NOTES, GENERIC etc.  eg, I've removed the quotes from:
   device  snd_maestro
   device  "snd_maestro3"
   device  snd_mss

I believe everything will still compile and work after this.
2004-08-30 23:03:58 +00:00
Warner Losh
23717fc46a Per letter dated July 22, 1999, delete clause 3 from code directly
from Berkeley.
2004-08-07 04:19:37 +00:00
Olivier Houchard
43a903c091 Add a new "files" directive, which allows to include a files.foo file directly
from a kernel config file.
Bump config version to reflect this change.
2004-05-09 22:29:00 +00:00
Ruslan Ermilov
292dd8a87f Convert to using <sys/queue.h> macros. 2003-02-15 02:26:13 +00:00
Peter Wemm
7a2eb19dbf Commit some infrastructure for turning on -Werror for kernel compiles.
It doesn't actually do it yet though.  This adds a flag to config so
that we can exclude certain vendor files from this even when the rest
of the kernel has it on.  make -DNO_WERROR would also bypass all of it.
2002-02-20 23:35:56 +00:00
Peter Wemm
76cb0cadf1 Enable hardwiring of things like tunables from embedded enironments
that do not start from loader(8).
2001-08-27 05:11:53 +00:00
Dima Dorfman
5e06480c9f Introduce an "include" directive. It takes one argument, a filename
to be included into this one.  This works the same way as #include
does in C; as far as the user is concerned, the included file is
inlined into the current one.

Since config(8) is no longer limited to working on one user-supplied
file, printing just a line number in an error message is not
sufficient.  The new global variable yyfile represents the file
currently being parsed, and must be printed as well.

Reviewed by:	imp
Obtained from:	OpenBSD
2001-07-12 02:08:51 +00:00
Peter Wemm
6f34947de7 newbus_ioconf() is long gone 2001-02-28 02:55:15 +00:00
Peter Wemm
f9f6bfe762 Some more tidying up. we dont use config-dependent anyware. Eliminate
some duplicate code (cut/paste bug?). tidy up some other minor stuff.
2001-02-28 02:53:32 +00:00
Peter Wemm
388481c1b7 s/special/compilewith/ (so I stop confusing myself) and GC an unused
function I missed before.
2001-02-28 02:30:30 +00:00
Peter Wemm
2db1cff10d Collect together a handful of copies of the option generator code into a
single newopt(char *name, char *value) function.  Change newdev() to
do the same thing rather than depending on the evil 'cur' device hack.
2001-02-22 03:40:50 +00:00
Peter Wemm
68f4fced95 ${BDECFLAGS} work. And fix a real error in the process. A "MAXUSERS"
string could have been passed to free();  There are some warnings here
I am not sure how to fix as they are in the lex scanner code, etc.
2001-02-19 04:43:21 +00:00
Peter Wemm
3b10a240e5 Remove the need to list each and every cpu platform. Config will now
take your word for the 'machine' switch.
2001-02-04 13:17:38 +00:00
Peter Wemm
246449f3e3 Unwind a bit more cruft - we only have one type of device now. 2001-01-31 10:30:30 +00:00
Peter Wemm
ace858085f Redo the stray header file cleanup code to not depend on timestamps
or access times or anything.  Just bite the bullet and keep a list of
header files that we know about.
2001-01-31 08:42:35 +00:00
Benno Rice
9abfa9d14b Add support for configuring PowerPC kernels.
Reviewed by:	peter
2001-01-22 12:10:45 +00:00
Doug Rabson
918c9eec57 Add ia64 support. 2000-09-29 13:36:47 +00:00
Peter Wemm
596feda554 If a ${KERNEL}.hints file exists, and no hints are specified explicitly,
then include the hints with a marker indicating that it is a fallback.
The kernel side of this is to come shortly.
2000-08-25 19:30:03 +00:00
Peter Wemm
f71c01cc52 Borrow phk's axe and apply the next stage of config(8)'s evolution.
Use Warner Losh's "hint" driver to decode ascii strings to fill the
resource table at boot time.

config(8) no longer generates an ioconf.c table - ie: the configuration
no longer has to be compiled into the kernel.  You can reconfigure your
isa devices with the likes of this at loader(8) time:
  set hint.ed.0.port=0x320

userconfig will be rewritten to use this style interface one day and will
move to /boot/userconfig.4th or something like that.

It is still possible to statically compile in a set of hints into a kernel
if you do not wish to use loader(8).  See the "hints" directive in GENERIC
as an example.

All device wiring has been moved out of config(8).  There is a set of
helper scripts (see i386/conf/gethints.pl, and the same for alpha and pc98)
that extract the 'at isa? port foo irq bar' from the old files and produces
a hints file.  If you install this file as /boot/device.hints (and update
/boot/defaults/loader.conf - You can do a build/install in sys/boot) then
loader will load it automatically for you.  You can also compile in the
hints directly with:  hints "device.hints"  as well.

There are a few things that I'm not too happy with yet.  Under this scheme,
things like LINT would no longer be useful as "documentation" of settings.
I have renamed this file to 'NOTES' and stored the example hints strings
in it.  However... this is not something that config(8) understands, so
there is a script that extracts the build-specific data from the
documentation file (NOTES) to produce a LINT that can be config'ed and
built.  A stack of man4 pages will need updating. :-/

Also, since there is no longer a difference between 'device' and
'pseudo-device' I collapsed the two together, and the resulting 'device'
takes a 'number of units' for devices that still have it statically
allocated.  eg:  'device fe 4' will compile the fe driver with NFE set
to 4.  You can then set hints for 4 units (0 - 3).  Also note that
'device fe0' will be interpreted as "zero units of 'fe'" which would be
bad, so there is a config warning for this.  This is only needed for
old drivers that still have static limits on numbers of units.
All the statically limited drivers that I could find were marked.

Please exercise EXTREME CAUTION when transitioning!

Moral support by: phk, msmith, dfr, asmodai, imp, and others
2000-06-13 22:28:50 +00:00
Peter Wemm
3f664fc689 A checkpoint of a part of a work-in-progress. Some more cleanups for
config(8).  This commit allows control of the creation of the
#include "foo.h" files.  We now only create them explicitly when needed.
BTW; these are mostly bad because they usually imply static limits on
numbers of units for devices.  eg: struct mysoftc sc[NFOO];
These static limits have Got To Go.
2000-06-10 22:13:40 +00:00