summaryrefslogtreecommitdiffstats
path: root/sys/boot/uboot/lib/disk.c
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-04-29 00:45:42 +0000
committerian <ian@FreeBSD.org>2014-04-29 00:45:42 +0000
commit3e706bc125f903c2223e90e5225594efea13e10f (patch)
tree9c3c5f09276a4dd11c269470de7bcbd03d78dc70 /sys/boot/uboot/lib/disk.c
parent4d985863b1ca378d0225d5c7089e922c5d53e868 (diff)
downloadFreeBSD-src-3e706bc125f903c2223e90e5225594efea13e10f.zip
FreeBSD-src-3e706bc125f903c2223e90e5225594efea13e10f.tar.gz
MFC r263052, r263124, r263265, r263267... Enhance loaderdev env var.
Enhance the mechanism that lets you configure the ubldr boot device by setting the u-boot environment variable loaderdev=. It used to accept only 'disk' or 'net'. Now it allows specification of unit, slice, and partition as well. In addition to the generic 'disk' it also accepts specific storage device types such as 'mmc' or 'sata'. If there isn't a loaderdev env var, the historical behavior is maintained. It will use the first storage device it finds, or a network device if no working storage device exists. 99% of the work on this was done by Patrick Kelsey, but I made some changes, so if anything goes wrong, blame me. (Indeed, the 3 followup commits fixed things I got wrong on the first.)
Diffstat (limited to 'sys/boot/uboot/lib/disk.c')
-rw-r--r--sys/boot/uboot/lib/disk.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/boot/uboot/lib/disk.c b/sys/boot/uboot/lib/disk.c
index 62b3132..4681e1b 100644
--- a/sys/boot/uboot/lib/disk.c
+++ b/sys/boot/uboot/lib/disk.c
@@ -278,3 +278,26 @@ stor_ioctl(struct open_file *f, u_long cmd, void *data)
return (0);
}
+
+/*
+ * Return the device unit number for the given type and type-relative unit
+ * number.
+ */
+int
+uboot_diskgetunit(int type, int type_unit)
+{
+ int local_type_unit;
+ int i;
+
+ local_type_unit = 0;
+ for (i = 0; i < stor_info_no; i++) {
+ if ((stor_info[i].type & type) == type) {
+ if (local_type_unit == type_unit) {
+ return (i);
+ }
+ local_type_unit++;
+ }
+ }
+
+ return (-1);
+}
OpenPOWER on IntegriCloud