Date: Mon, 18 Feb 2019 17:12:31 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344260 - head/stand/uboot/common Message-ID: <201902181712.x1IHCV50019306@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Mon Feb 18 17:12:30 2019 New Revision: 344260 URL: https://svnweb.freebsd.org/changeset/base/344260 Log: Allow the u-boot loaderdev env var to be formatted in the "usual" loader(8) way: device<unit>[s|p]<slice><partition>. E.g., disk0s2a or disk3p12. The code first tries to parse the variable in this format using the standard disk_parsedev(). If that fails, it falls back to parsing the legacy format that has been supported by ubldr for years. In addition to 'disk', all the valid uboot device names can also be used: mmc, sata, usb, ide, scsi. The 'disk' device serves as an alias for all those types and will match the Nth storage-type device found (where N is the unit number). Modified: head/stand/uboot/common/main.c Modified: head/stand/uboot/common/main.c ============================================================================== --- head/stand/uboot/common/main.c Mon Feb 18 16:11:11 2019 (r344259) +++ head/stand/uboot/common/main.c Mon Feb 18 17:12:30 2019 (r344260) @@ -182,6 +182,14 @@ device_typename(int type) * The returned values for slice and partition are interpreted by * disk_open(). * + * The device string can be a standard loader(8) disk specifier: + * + * disk<unit>s<slice> disk0s1 + * disk<unit>s<slice><partition> disk1s2a + * disk<unit>p<partition> disk0p4 + * + * or one of the following formats: + * * Valid device strings: For device types: * * <type_name> DEV_TYP_STOR, DEV_TYP_NET @@ -198,6 +206,7 @@ device_typename(int type) static void get_load_device(int *type, int *unit, int *slice, int *partition) { + struct disk_devdesc dev; char *devstr; const char *p; char *endp; @@ -215,6 +224,19 @@ get_load_device(int *type, int *unit, int *slice, int printf("U-Boot env: loaderdev='%s'\n", devstr); p = get_device_type(devstr, type); + + /* + * If type is DEV_TYP_STOR we have a disk-like device. If we can parse + * the remainder of the string as a standard unit+slice+partition (e.g., + * 0s2a or 1p12), return those results. Otherwise we'll fall through to + * the code that parses the legacy format. + */ + if ((*type & DEV_TYP_STOR) && disk_parsedev(&dev, p, NULL) == 0) { + *unit = dev.dd.d_unit; + *slice = dev.d_slice; + *partition = dev.d_partition; + return; + } /* Ignore optional spaces after the device name. */ while (*p == ' ')
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902181712.x1IHCV50019306>