Commit Graph

321 Commits

Author SHA1 Message Date
Warner Losh
861f802b3e textvidc: Reindent
Since this is now 'new code' go ahead and reindent for modern project
preferences.

Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh
3f012b9508 loader: stlye(9) nit: Space between return and the value
Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh
2d425b634f loader: c_init returns 0 or 1
c_init returns 0 (success) or 1 (failure). Don't return other values.

Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh
5e7b0cd93a i386/nullconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh
803060b217 i386/spinconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh
a578e2b896 boot/i386: Use C99 initializer for textvidc
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Ed Maste
3bd637afbd boot0: remove reference to fdisk
fdisk is obsolete and there is no need to mention a specific tool used
to update the partition table.  Just refer to it as the MBR partition
table.

Sponsored by:	The FreeBSD Foundation
2024-03-25 15:59:09 -04:00
Warner Losh
3e15b01d69 libsa: Remove redundant sys/cdefs.h
Sponsored by:		Netflix
2024-02-22 09:31:57 -07:00
Warner Losh
32568e5f24 loader: Retire CTASSERT
The project is moving away from CTASSERT in favor of
_Static_assert. Cleanup the few instances in the loader proactively.

Sponsored by:		Netflix
Reviewed by:		manu, tsoome
Differential Revision:	https://reviews.freebsd.org/D44006
2024-02-21 08:51:34 -07:00
Warner Losh
bbfc01c2d2 loader: Make MK_LOADER_BIOS_TEXTONLY work
Select between text-only and graphical frame buffer consoles for the
BIOS boot loader. Pull one or the other in with #ifdef in conf.c. Add
gfx_bios.c for the few routines that are needed for the BIOS support of
gfx. These are stubbed out for text-only mode. Move bi_load_vbe_data
here since it's only used for the graphical frame buffer.

Note: This setup also allows us to build multiple BIOS loaders if we
have to, some with text-only and some graphical. We don't do this today.
We may be forced to turn this on in the future if ZFS keeps growing.

The size savings is 41k, which helps a lot with some of our users that
want to enable more options in the BIOS boot loader than are normally
safe to do, and they don't need graphics.

Sponsored by: 		Netflix
Differential Revision:	https://reviews.freebsd.org/D43917
2024-02-17 23:29:07 -07:00
Warner Losh
e36afddf11 loader: Add textvidc to build
Add textvidc to the build. And use -DTERM_EMU to build it.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43915
2024-02-17 23:29:07 -07:00
Warner Losh
1954e5c1dc loader: bring back old text-only video console
Bring back vidconsole.c as textvidc.c from 2a0e2c88db. This console
does no graphics stuff at all, supports no fancy logos, has known bugs
in the terminal emulation, etc. However, it is small. It will be a
build-time option to select between the two. The BIOS loader is running
out of space when too many options are selected, so this allows people
to select the smaller one to spend the space elsewhere. This is only the
verbatim copy of the old vidconsole.c. It's not yet connected to the
build.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43911
2024-02-17 23:29:07 -07:00
Warner Losh
e5d1a21e50 loader: Bump the limit to 560,000 bytes for BIOS loader
Further experience suggests we do not need as much margin. This was
mistakenly bumped to 570,000 in a prior commit, so this undoes that.

Sponsored by:		Netflix
2024-02-15 21:16:36 -07:00
Warner Losh
26c8dedef1 loader: line line per src file in libi386
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43913
2024-02-15 21:02:37 -07:00
Warner Losh
588ff0748f loader: Simplify build a little
Confine -DDISK_DEBUG to biosdisc.c, the only file it affects.
Use modern variable arrays instead of alloca and add a sanity
size minimum for biospnp nodes. These nodes are tiny enough that
we needn't do a malloc/free pair: the stack is fine.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D43914
2024-02-15 20:59:23 -07:00
Warner Losh
e34fd722ca kboot: Add our own lua bindings
Create a small wrapper around the new flua hash module so we can use it
here too. There's no 4th bindings, nor will they be created.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43874
2024-02-15 20:59:23 -07:00
Warner Losh
a27c1350e4 loader: Make vidc_biosputchar static
It's currently unused outside of vidconsole.c. Gerald Hicks' fix to the
beep code from de37e4a6d2333/1998 introduced the funciton as
static. Maxim Sobolev (sobomax) made it non-static since his spinconsole
called it in c4c3b35172d67/2009. When sobomax dropped the direct call
after making spinconsole console independent in b35172d67/2017,
vidc_biosputchar remained a harmless unreferenced global. Make it static
once again.

Fixes:		c7e10205ae
Sponsored by:	Netflix
2024-02-14 11:22:57 -07:00
Dag-Erling Smørgrav
7edbf69b79 stand: Add 1440p to the list of known resolutions.
MFC after:	1 week
Reviewed by:	manu, kevans, imp
Differential Revision:	https://reviews.freebsd.org/D43391
2024-01-23 15:20:27 +01:00
Kyle Evans
e183039f08 loader: lua: assume late ACPI detection if the feature isn't enabled
While we're here, enable the feature in the places we detect ACPI.  This
lets us side-step the existing issues and provide a path forward for
folks upgrading from previous releases that haven't updated their ESP
yet.

Let's also fix core.setACPI: the hint already indicates that the
user's disabled it more consistently than loader.acpi_disabled_by_user.
Even more, the latter is wrong because we set it by default if we did
not detect ACPI.  The ACPI hint remains even when we're setting defaults
because ACPI loaded into the kernel will make some noise if it's not
hinted off, even when we didn't detect it.

imp notes that this will result in some relatively harmless noise on
platforms that don't support ACPI but aren't using the UEFI loader, as
we would enable the ACPI module for loading on them and then loader
would not be able to find it.  These are non-fatal, but should probably
be fixed by just declaring support for EARLY_ACPI in those loaders since
we know they won't have ACPI early on -- punting on this for the time
being, though, in favor of providing a safer upgrade path sooner.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42727
2023-12-08 15:43:59 -06:00
Warner Losh
c596126a5d pmbr: Only load the first 545k rather than error out
It would be nice to have larger boot partitions for ESPs to live in one
day. It's trivial to carve out 5M 10M or 200M when provisioning, but
logistical issues may make it hard to do it after the fact. So only warn
when the partition is > 545k. If we ever grow the boot loader larger
than that, then it will be responsible for loading the rest anyway.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D42774
2023-11-27 15:45:56 -07:00
Warner Losh
7c43148a97 stand: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Stephen J. Kiernan
2008043f38 loader: add target for dirdeps build
Update dependencies for the loader variations used for each
architecture.

Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D39741
2023-11-02 19:35:08 -04:00
Ed Maste
4722ceb7d5 Use 115200 bps by default for serial communication
9600 was a standard baud rate decades ago, but 115200 is now more common
so choose defaults that are useful to the largest number of users.

Note that boot0sio does not support rates above 9600 so it remains
unchanged.

Reviewed by:	bz, imp, manu
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36295
2023-08-17 13:31:38 -04:00
Warner Losh
26a58599a0 Remove $FreeBSD$: one-line forth tag
Remove /^\\[\s*]*\$FreeBSD\$.*$\n/
2023-08-16 11:55:43 -06:00
Warner Losh
05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Ed Maste
34d55be074 boot0: add a note about BIOS-supported serial rates
We plan to increase the default serial rate to 115200 (see review
D36295) but early boot components that use BIOS interfaces do not
support higher rates.  Add a note to that effect.

Reported by:	imp
Sponsored by:	The FreeBSD Foundation
2023-08-15 18:45:58 -04:00
Warner Losh
2f131435bc stand: efi create eficom console device.
Fix the 'renaming kludge' that we absolutely cannot do going forward
(it's cost us days of engineering time).

console=comconsole talks to the hardware directly. This is available
only on amd64. It is not available anywhere else (and so requires
changes for people doing comconsole on aarch64)

console=eficom talks to the console via EFI protocols.  It's available
on amd64, aarch64 and riscv64. It's the first port that we find, though
it can be overriden by efi_com_port (which should be set to the UID of
the serial port, not the I/O port, despite the name). devinfo -v
will give the UID to uartX mapping.

This is an incompatible change for HYPER-V on amd64. It only works with
eficom console, so you'll need to change your configuration in
loader.conf. No compatibility hack will ever be provided for this (since
it requires renamig, which the loader cannot reliably do).

It's also an incompatible change for aarch64. comconsole will need to
change to eficom. There might be a comconsole "shim" for this.

All the interlock to keep only eficom and comconsole from both attaching
have been removed.

RelNotes:		Yes
Sponsored by:		Netflix
Discussed with:		kevans
Differential Revision:	https://reviews.freebsd.org/D39982
2023-05-11 14:06:03 -06:00
Ed Maste
e32fecd0c2 loader: install help files only once
Every file should be installed exactly once by `make installworld`.
This is especially important for pkgbase.

Loader help files were being installed by each loader variant (e.g.,
the simp, lua, and 4th EFI loaders).  Add a (slightly hacky) mechanism
to skip installing help files for all but one variant.

PR:		271178
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40021
2023-05-09 20:18:19 -04:00
Toomas Soome
795497bf3d pxeboot: bugs in pxe.h
SEGDESC_t needs to be PACKED
there is no status in t_PXENV_UNDI_MCAST_ADDRESS

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D39799
2023-04-26 16:33:28 +03:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
John Baldwin
c7f3674fb0 boot0: Drop the BOOT_BOOT0_ORG option.
This shouldn't be an option (and I added it in the first place back in
4ae4202e70 and
83f4b92050).  However, unlike the other
knobs I added back then, this really shouldn't be a knob since it is
hardcoded in the source.
2023-04-18 11:19:12 -07:00
John Baldwin
bd5dc94b99 boot0: Expand the description of BOOT_BOOT0_ORG.
This really shouldn't even be an option given it is hardcoded as a
constant named ORIGIN in the assembly.  mbr.S also uses 0x600 and
hardcodes it in both the assembly and the Makefile.
2023-04-18 11:02:50 -07:00
Gordon Bergling
c3fbd9c621 Revert "stand: Remove double words in source code comments"
The sentence, "The base address that we the boot0 code to to run it."
is correct.

Reported by:	jrtc27

This reverts commit b12ccd0bb1.
2023-04-18 08:08:35 +02:00
Gordon Bergling
b12ccd0bb1 stand: Remove double words in source code comments
- s/to to/to/
- s/value value/value/

MFC after:	5 days
2023-04-18 07:14:44 +02:00
Kyle Evans
ec671f4980 loader: comconsole: don't unconditionally wipe out hw.uart.console
It may be the case that we need to set hw.uart.console manually in some
scenarios that comconsole can't necessarily support.  Avoid clobbering
hw.uart.console unless we've actually selected comconsole so that one
could at least get kernel console output..

Discussed with:	imp
Sponsored by:	Zenith Electronics LLC
Sponsored by:	Klara, Inc.
2023-04-13 23:42:03 -05:00
Wei Hu
927358dd98 amd64 loader: Use efiserialio for Hyper-V booted systems
UEFI provides ConIn/ConOut handles for consoles that it supports,
which include the text-video and serial ports. When the serial port
is available, use the UEFI driver instead of direct io-port accesses
to avoid conflicts between the firmware and direct hardware access, as
happens on Hyper-V (Azure) setups.

This change enables efiserialio to be built for efi-amd64 and has
higher order priority vs comconsole, and only uses efiserialio
if the hypervisor is Hyper-V. When efiserialio successfully
probes, it will set efi_comconsole_avail=true which will prevent
comconsole from probing in this setup.

Tested on Hyper-V, ESXi and Azure VMs.

PR:		264267
Reviewed by:	kevans, whu
Tested by:	whu
Obtained from:	Rubicon Communications, LLC (Netgate)
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (Netgate)
2023-03-18 07:07:35 +00:00
Mitchell Horne
8859960436 loader: always install help files
Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR:		267134
Reported by:	Daniel O'Connor <darius@dons.net.au>
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28591
2023-02-03 16:35:06 -04:00
Warner Losh
ad70f2e22e stand: create common set_currdev
Pull together the nearly identical copies of set_currdev in i386,
userboot and efi. Other boot loaders have variances that might be fine
to use the common routine, or not. Since they are harder to test for me,
and ofw and uboot do handle these setting differently, leave them be for
now.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38005
2023-01-11 15:15:15 -07:00
Warner Losh
1c1783d66b stand: Create common gen_setcurrdev and replace code
Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid
having to create a 5th copy. uboot_setcurrdev is actually different and
needs to remain separate (even though it's quite similar).

Sponsored by:		Netflix
Reviewed by:		fuz@fuz.su, kevans
Differential Revision:	https://reviews.freebsd.org/D38003
2023-01-11 15:15:14 -07:00
Warner Losh
71bbe6fb70 stand/zfs: Add a third argument to zfs_probe_dev: part_too
Pass in 'true' if you'd like to search this device's partitions or
'false' if you should just search the device. EFI and (in the future)
kboot have discrete partitions that aren't accessed via the full disk
device. Weird things happen if you try to search in these cases.

Sponsored by:		Netflix
2023-01-08 09:45:11 -07:00
Warner Losh
33bbe5ddcb stand: parsedev API change: devspec now points to start of full device name
To support more flexible device matching, we now pass in the full
devspec to the parsedev routines. For everything execpt uboot, this is
just a drop in (since everything except uboot and openfirmware always
uses disk...: and/or zfs:, but openfirmware isn't really affected).

uboot we kludge around it by subtracting 4 from where the rest of the
device name starts. This is unforunate, and can compute the address one
before the string. But we never dereference that address. uboot needs
more work, and this is an acceptable UB until that other work happens.

OFW doesn't really use the parsedev routines these days (since none of
the supported device uses this... yet). It too needs more work, but it
needs device matching support first.

Sponsored by:		Netflix
Reviewed by:		delphij
Differential Revision:	https://reviews.freebsd.org/D37553
2022-11-30 15:30:33 -07:00
Warner Losh
66012c8fc4 stand: create devinit
devinit() marches through all the devices, calling the inint routines if
any exist. Replace all the identical copies of this code.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D37349
2022-11-30 15:30:33 -07:00
Warner Losh
bb9f61da17 zfs: Remove devicename_stubs
We no longer need the zfs stubs since we're no longer referencing these
functions outside of zfs.c.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D37345
2022-11-30 15:30:32 -07:00
Warner Losh
641a0617e8 stand/i386: Move to using common devparse()
We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D37341
2022-11-30 15:30:32 -07:00