Commit Graph

510 Commits

Author SHA1 Message Date
Kyle Evans
35beb9285b lualoader: Match Forth module-loading behavior w.r.t flags
Also as documented in loader.conf(5), ${module}_flags are actually flags to
be passed to the module, not to `load` as was done thus far.
2018-06-12 18:42:41 +00:00
Kyle Evans
5d2791646b lualoader: More black-on-white fixes
To recap the problem: with a black-on-white xterm, the menu draws terribly.
Ideally, we would try our best for a white-on-black context for the menu
since graphics and whatnot might not be tested for other setups and there's
no reasonable way to sample the terminal at this point for the used color
scheme.

This commit attempts to address that further in two ways:
- Instead of issuing CSI bg/fg resets (CSI 39m and CSI 49m respectively for
  "default"), issue CSI bg/fg escape sequences for our expected color scheme
- Reset to *our* default color scheme before we even attempt to load the
  local module, so that we personally don't have any earlier text with the
  console default color scheme.

Reported by:	emaste (again)
2018-06-12 03:44:34 +00:00
Kyle Evans
e21e1dbe0c lualoader: Allow brand-*.lua for adding new brands
dteske@, I believe, had originally pointed out that lualoader failed to
allow logo-*.lua for new logos to be added. When correcting this mistake, I
failed to do the same for brands.

Correct the sub-mistake: creating new brands is almost identical to creating
new logos, except one must use `drawer.addBrand` and 'graphic' is the only
valid key for a branddef at the moment.

While here, I've added `drawer.default_brand` to be set to name of brand to
be used (e.g. 'fbsd', project default).

Eventually this whole goolash will be documented.

Reported by:	kmoore, iXsystems
2018-06-11 01:32:18 +00:00
Kyle Evans
deb8c8f55c lualoader: Support variable substitution in env var settings
We support both of the following cases of substitution:

bar="y"
foo="${bar}"
foo="$bar"

The latter substitution syntax is, of course, not recommended- all
punctuation must be considered potential variable names, and we do not go
through the effort of searching the different combinations of, for instance,
"$x.y.z" to determine if the variable is $x, $x.y, or $x.y.z.

This is not officially documented as supported, but it has worked in
forthloader for what is most likely a long time as `evaluate` is used to
process the right hand side of the assignment.
2018-06-10 02:36:38 +00:00
Kyle Evans
4072dcb3c7 lualoader: Process loader_conf_files properly
loader.conf(5) documents loader_conf_files to mean "additional configuration
files to be processed right after the present file." However, lualoader
ignored loader_conf_files after processing /boot/defaults/loader.conf.

Rewrite these bits to process loader_conf_files after each loaded file.
2018-06-10 01:38:52 +00:00
Kyle Evans
d4f745563d lualoader: Add cli.lua(8) to the tree
Reviewed by:	rpokala
Differential Revision:	https://reviews.freebsd.org/D14818
2018-06-09 19:51:09 +00:00
Kyle Evans
3db6d179e8 stand: One more trivial consolidation (setting environment from howto) 2018-06-09 15:52:29 +00:00
Kyle Evans
28ee318d9c stand: Fix build after r334882
Not sure how this was not caught in Universe.
2018-06-09 15:28:37 +00:00
Kyle Evans
593e2c6ece stand: Consolidate checking for boot flags driven by environment vars
e.g. boot_mute, boot_single, boot_verbose, and friends; we checked for these
in multiple places, consolidate into common/ and allow a setting of "NO" for
any of these to turn them off. This allows systems with multiple
loader.conf(5) or loader.conf(5) overlay systems to easily turn off
variables in later processed files by setting it to NO.

Reported by:	Nick Wolff @ iXsystems
Reviewed by:	imp
2018-06-09 15:10:39 +00:00
Kyle Evans
7150314eae lualoader: Add hook.lua(8) to tree
Reviewed by:	rpokala (w/ "All Rights Reserved" previously added)
Differential Revision:	https://reviews.freebsd.org/D14815
2018-06-09 14:26:30 +00:00
Kyle Evans
f6b2a4291b libsa(3): Correct statement about FS Write-support, name change
- jhb implemented UFS write support a little over 16 years ago.
- Update the library name while we're here.

Reviewed by:	jhb, rpokala
Differential Revision:	https://reviews.freebsd.org/D14476
2018-06-09 14:24:16 +00:00
Simon J. Gerraty
5ad42d0f47 Add st_mtime, st_ino and st_dev for ufs_stat
Differential Revision:	D15064
2018-06-09 02:41:51 +00:00
Kyle Evans
7aba5b2f6a lualoader: Add a loaded hook for others to execute upon config load
This will not be executed on reload, though later work could allow for that.
It's intended/expected that later work won't generally need to happen on
every config load, just once (for, e.g., menu initialization) or just when
config is reloaded but not upon the initial load.
2018-06-06 18:28:17 +00:00
Ian Lepore
9f6fd8397c Remove comments and assertions that are no longer valid after r330809.
r330809 replaced duplication of devdesc struct fields with an embedded copy
of the devdesc struct, to avoid fragility.  That means all the scattered
comments indicating that structs must match are no longer valid.  Likewise
asserts that attempted to mitigate some of the old fragility.

Reviewed by:	imp@
2018-06-05 22:13:45 +00:00
Ian Lepore
3e9c7874ce Make the v*printf() functions in libsa return int instead of void.
This makes them compatible with the C standard signatures, avoiding
spurious mismatch errors in the places where the oddball requirements
of standalone code end up putting two declarations of the same function
in play.
2018-06-05 17:18:10 +00:00
Ian Lepore
1851d70d31 Add vsnprintf() to libsa. Alpha-sort the printf prototypes in stand.h.
I'm not sure why the v*printf() functions in libsa return void instead of
int, but this maintains that convention for the new function.
2018-06-05 14:47:13 +00:00
Dimitry Andric
073193ed51 Fix build of stand with base gcc
* Make autoboot() a static function in stand/common/boot.c, so it does
  not shadow local variables in gptboot.c and zfsboot.c.
* Remove -Winline from the Makefiles for gptboot, gptzfsboot and
  zfsboot, as gcc will always fail to inline some functions, and there
  is nothing we can do about it.
* For gcc <= 4.2.1, silence -Wuninitialized for isoboot, as it produces
  a false positive warning.
* Remove deprecated and unnecessary -mcpu=i386 flag from stand/defs.mk,
  as there is already a -march=i386 flag further in the file.

Reviewed by:	imp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D15628
2018-05-31 14:38:13 +00:00
Warner Losh
3dfe152d8d Pass a struct devdesc to the format commands. Use proper type rather
than doing weird type-punning that happened to work because the size
was right. We copied a zfs devdesc into a disk_devdesc and then after
passing through a NULL pointer reinterpreted it as a
zfs_devdesc. Instead, pass the base devdesc around and 'upcase' when
we know the types are right.

This has the happy side effect of fixing a gcc warning about bad
type punning.

Differential Revision: https://reviews.freebsd.org/D15629
2018-05-31 02:54:11 +00:00
Warner Losh
9958932695 Teach ufs_module.c about bsd labels and probe 'a' partition.
If the check for a UFS partition at offset 0 on the disk fails, check
to see if there's a BSD disklabel at block 1 (standard) or at offset
512 (install images assume 512 sector size). If found, probe for UFS
on the 'a' partition.

This fixes UEFI booting images from a BSD labeled MBR slice when the
'a' partiton isn't at offset 0. This is a stop-gap fix since we plan
on removing boot1.efi in FreeBSD 12. We can't easily do that for 11.2,
however, hence the short MFC window.

Tested by: emaste@
MFC After: 3 days
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D15598
2018-05-29 03:58:29 +00:00
Marius Strobl
dd5dbb3199 - Unbreak booting sparc64 kernels after the metadata unification in
r329190; sparc64 kernels are always 64-bit but with that revision
  in place, the loader was treating them as 32-bit ones.
- In order to reduce the likelihood of this kind of breakage in the
  future, #ifdef out md_load() on sparc64 and make md_load_dual() -
  which is currently local to metadata.c anyway - static.
- Make md_getboothowto() - also local to metadata.c - static.
- Get rid of the unused DTB pointer on sparc64.
2018-05-21 01:20:19 +00:00
Ed Maste
408c1ff8f4 Clarify that boot_mute / boot -m mutes kernel console only
Perhaps RB_MUTE could mute user startup (rc) output as well, but right
now it mutes only kernel console output, so make the documentation match
reality.

PR:		228193
Sponsored by:	The FreeBSD Foundation
2018-05-16 02:15:18 +00:00
Warner Losh
09001b5c78 Revert r333365
Even though we don't use it, it appears something else requires it to
be != 0 to work. This breaks tftp boot in loader.efi, so revert until
that can be sorted out.
2018-05-10 20:27:12 +00:00
Mariusz Zaborski
31f7586d73 Introduce the 'n' flag for the geli attach command.
If the 'n' flag is provided the provided key number will be used to
decrypt device. This can be used combined with dryrun to verify if the key
is set correctly. This can be also used to determine which key slot we want to
change on already attached device.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D15309
2018-05-09 20:53:38 +00:00
Kyle Evans
4b3c64f722 Remove "All Rights Reserved" on files that I hold sole copyright on
See r333391 for more detail; in summary: it holds no weight and may be
removed.
2018-05-09 16:44:19 +00:00
Warner Losh
a1947307e7 We don't use f_devdata, so don't set it. Should that need to change
later, we can. This leaves ZFS as the only irregular f_devdata
user in the tree.
2018-05-08 16:16:56 +00:00
Warner Losh
e4eef18848 Use M. Warner Losh everywhere on my copyrights.
Remove 'All Rights Reserved' where I can.
2018-05-01 16:29:22 +00:00
Warner Losh
ad7d33c45b No need to make objects here. 2018-04-27 22:15:18 +00:00
Kyle Evans
fb205d37d7 forthloader: Remove "EFI boot environment message"
Contrary to what the message says, this is not only executed in an EFI
context- it provides functions for use in an EFI environment. I don't think
there's much reason to broadcast this fact when we haven't in the past, so
just remove it.

Reported by:	emaste (a while ago), cperciva
2018-04-25 02:42:57 +00:00
Ed Maste
b25a46f7f7 Add support for linker-type-specific flags
r332090 added a LINKER_TYPE test to add the --no-rosegment flag when
linking the i386 loader components with lld.  Instead, introduce a
general mechanism for setting LDFLAGS for a specific linker type,
and use it for --no-rosegment.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14998
2018-04-19 20:58:09 +00:00
Kyle Evans
807dbf2b94 efi loader: Address two nits with recent graphics changes
- We should be setting a known graphics mode on conout, but we aren't.
- We shouldn't be setting gop mode if we didn't find a good resolution to
  set, but we were. This made efi_max_resolution=1x1 effectively worthless,
  since it would always set gop mode 0 if nothing else.
2018-04-19 03:31:41 +00:00
Kyle Evans
87c0258beb Regenerate FAT templates after r332561 2018-04-16 15:13:18 +00:00
Toomas Soome
b67d407ac7 loader: cstyle cleanup of command.c
just clean it up. no functional changes intended.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D15087
2018-04-16 14:10:19 +00:00
Kyle Evans
db911ed570 Rename volume label for ESP
Harry Schmalzbauer reports that some firmware, in his experience, trips
over the ESP we install due to the volume label. It has been theorized that
this is due to some confusion with the label and the path on the ESP to
boot1.efi.

Regardless, Harry found that renaming the label seems to fix it.

PR:		214282
MFC after:	3 days
2018-04-16 13:18:18 +00:00
Toomas Soome
6d68f8acf4 loader: make sure we do not return garbage from help_getnext
Since we do free subtopic and desc in help_getnext(), we need to set them also
NULL, so we make sure we dont get double free().

Approved by:	bapt
Differential Revision:	https://reviews.freebsd.org/D15082
2018-04-16 12:46:14 +00:00
Toomas Soome
746dddb134 loader: command_errmsg should be const
Use const char * for command_errmsg.
2018-04-16 08:41:44 +00:00
Toomas Soome
faa5306390 loader: make sure we use snprintf() in commands.c
Safeguard against memory corruptions.
2018-04-16 08:15:50 +00:00
Toomas Soome
5276f60430 loader: provide values in help_getnext()
With r328289 we attempt to make sure we free the resources allocated in
help_getnext(), however, it is possible that we get no resources allocated
and help_getnext() will return early.

Make sure we have pointers set to NULL early in help_getnext().

Reported by:	Andy Fiddaman
2018-04-16 07:26:23 +00:00
Brooks Davis
3a4fc8a8a1 Remove support for the Arcnet protocol.
While Arcnet has some continued deployment in industrial controls, the
lack of drivers for any of the PCI, USB, or PCIe NICs on the market
suggests such users aren't running FreeBSD.

Evidence in the PR database suggests that the cm(4) driver (our sole
Arcnet NIC) was broken in 5.0 and has not worked since.

PR:		182297
Reviewed by:	jhibbits, vangyzen
Relnotes:	yes
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15057
2018-04-13 21:18:04 +00:00
Warner Losh
fa9dc8d3ed Refactor currdev setting
Refactor the currdev setting to find the device we booted from. Limit
searching when we don't already have a reasonable currdev from that to
the same device only. Search a little harder for ZFS volumes as that's
needed for loader.efi to live on an ESP.

Sponsored by: Netflix
Differential Review: https://reviews.freebsd.org/D13784
2018-04-11 19:46:24 +00:00
Warner Losh
7afc7a8717 Revert r332275, r332272, r332270
There's problems with them. The order of efi stuff isn't quite right,
and there's various problems. Revert until thos problems can be fixed.

Reviewed by: kevans@
2018-04-11 18:02:13 +00:00
Toomas Soome
74837c798c loader: 332270 did left out stand/i386/loader/loader.rc
we have 2 instances of loader.rc...
2018-04-08 13:40:38 +00:00
Toomas Soome
ff77d7a560 loader: 332270 did use wrong path for efi.4th
The correct  path is still /boot/efi.4th
2018-04-08 11:55:27 +00:00
Toomas Soome
cae0ecf693 loader: include efi.4th only if we do have uefi
Also simplify efi.4th.
2018-04-08 11:39:27 +00:00
Toomas Soome
b1e0bc1210 libsa: name is not used in dirmatch()
Seems like variable 'name' is leftover.
2018-04-07 14:42:47 +00:00
Toomas Soome
213f235f49 libsa: cd9660: warning: 'lenskip' may be used uninitialized in this function
We better provide value for lenskip in both instances.
2018-04-07 14:40:09 +00:00
Kyle Evans
814a016d28 lualoader: Fix menu skipping with loader.conf(5) vars
Earlier efforts to stop loading the menu broke the ability to skip the menu
with, e.g., beastie_disable in loader.conf(5) as it was decided before
configuration was read.

Defer bringing in the menu module until we've loaded configuration so that
we can make a more informed decision on whether the menu should be skipped
or not.
2018-04-06 15:19:48 +00:00
Ed Maste
93b980a802 stand: pass --no-rosegment for i386 bits when linking with lld
btxld does not correctly handle input with other than 2 PT_LOAD
segments.  Passing --no-rosegment lets lld produce output eqivalent to
ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO.

PR:		225775
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14956
2018-04-06 02:57:58 +00:00
Benno Rice
48990fce8e Add an ISO9660 "partition table" type to loader.
When booted via isoboot(8) loader will be handed a disk that simply contains
an ISO9660 image. Currently this confuses it greatly. Teach it how to spot
that it's in this situation and that ISO9660 has one "partition" covering
the whole disk.

Reviewed by:	imp
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D14915
2018-04-05 19:45:30 +00:00
Benno Rice
7acb51f681 Add isoboot(8) for booting BIOS systems from HDDs containing ISO images.
This is part of a project for adding the ability to create hybrid CD/USB boot
images. In the BIOS case when booting from something that isn't a CD we need
some extra boot code to actually find our next stage (loader) within an
ISO9660 filesystem. This code will reside in a GPT partition (similar to
gptboot(8) from which it is derived) and looks for /boot/loader in an
ISO9660 filesystem on the image.

Reviewed by:	imp
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D14914
2018-04-05 19:40:46 +00:00
Benno Rice
288013f54c Various style(9) fixes.
Reviewed by:	strip --strip-debug -o - gptboot.o | md5
Sponsored by:	iXsystems, Inc.
2018-04-05 19:29:22 +00:00