Commit Graph

16 Commits

Author SHA1 Message Date
Warner Losh
5328f9034f stand/kboot: Simplify
There's plenty of stack in kboot, so use it here rather than the
malloc/free dance.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D39416
2023-05-01 15:02:53 -06:00
Warner Losh
7b4299eb4e kboot: Fix hostdisk_override
We were assuming that hostdisk_override was both a directory and a
file, which is not going to work very well. It's supposed to be a
single file, so recode it as such. Simplify erorr handling a little as
well and fix a return type-mismatch that doesn't matter for the
generated code (return NULL is the same as return false in this
context)

Sponsored by: Netflix
2023-03-02 11:12:10 -07:00
Warner Losh
d76330efd9 kboot: Probe all disks and partitions for a kernel
Guess where to boot from when bootdev= isn't on the command line or
other config. Search all the disks and partitions for one that looks
like it could be a boot partition (same as we do when probing
zpools). Return the first one we find.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D38319
2023-02-03 08:41:38 -07:00
Warner Losh
81d71f94ca kboot: Fix hostdisk fmtdev
The device name was totally wrong. It should be "/dev/mumble:" not just
"mumble".

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D38318
2023-02-02 13:04:06 -07:00
Warner Losh
b7ecfa195f kboot: Add hostdisk override
When hostdisk_override is set, all the /dev devices are hidden, and only
the files in that directory are used. This will allow filesystem testing
on FreeBSD without root, for example. Adjust the parse routine to not
require devices start with /dev (plus fix a leak for an error
condition). Add a match routine to allow the device name to be something
like "/home/user/testing/zfsfoo:" instead of strictly in /dev. Note:
since we need to look at all the devices in the system to probe for ZFS
zpools, you can't generally use a full path to get a 'virtual disk' at
this time.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38011
2023-01-13 14:22:39 -07:00
Warner Losh
cc82c650a7 kboot: Add ZFS support to hostdisk
Add helper function to walk through the disk drives we've found to look
for zpools. main.c will still need to call this because the loader
hasn't implemented a good way to 'taste' drives for zpools and/or GELI
partitions (mostly because there's no generic list of candidate
devices).

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38007
2023-01-13 14:22:38 -07:00
Warner Losh
1a13008e98 kboot: Rework hostdisk.c to allow easier ZFS support.
Keep a list of disks and partitions that we have. Keep track of the
sizes of the media and sector and use that to implement DIOCGMEDIASIZE
and DIOCGSECTORSIZE. Proivde a way to lookup disks by name.

Sponsored by:		Netflix
Reviewed by:		kevans (prior version)
Differential Revision:	https://reviews.freebsd.org/D38013
2023-01-13 14:22:38 -07:00
Warner Losh
0386255bee kboot: Disks should be at least 16MB
Linux pre-boot environments will often have a number of psuedo disks
that are small, all smaller than a few MB. 16MB is a good cutoff since
it's big enough to filter these devices, yet small enough to allow a
super-minimal partition through (the smallest I've been able to make
that's useful lately is around 20MB).

Sponsored by:		Netflix
2023-01-07 13:20:44 -07:00
Warner Losh
538b73578b kboot: hostdisk.c update copyright notice
I've rewritten a substantial portion of this file, so add Netflix
copyright.

Sponsored by:		Netflix
2023-01-07 13:16:19 -07:00
Warner Losh
7685e8d97a kboot: Enhance hostdisk
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
2022-12-02 11:31:26 -07:00
Warner Losh
2cb90a7b2e stand/kboot: hostdisk isn't a DEVT_DISK, use a different value.
We assume in all the code that a DEVT_DISK uses common/disk.c and/or
common/part.c and we can access a struct disk_devdesc. hostdisk.c
opens raw devices directly, so has no such structures. Define a
kboot-specific DEVT_HOSTDISK and use that instead.

In addition, disk_fmtdev assumes it is working with a struct
disk_devdesc, so write hostdisk_fmtdev as well.

Sponsored by:		Netflix
2022-10-22 19:47:24 -06:00
Warner Losh
6700f34d12 kboot: hostdisk add to lsdev output
Not entirely sure what to do here, so just list that we're here.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D36606
2022-10-07 23:46:20 -06:00
Warner Losh
ad759c7352 stand: Add disk_fmtdev for dv_fmtdev for all the disk devices
All of the archsw fmtdev functions treat DEVT_DISK as a call to
disk_fmtdev. Set all disks' dv_fmtdev to disk_fmtdev so devformat
will return the same thing.

Sponsored by:		Netflix
Reviewed by:		tsoome (prior version)
Differential Revision:	https://reviews.freebsd.org/D35917
2022-08-11 10:27:16 -06:00
Warner Losh
e98f952c82 stand: Make sure nobody has a NULL pointer for dv_cleanup
dv_cleanup is specified almost everywhere. Use nullsys instead of NULL
to indicate 'do nothing'. Also, be consistent in trailing commas that
were missing before.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D35913
2022-07-27 09:04:13 -06:00
Warner Losh
fc5d0d51aa stand: Use c99 structure initialization for kboot's hostdisk device
Use c99 structure init for devsw.

Sponsored by:		Netflix
2022-07-24 16:53:34 -06:00
Warner Losh
4366199644 kboot: Move powerpc kboot to top level
As the first step at making this more generic, move kboot to top level.

Sponsored by:		Netflix
Reviewed by:		luporl, tsoome
Differential Revision:	https://reviews.freebsd.org/D33513
2021-12-30 16:07:06 -07:00