It typically had two args with an optional third from the userland
declaration in sys/ioccom.h. However, the funciton definition used a
non-optional char * argument. This mismatch is UB behavior (but worked
due to the calling convetions of all our machines).
Instead, add a declaration for ioctl to stand.h, make the third arg
'void *' which is a better match to the ... declaration before. This
prevents the convert int * -> char * errors as well. Make the ioctl
user-space declaration truly user-space specific (omit it in the
stand-alone build).
No functional change intended.
Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37680
`int foo();` means 'a function that takes any number of arguments.`
not `a function that takes no arguemnts`, that's spelled `int foo(void);`
Adopt the latter.
Sponsored by: Netflix
Linux has /sys/firmware/fdt and /proc/device-tree to publish the dtb for
the system. The former has it all in one file, while the latter breaks
it out. Prefer the former since it's the more modern interface, but
retain both since I don't have a PS3 to test to see if its kernel is new
enough for /sys/firmware or not.
In addition, do the proper fixup.
Sponsored by: Netflix
Do the standard command line parsing... With a small twist to deal with
the quirks of booting via linuxboot to the initrd from the command line
in shell.efi and other observed oddities.
Sponsored by: Netflix
main() of the boot loader is expected to call devinit() early. We do
this at the same time we do it in the EFI loader (except we don't have a
buffer cache here, we don't need to initialize time and we don't have
special efi partition handles to enumerate). This is just after we probe
for the console.
Sponsored by: Netflix
Copy EFI's bootinfo.c and make minor adjustments for kboot's needs. Do
not connect this to the build just yet until other pieces are in place.
Sponsored by: Netflix
bootinfo.c is about to be shared with kboot since they create
substantially similar environments / metadata tagging / etc. Tag this
with #ifdef EFI for the moment until the proper abstracting out can
happen.
Sponsored by: Netflix
The zlib project has issue https://github.com/madler/zlib/issues/633 to
document its continued use of old K&R-style function definitions.
Suggested by: delphij@
Sponsored by: Netflix
These are declared as extern in a number of files (some with the wrong
return type). Centralize this in modinfo.h and remove a few extra stray
declarations as well that are no longer used. No functional change.
Note: I've not tried to cope with the bi_load() functions which are the
same logical thing. These will be handled separately.
Sponsored by: Netflix
GCC 12 warns about a dangling pointer to 'objid' in
zfs_bootenv_initial(). However, this appears to be a false positive
as the pointer to 'objid' is only passed to zfs_lookup_dataset() but
not saved anywhere that outlives the lifetime of the
zfs_bootenv_initial() function.
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37533
Some typedefs are system dependent, so move them into stat_arch.h where
they are used. On amd64, nlinks is a int64_t, while on aarch64 it's an
int (or int32_t).
Sponsored by: Netflix
Have a better include order so this can more easily be shared between
EFI and kboot. Fewer ifdefs and the same (enough) include order as
before.
Sponsored by: Netflix
We call bi_copymodules twice: once with 0 and once with the size of the
arena. We do this to find the size, it turns out. Document this.
Sponsored by: Netflix
For the 64-bit platforms, this is a nop. Currently kboot only supports
64-bit platforms, though. If we support 32-bit in the future, this will
become important.
Noticed by: rpokala
Sponsored by: Netflix
Added missing functionality to allow us to boot off of things like
/dev/nvme0n1p2 successfully. And to list all available devices and
partitions with 'lsdev'.
Sponsored by: Netflix
Use the system's firmware memory map to find a good place to put the
kernel that won't stomp on anything else. While this uses obstensibly MI
interfaces to get this data, arm64 doesn't have this, nor does
powerpc64, so place it here.
Sponsored by: Netflix
We can use devparse directly now. No need to invent a kboot_parsedev
that just does what devparse does now that we've refactored.
Sponsored by: Netflix
Most of the files in /sys/ and /proc/ are small with one value. Create
two routines to help us read the file and decode that value.
Sponsored by: Netflix
Both ofw_disk and ofw_net use the same parsedev routine, except for the
string passed in to match the ofw device node's type. Create a routine
to do that and connect these two users up to that.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37560
Add a parsedev support for OpenFirmware disks. We must look at
characteristics of the OFW node to know if we match this device (so
supply a match routine) or not. Add a parsing routine to allocate
devdesc for OpenFirmware disks as well.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37558
We need to match devices in a slightly special way: We have to look up
the path and see if the device is a 'network' device in order to use it.
Sponsored by: Netflix
Tested by: grehan@ (with tweaks to my original patch)
Differential Revision: https://reviews.freebsd.org/D37557
ofw_path_to_handle converts a path string to a phandle_t. It searches
down the path for the first device whose type matches the passed-in
string.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37556
On OpenFirmware, and possibly kboot, we use full path names for the
objects that are the 'device'. kboot uses a hack of knowing that all
disk device nodes start with '/dev', but this generalizes it for
OpenFirmware where both 'block' and 'network' devices live in the same
namespace and one must ask the OF node its type to know if this device
type matches.
For drivers that don't specify, the current convention of using
strncmp() is retained. This is done only in devparse(), but everything
uses it directly (or will soon).
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37554
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
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
The rest of the code in the tree assumes that a DEVT_DISK uses a
disk_devdesc to represent the device. However ofw_disk diesn't, so we
can't use disk_fmtdev, nor disk_parsedev. ofw needs to have a
dv_match-like routine to use devpasrse, though, since we have two
drivers (net and block) that claim the same sort of devices (eg
/path/to/ofw-dev) based on the device-type property. In the interim, we
can't use devmatch and ofw_disk's and the default net driver's parsing
is offloaded ofw_parsedev.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37347
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
We don't need to check if something is a ZFS device. Instead, if the
found device has a parse routine, call it. Otherwise, just copy the
path.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37343
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/D37342
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
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/D37340