summaryrefslogtreecommitdiffstats
path: root/sys/boot/uboot/lib/devicename.c
diff options
context:
space:
mode:
authorraj <raj@FreeBSD.org>2009-05-05 16:29:08 +0000
committerraj <raj@FreeBSD.org>2009-05-05 16:29:08 +0000
commit25b538c6a6349c10d9df14fd79f4a238f0e6067d (patch)
treead95f0fba7df9d61056ba4253bb4c25009ade29f /sys/boot/uboot/lib/devicename.c
parentd41e64fb3b4dc3c516438f8b15afea2c95bf4be2 (diff)
downloadFreeBSD-src-25b538c6a6349c10d9df14fd79f4a238f0e6067d.zip
FreeBSD-src-25b538c6a6349c10d9df14fd79f4a238f0e6067d.tar.gz
GPT style partitioning for loader(8) with U-Boot support library (tested on
ARM). Submitted by: Piotr Ziecik kosmo ! semihalf dot com
Diffstat (limited to 'sys/boot/uboot/lib/devicename.c')
-rw-r--r--sys/boot/uboot/lib/devicename.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/sys/boot/uboot/lib/devicename.c b/sys/boot/uboot/lib/devicename.c
index 5d91550..27ea5cc 100644
--- a/sys/boot/uboot/lib/devicename.c
+++ b/sys/boot/uboot/lib/devicename.c
@@ -90,7 +90,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
struct devsw *dv;
char *cp;
const char *np;
- int i, unit, partition, err;
+ int i, unit, pnum, ptype, err;
/* minimum length check */
if (strlen(devspec) < 2)
@@ -116,7 +116,8 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
case DEVT_DISK:
unit = -1;
- partition = -1;
+ pnum = -1;
+ ptype = -1;
if (*np && (*np != ':')) {
/* next comes the unit number */
unit = strtol(np, &cp, 10);
@@ -126,13 +127,20 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
}
if (*cp && (*cp != ':')) {
/* get partition */
- partition = *cp - 'a';
- if ((partition < 0) ||
- (partition >= MAXPARTITIONS)) {
- err = EPART;
- goto fail;
+ if (*cp == 'p' && *(cp + 1) &&
+ *(cp + 1) != ':') {
+ pnum = strtol(cp + 1, &cp, 10);
+ ptype = PTYPE_GPT;
+ } else {
+ pnum = *cp - 'a';
+ ptype = PTYPE_BSDLABEL;
+ if ((pnum < 0) ||
+ (pnum >= MAXPARTITIONS)) {
+ err = EPART;
+ goto fail;
+ }
+ cp++;
}
- cp++;
}
}
if (*cp && (*cp != ':')) {
@@ -141,7 +149,8 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
}
idev->d_unit = unit;
- idev->d_disk.partition = partition;
+ idev->d_disk.pnum = pnum;
+ idev->d_disk.ptype = ptype;
idev->d_disk.data = NULL;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
@@ -202,9 +211,15 @@ uboot_fmtdev(void *vdev)
case DEVT_DISK:
cp = buf;
cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
- if (dev->d_kind.disk.partition >= 0)
- cp += sprintf(cp, "%c", dev->d_kind.disk.partition +
- 'a');
+ if (dev->d_kind.disk.pnum >= 0) {
+ if (dev->d_kind.disk.ptype == PTYPE_BSDLABEL)
+ cp += sprintf(cp, "%c",
+ dev->d_kind.disk.pnum + 'a');
+ else if (dev->d_kind.disk.ptype == PTYPE_GPT)
+ cp += sprintf(cp, "p%i",
+ dev->d_kind.disk.pnum);
+ }
+
strcat(cp, ":");
break;
OpenPOWER on IntegriCloud