summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2023-08-26 11:25:08 -0400
committerTom Rini <[email protected]>2023-08-26 11:25:08 -0400
commit11cf91f755c7b1f1c8e7865743ac589bd23b7099 (patch)
treeac16ffe5e84057ffa0d1c7e93d47c00d5c3ed532
parent05763b71d2fcfe9729bf5ef0b14bd00c3af0c985 (diff)
parent453c3fb48141f60eb9b7ab5545d94c88dc5af40c (diff)
Merge branch '2023-08-26-bootstd-chromeos-impreovements-and-move-to-gcc-13.2' into next
First, update CI to using gcc-13.2 from 13.1, and rebuild the CI containers. This is needed because the second part adds utilities for tests and provides, to quote the author: This updates the ChromiumOS bootmeth to detect multiple kernel partitions on a disk. It also includes minor code improvements to the partition drivers, including accessors for the optional fields. This series also includes some other related tweaks in testing.
-rw-r--r--.azure-pipelines.yml4
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--arch/sandbox/cpu/os.c24
-rw-r--r--arch/sandbox/dts/test.dts9
-rw-r--r--boot/Kconfig3
-rw-r--r--boot/bootdev-uclass.c24
-rw-r--r--boot/bootmeth_cros.c48
-rw-r--r--cmd/bootflow.c2
-rw-r--r--cmd/gpt.c10
-rw-r--r--configs/snow_defconfig1
-rw-r--r--disk/part.c226
-rw-r--r--disk/part_amiga.c34
-rw-r--r--disk/part_dos.c80
-rw-r--r--disk/part_efi.c281
-rw-r--r--disk/part_iso.c52
-rw-r--r--disk/part_mac.c59
-rw-r--r--doc/develop/bootstd.rst11
-rw-r--r--drivers/core/device.c3
-rw-r--r--fs/fat/fat.c4
-rw-r--r--include/bootmeth.h3
-rw-r--r--include/os.h10
-rw-r--r--include/part.h212
-rw-r--r--include/part_efi.h14
-rw-r--r--include/uuid.h103
-rw-r--r--lib/uuid.c110
-rw-r--r--test/boot/bootflow.c80
-rw-r--r--test/dm/host.c44
-rw-r--r--test/py/tests/fs_helper.py6
-rw-r--r--test/py/tests/test_ut.py148
-rw-r--r--tools/buildman/toolchain.py2
-rw-r--r--tools/docker/Dockerfile63
31 files changed, 1024 insertions, 650 deletions
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 0be317b3886..9acc4f5dbba 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -2,7 +2,7 @@ variables:
windows_vm: windows-2019
ubuntu_vm: ubuntu-22.04
macos_vm: macOS-12
- ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230624-20Jul2023
+ ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230804-25Aug2023
# Add '-u 0' options for Azure pipelines, otherwise we get "permission
# denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
# since our $(ci_runner_image) user is not root.
@@ -195,7 +195,7 @@ stages:
ln -s /opt/nokia/libc6_2.5.1-1eglibc27+0m5_armel.deb nokia_rx51_tmp/
ln -s /opt/nokia/busybox_1.10.2.legal-1osso30+0m5_armel.deb nokia_rx51_tmp/
ln -s /opt/nokia/qemu-system-arm nokia_rx51_tmp/
- export PATH=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin:$PATH
+ export PATH=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin:$PATH
test/nokia_rx51_test.sh
- job: pylint
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5750d820233..8f488a0c85c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ default:
# Grab our configured image. The source for this is found
# in the u-boot tree at tools/docker/Dockerfile
-image: ${MIRROR_DOCKER}/trini/u-boot-gitlab-ci-runner:jammy-20230624-20Jul2023
+image: ${MIRROR_DOCKER}/trini/u-boot-gitlab-ci-runner:jammy-20230804-25Aug2023
# We run some tests in different order, to catch some failures quicker.
stages:
@@ -235,7 +235,7 @@ Run tests for Nokia RX-51 (aka N900):
ln -s /opt/nokia/libc6_2.5.1-1eglibc27+0m5_armel.deb nokia_rx51_tmp/;
ln -s /opt/nokia/busybox_1.10.2.legal-1osso30+0m5_armel.deb nokia_rx51_tmp/;
ln -s /opt/nokia/qemu-system-arm nokia_rx51_tmp/;
- export PATH=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin:$PATH;
+ export PATH=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin:$PATH;
test/nokia_rx51_test.sh
# Check for any pylint regressions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 9e93a0fa571..85d0d6a1703 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -258,6 +258,30 @@ int os_unmap(void *buf, int size)
return 0;
}
+int os_persistent_file(char *buf, int maxsize, const char *fname)
+{
+ const char *dirname = getenv("U_BOOT_PERSISTENT_DATA_DIR");
+ char *ptr;
+ int len;
+
+ len = strlen(fname) + (dirname ? strlen(dirname) + 1 : 0) + 1;
+ if (len > maxsize)
+ return -ENOSPC;
+
+ ptr = buf;
+ if (dirname) {
+ strcpy(ptr, dirname);
+ ptr += strlen(dirname);
+ *ptr++ = '/';
+ }
+ strcpy(ptr, fname);
+
+ if (access(buf, F_OK) == -1)
+ return -ENOENT;
+
+ return 0;
+}
+
/* Restore tty state when we exit */
static struct termios orig_term;
static bool term_setup;
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 084cb88a232..b48456aebee 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -39,6 +39,8 @@
mmc1 = "/mmc1";
mmc2 = "/mmc2";
mmc3 = "/mmc3";
+ mmc4 = "/mmc4";
+ mmc5 = "/mmc5";
pci0 = &pci0;
pci1 = &pci1;
pci2 = &pci2;
@@ -1055,6 +1057,13 @@
filename = "mmc4.img";
};
+ /* This is used for ChromiumOS tests */
+ mmc5 {
+ status = "disabled";
+ compatible = "sandbox,mmc";
+ filename = "mmc5.img";
+ };
+
pch {
compatible = "sandbox,pch";
};
diff --git a/boot/Kconfig b/boot/Kconfig
index 5e2d4286aea..86ccfd78031 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -466,6 +466,9 @@ config BOOTMETH_CROS
bool "Bootdev support for Chromium OS"
depends on X86 || ARM || SANDBOX
default y if !ARM
+ select EFI_PARTITION
+ select PARTITION_TYPE_GUID
+ select PARTITION_UUIDS
help
Enables support for booting Chromium OS using bootdevs. This uses the
kernel A slot and obtains the kernel command line from the parameters
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index fa52bc3a9c4..69506e3865f 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -111,6 +111,8 @@ int bootdev_bind(struct udevice *parent, const char *drv_name, const char *name,
int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
struct bootflow_iter *iter, struct bootflow *bflow)
{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(bflow->method);
+ bool allow_any_part = plat->flags & BOOTMETHF_ANY_PART;
struct blk_desc *desc = dev_get_uclass_plat(blk);
struct disk_partition info;
char partstr[20];
@@ -142,6 +144,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
* us whether there is valid media there
*/
ret = part_get_info(desc, iter->part, &info);
+ log_debug("part_get_info() returned %d\n", ret);
if (!iter->part && ret == -ENOENT)
ret = 0;
@@ -154,7 +157,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
ret = -ESHUTDOWN;
else
bflow->state = BOOTFLOWST_MEDIA;
- if (ret) {
+ if (ret && !allow_any_part) {
/* allow partition 1 to be missing */
if (iter->part == 1) {
iter->max_part = 3;
@@ -174,9 +177,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
if (!iter->part) {
iter->first_bootable = part_get_bootable(desc);
log_debug("checking bootable=%d\n", iter->first_bootable);
+ } else if (allow_any_part) {
+ /*
+ * allow any partition to be scanned, by skipping any checks
+ * for filesystems or partition contents on this disk
+ */
/* if there are bootable partitions, scan only those */
- } else if (iter->first_bootable ? !info.bootable : iter->part != 1) {
+ } else if (iter->first_bootable >= 0 &&
+ (iter->first_bootable ? !info.bootable : iter->part != 1)) {
return log_msg_ret("boot", -EINVAL);
} else {
ret = fs_set_blk_dev_with_part(desc, bflow->part);
@@ -184,16 +193,16 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
if (ret)
return log_msg_ret("fs", ret);
- /* Use an #ifdef due to info.sys_ind */
-#ifdef CONFIG_DOS_PARTITION
log_debug("%s: Found partition %x type %x fstype %d\n",
- blk->name, bflow->part, info.sys_ind,
+ blk->name, bflow->part,
+ IS_ENABLED(CONFIG_DOS_PARTITION) ?
+ disk_partition_sys_ind(&info) : 0,
ret ? -1 : fs_get_type());
-#endif
bflow->blk = blk;
bflow->state = BOOTFLOWST_FS;
}
+ log_debug("method %s\n", bflow->method->name);
ret = bootmeth_read_bootflow(bflow->method, bflow);
if (ret)
return log_msg_ret("method", ret);
@@ -560,7 +569,8 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
{
const struct bootdev_ops *ops = bootdev_get_ops(dev);
- log_debug("->get_bootflow %s=%p\n", dev->name, ops->get_bootflow);
+ log_debug("->get_bootflow %s,%x=%p\n", dev->name, iter->part,
+ ops->get_bootflow);
bootflow_init(bflow, dev, iter->method);
if (!ops->get_bootflow)
return default_get_bootflow(dev, iter, bflow);
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 1776fb1838c..20e0b1e89c3 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -16,16 +16,19 @@
#include <bootmeth.h>
#include <display_options.h>
#include <dm.h>
+#include <efi.h>
#include <malloc.h>
#include <mapmem.h>
#include <part.h>
#include <linux/sizes.h>
#include "bootmeth_cros.h"
+static const efi_guid_t cros_kern_type = PARTITION_CROS_KERNEL;
+
/*
* Layout of the ChromeOS kernel
*
- * Partitions 2 and 4 contain kernels
+ * Partitions 2 and 4 contain kernels with type GUID_CROS_KERNEL
*
* Contents are:
*
@@ -145,13 +148,25 @@ static int scan_part(struct udevice *blk, int partnum,
{
struct blk_desc *desc = dev_get_uclass_plat(blk);
struct vb2_keyblock *hdr;
+ struct uuid type;
ulong num_blks;
int ret;
+ if (!partnum)
+ return log_msg_ret("efi", -ENOENT);
+
ret = part_get_info(desc, partnum, info);
if (ret)
return log_msg_ret("part", ret);
+ /* Check for kernel partition type */
+ log_debug("part %x: type=%s\n", partnum, info->type_guid);
+ if (uuid_str_to_bin(info->type_guid, (u8 *)&type, UUID_STR_FORMAT_GUID))
+ return log_msg_ret("typ", -EINVAL);
+
+ if (memcmp(&cros_kern_type, &type, sizeof(type)))
+ return log_msg_ret("typ", -ENOEXEC);
+
/* Make a buffer for the header information */
num_blks = PROBE_SIZE >> desc->log2blksz;
log_debug("Reading header, blk=%s, start=%lx, blocks=%lx\n",
@@ -167,6 +182,7 @@ static int scan_part(struct udevice *blk, int partnum,
if (memcmp(VB2_KEYBLOCK_MAGIC, hdr->magic, VB2_KEYBLOCK_MAGIC_SIZE)) {
free(hdr);
+ log_debug("no magic\n");
return -ENOENT;
}
@@ -340,24 +356,16 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
struct vb2_keyblock *hdr;
const char *uuid = NULL;
struct cros_priv *priv;
- int part, ret;
-
- log_debug("starting, part=%d\n", bflow->part);
+ int ret;
- /* We consider the whole disk, not any one partition */
- if (bflow->part)
- return log_msg_ret("max", -ENOENT);
+ log_debug("starting, part=%x\n", bflow->part);
- /* Check partition 2 then 4 */
- part = 2;
- ret = scan_part(bflow->blk, part, &info, &hdr);
+ /* Check for kernel partitions */
+ ret = scan_part(bflow->blk, bflow->part, &info, &hdr);
if (ret) {
- part = 4;
- ret = scan_part(bflow->blk, part, &info, &hdr);
- if (ret)
- return log_msg_ret("scan", ret);
+ log_debug("- scan failed: err=%d\n", ret);
+ return log_msg_ret("scan", ret);
}
- bflow->part = part;
priv = malloc(sizeof(struct cros_priv));
if (!priv) {
@@ -366,8 +374,8 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
bflow->bootmeth_priv = priv;
- log_info("Selected partition %d, header at %lx\n", bflow->part,
- (ulong)map_to_sysmem(hdr));
+ log_debug("Selected partition %d, header at %lx\n", bflow->part,
+ (ulong)map_to_sysmem(hdr));
/* Grab a few things from the preamble */
preamble = (void *)hdr + hdr->keyblock_size;
@@ -381,8 +389,11 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
ret = cros_read_info(bflow, uuid, preamble);
preamble = NULL;
free(hdr);
- if (ret)
+ if (ret) {
+ free(priv->info_buf);
+ free(priv);
return log_msg_ret("inf", ret);
+ }
bflow->size = priv->body_size;
bflow->state = BOOTFLOWST_READY;
@@ -437,6 +448,7 @@ static int cros_bootmeth_bind(struct udevice *dev)
struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
plat->desc = "ChromiumOS boot";
+ plat->flags = BOOTMETHF_ANY_PART;
return 0;
}
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 3c3abaf8a3b..300ad3aaa76 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -71,7 +71,7 @@ static void show_bootflow(int index, struct bootflow *bflow, bool errors)
printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
bflow->method->name, bootflow_state_get_name(bflow->state),
bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
- "(none)", bflow->part, bflow->name, bflow->fname);
+ "(none)", bflow->part, bflow->name, bflow->fname ?: "");
if (errors)
report_bootflow_err(bflow, bflow->err);
}
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 007a68eaa72..8969efba8c8 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -211,12 +211,10 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info,
PART_TYPE_LEN);
newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0';
newpart->gpt_part_info.bootable = info->bootable;
-#ifdef CONFIG_PARTITION_UUIDS
- strncpy(newpart->gpt_part_info.uuid, (const char *)info->uuid,
- UUID_STR_LEN);
- /* UUID_STR_LEN is correct, as uuid[]'s length is UUID_STR_LEN+1 chars */
- newpart->gpt_part_info.uuid[UUID_STR_LEN] = '\0';
-#endif
+ if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) {
+ strlcpy(newpart->gpt_part_info.uuid, disk_partition_uuid(info),
+ UUID_STR_LEN + 1);
+ }
newpart->partnum = partnum;
return newpart;
diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index bb066a64599..22ec8e5141f 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -29,6 +29,7 @@ CONFIG_DEBUG_UART=y
CONFIG_FIT=y
CONFIG_FIT_BEST_MATCH=y
CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTMETH_CROS=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_SILENT_CONSOLE=y
CONFIG_BLOBLIST=y
diff --git a/disk/part.c b/disk/part.c
index eec02f58988..72241b7b232 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -26,6 +26,12 @@
/* Check all partition types */
#define PART_TYPE_ALL -1
+/**
+ * part_driver_get_type() - Get a driver given its type
+ *
+ * @part_type: Partition type to find the driver for
+ * Return: Driver for that type, or NULL if none
+ */
static struct part_driver *part_driver_get_type(int part_type)
{
struct part_driver *drv =
@@ -42,25 +48,41 @@ static struct part_driver *part_driver_get_type(int part_type)
return NULL;
}
-static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
+/**
+ * part_driver_lookup_type() - Look up the partition driver for a blk device
+ *
+ * If @desc->part_type is PART_TYPE_UNKNOWN, this checks each parition driver
+ * against the blk device to see if there is a valid partition table acceptable
+ * to that driver.
+ *
+ * If @desc->part_type is already set, it just returns the driver for that
+ * type, without testing if the driver can find a valid partition on the
+ * descriptor.
+ *
+ * On success it updates @desc->part_type if set to PART_TYPE_UNKNOWN on entry
+ *
+ * @dev_desc: Device descriptor
+ * Return: Driver found, or NULL if none
+ */
+static struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
{
struct part_driver *drv =
ll_entry_start(struct part_driver, part_driver);
const int n_ents = ll_entry_count(struct part_driver, part_driver);
struct part_driver *entry;
- if (dev_desc->part_type == PART_TYPE_UNKNOWN) {
+ if (desc->part_type == PART_TYPE_UNKNOWN) {
for (entry = drv; entry != drv + n_ents; entry++) {
int ret;
- ret = entry->test(dev_desc);
+ ret = entry->test(desc);
if (!ret) {
- dev_desc->part_type = entry->part_type;
+ desc->part_type = entry->part_type;
return entry;
}
}
} else {
- return part_driver_get_type(dev_desc->part_type);
+ return part_driver_get_type(desc->part_type);
}
/* Not found */
@@ -83,27 +105,37 @@ int part_get_type_by_name(const char *name)
return PART_TYPE_UNKNOWN;
}
+/**
+ * get_dev_hwpart() - Get the descriptor for a device with hardware partitions
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev: Device number (0 for first device on that interface, 1 for
+ * second, etc.
+ * @hwpart: Hardware partition, or 0 if none (used for MMC)
+ * Return: pointer to the block device, or NULL if not available, or an
+ * error occurred.
+ */
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
{
- struct blk_desc *dev_desc;
+ struct blk_desc *desc;
int ret;
if (!blk_enabled())
return NULL;
- dev_desc = blk_get_devnum_by_uclass_idname(ifname, dev);
- if (!dev_desc) {
+ desc = blk_get_devnum_by_uclass_idname(ifname, dev);
+ if (!desc) {
debug("%s: No device for iface '%s', dev %d\n", __func__,
ifname, dev);
return NULL;
}
- ret = blk_dselect_hwpart(dev_desc, hwpart);
+ ret = blk_dselect_hwpart(desc, hwpart);
if (ret) {
debug("%s: Failed to select h/w partition: err-%d\n", __func__,
ret);
return NULL;
}
- return dev_desc;
+ return desc;
}
struct blk_desc *blk_get_dev(const char *ifname, int dev)
@@ -140,29 +172,24 @@ static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by,
return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
}
-void dev_print(struct blk_desc *dev_desc)
+void dev_print(struct blk_desc *desc)
{
lba512_t lba512; /* number of blocks if 512bytes block size */
- if (dev_desc->type == DEV_TYPE_UNKNOWN) {
+ if (desc->type == DEV_TYPE_UNKNOWN) {
puts ("not available\n");
return;
}
- switch (dev_desc->uclass_id) {
+ switch (desc->uclass_id) {
case UCLASS_SCSI:
- printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
- dev_desc->target,dev_desc->lun,
- dev_desc->vendor,
- dev_desc->product,
- dev_desc->revision);
+ printf("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n", desc->target,
+ desc->lun, desc->vendor, desc->product, desc->revision);
break;
case UCLASS_IDE:
case UCLASS_AHCI:
- printf ("Model: %s Firm: %s Ser#: %s\n",
- dev_desc->vendor,
- dev_desc->revision,
- dev_desc->product);
+ printf("Model: %s Firm: %s Ser#: %s\n", desc->vendor,
+ desc->revision, desc->product);
break;
case UCLASS_MMC:
case UCLASS_USB:
@@ -171,27 +198,27 @@ void dev_print(struct blk_desc *dev_desc)
case UCLASS_HOST:
case UCLASS_BLKMAP:
printf ("Vendor: %s Rev: %s Prod: %s\n",
- dev_desc->vendor,
- dev_desc->revision,
- dev_desc->product);
+ desc->vendor,
+ desc->revision,
+ desc->product);
break;
case UCLASS_VIRTIO:
- printf("%s VirtIO Block Device\n", dev_desc->vendor);
+ printf("%s VirtIO Block Device\n", desc->vendor);
break;
case UCLASS_EFI_MEDIA:
- printf("EFI media Block Device %d\n", dev_desc->devnum);
+ printf("EFI media Block Device %d\n", desc->devnum);
break;
case UCLASS_INVALID:
puts("device type unknown\n");
return;
default:
- printf("Unhandled device type: %i\n", dev_desc->uclass_id);
+ printf("Unhandled device type: %i\n", desc->uclass_id);
return;
}
puts (" Type: ");
- if (dev_desc->removable)
+ if (desc->removable)
puts ("Removable ");
- switch (dev_desc->type & 0x1F) {
+ switch (desc->type & 0x1F) {
case DEV_TYPE_HARDDISK:
puts ("Hard Disk");
break;
@@ -205,17 +232,17 @@ void dev_print(struct blk_desc *dev_desc)
puts ("Tape");
break;
default:
- printf ("# %02X #", dev_desc->type & 0x1F);
+ printf("# %02X #", desc->type & 0x1F);
break;
}
puts ("\n");
- if (dev_desc->lba > 0L && dev_desc->blksz > 0L) {
+ if (desc->lba > 0L && desc->blksz > 0L) {
ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
lbaint_t lba;
- lba = dev_desc->lba;
+ lba = desc->lba;
- lba512 = (lba * (dev_desc->blksz/512));
+ lba512 = lba * (desc->blksz / 512);
/* round to 1 digit */
/* 2048 = (1024 * 1024) / 512 MB */
mb = lba512_muldiv(lba512, 10, 11);
@@ -227,7 +254,7 @@ void dev_print(struct blk_desc *dev_desc)
gb_quot = gb / 10;
gb_rem = gb - (10 * gb_quot);
#ifdef CONFIG_LBA48
- if (dev_desc->lba48)
+ if (desc->lba48)
printf (" Supports 48-bit addressing\n");
#endif
#if defined(CONFIG_SYS_64BIT_LBA)
@@ -235,42 +262,42 @@ void dev_print(struct blk_desc *dev_desc)
mb_quot, mb_rem,
gb_quot, gb_rem,
lba,
- dev_desc->blksz);
+ desc->blksz);
#else
printf (" Capacity: %lu.%lu MB = %lu.%lu GB (%lu x %lu)\n",
mb_quot, mb_rem,
gb_quot, gb_rem,
(ulong)lba,
- dev_desc->blksz);
+ desc->blksz);
#endif
} else {
puts (" Capacity: not available\n");
}
}
-void part_init(struct blk_desc *dev_desc)
+void part_init(struct blk_desc *desc)
{
struct part_driver *drv =
ll_entry_start(struct part_driver, part_driver);
const int n_ents = ll_entry_count(struct part_driver, part_driver);
struct part_driver *entry;
- blkcache_invalidate(dev_desc->uclass_id, dev_desc->devnum);
+ blkcache_invalidate(desc->uclass_id, desc->devnum);
- dev_desc->part_type = PART_TYPE_UNKNOWN;
+ desc->part_type = PART_TYPE_UNKNOWN;
for (entry = drv; entry != drv + n_ents; entry++) {
int ret;
- ret = entry->test(dev_desc);
+ ret = entry->test(desc);
debug("%s: try '%s': ret=%d\n", __func__, entry->name, ret);
if (!ret) {
- dev_desc->part_type = entry->part_type;
+ desc->part_type = entry->part_type;
break;
}
}
}
-static void print_part_header(const char *type, struct blk_desc *dev_desc)
+static void print_part_header(const char *type, struct blk_desc *desc)
{
#if CONFIG_IS_ENABLED(MAC_PARTITION) || \
CONFIG_IS_ENABLED(DOS_PARTITION) || \
@@ -278,7 +305,7 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
CONFIG_IS_ENABLED(EFI_PARTITION)
puts ("\nPartition Map for ");
- switch (dev_desc->uclass_id) {
+ switch (desc->uclass_id) {
case UCLASS_IDE:
puts ("IDE");
break;
@@ -314,50 +341,46 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
break;
}
printf (" device %d -- Partition Type: %s\n\n",
- dev_desc->devnum, type);
+ desc->devnum, type);
#endif /* any CONFIG_..._PARTITION */
}
-void part_print(struct blk_desc *dev_desc)
+void part_print(struct blk_desc *desc)
{
struct part_driver *drv;
- drv = part_driver_lookup_type(dev_desc);
+ drv = part_driver_lookup_type(desc);
if (!drv) {
printf("## Unknown partition table type %x\n",
- dev_desc->part_type);
+ desc->part_type);
return;
}
PRINTF("## Testing for valid %s partition ##\n", drv->name);
- print_part_header(drv->name, dev_desc);
+ print_part_header(drv->name, desc);
if (drv->print)
- drv->print(dev_desc);
+ drv->print(desc);
}
-int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type,
+int part_get_info_by_type(struct blk_desc *desc, int part, int part_type,
struct disk_partition *info)
{
struct part_driver *drv;
if (blk_enabled()) {
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
/* The common case is no UUID support */
- info->uuid[0] = 0;
-#endif
-#ifdef CONFIG_PARTITION_TYPE_GUID
- info->type_guid[0] = 0;
-#endif
+ disk_partition_clr_uuid(info);
+ disk_partition_clr_type_guid(info);
if (part_type == PART_TYPE_UNKNOWN) {
- drv = part_driver_lookup_type(dev_desc);
+ drv = part_driver_lookup_type(desc);
} else {
drv = part_driver_get_type(part_type);
}
if (!drv) {
debug("## Unknown partition table type %x\n",
- dev_desc->part_type);
+ desc->part_type);
return -EPROTONOSUPPORT;
}
if (!drv->get_info) {
@@ -365,7 +388,7 @@ int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type,
drv->name);
return -ENOSYS;
}
- if (drv->get_info(dev_desc, part, info) == 0) {
+ if (drv->get_info(desc, part, info) == 0) {
PRINTF("## Valid %s partition found ##\n", drv->name);
return 0;
}
@@ -374,33 +397,29 @@ int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type,
return -ENOENT;
}
-int part_get_info(struct blk_desc *dev_desc, int part,
+int part_get_info(struct blk_desc *desc, int part,
struct disk_partition *info)
{
- return part_get_info_by_type(dev_desc, part, PART_TYPE_UNKNOWN, info);
+ return part_get_info_by_type(desc, part, PART_TYPE_UNKNOWN, info);
}
-int part_get_info_whole_disk(struct blk_desc *dev_desc,
+int part_get_info_whole_disk(struct blk_desc *desc,
struct disk_partition *info)
{
info->start = 0;
- info->size = dev_desc->lba;
- info->blksz = dev_desc->blksz;
+ info->size = desc->lba;
+ info->blksz = desc->blksz;
info->bootable = 0;
strcpy((char *)info->type, BOOT_PART_TYPE);
strcpy((char *)info->name, "Whole Disk");
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- info->uuid[0] = 0;
-#endif
-#ifdef CONFIG_PARTITION_TYPE_GUID
- info->type_guid[0] = 0;
-#endif
+ disk_partition_clr_uuid(info);
+ disk_partition_clr_type_guid(info);
return 0;
}
int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
- struct blk_desc **dev_desc)
+ struct blk_desc **desc)
{
char *ep;
char *dup_str = NULL;
@@ -436,8 +455,8 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
}
}
- *dev_desc = get_dev_hwpart(ifname, dev, hwpart);
- if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) {
+ *desc = get_dev_hwpart(ifname, dev, hwpart);
+ if (!(*desc) || ((*desc)->type == DEV_TYPE_UNKNOWN)) {
debug("** Bad device %s %s **\n", ifname, dev_hwpart_str);
dev = -ENODEV;
goto cleanup;
@@ -449,8 +468,8 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
* Always should be done, otherwise hw partition 0 will return
* stale data after displaying a non-zero hw partition.
*/
- if ((*dev_desc)->uclass_id == UCLASS_MMC)
- part_init(*dev_desc);
+ if ((*desc)->uclass_id == UCLASS_MMC)
+ part_init(*desc);
}
cleanup:
@@ -461,7 +480,7 @@ cleanup:
#define PART_UNSPECIFIED -2
#define PART_AUTO -1
int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *info, int allow_whole_dev)
{
int ret;
@@ -474,7 +493,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
int part;
struct disk_partition tmpinfo;
- *dev_desc = NULL;
+ *desc = NULL;
memset(info, 0, sizeof(*info));
#if IS_ENABLED(CONFIG_SANDBOX) || IS_ENABLED(CONFIG_SEMIHOSTING)
@@ -533,7 +552,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
}
/* Look up the device */
- dev = blk_get_device_by_str(ifname, dev_str, dev_desc);
+ dev = blk_get_device_by_str(ifname, dev_str, desc);
if (dev < 0) {
printf("** Bad device specification %s %s **\n",
ifname, dev_str);
@@ -565,9 +584,8 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
* No partition table on device,
* or user requested partition 0 (entire device).
*/
- if (((*dev_desc)->part_type == PART_TYPE_UNKNOWN) ||
- (part == 0)) {
- if (!(*dev_desc)->lba) {
+ if (((*desc)->part_type == PART_TYPE_UNKNOWN) || !part) {
+ if (!(*desc)->lba) {
printf("** Bad device size - %s %s **\n", ifname,
dev_str);
ret = -EINVAL;
@@ -586,9 +604,9 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
goto cleanup;
}
- (*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);
+ (*desc)->log2blksz = LOG2((*desc)->blksz);
- part_get_info_whole_disk(*dev_desc, info);
+ part_get_info_whole_disk(*desc, info);
ret = 0;
goto cleanup;
@@ -606,7 +624,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
* other than "auto", use that partition number directly.
*/
if (part != PART_AUTO) {
- ret = part_get_info(*dev_desc, part, info);
+ ret = part_get_info(*desc, part, info);
if (ret) {
printf("** Invalid partition %d **\n", part);
goto cleanup;
@@ -618,7 +636,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
*/
part = 0;
for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
- ret = part_get_info(*dev_desc, p, info);
+ ret = part_get_info(*desc, p, info);
if (ret)
continue;
@@ -662,7 +680,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
goto cleanup;
}
- (*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);
+ (*desc)->log2blksz = LOG2((*desc)->blksz);
ret = part;
goto cleanup;
@@ -672,14 +690,14 @@ cleanup:
return ret;
}
-int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
+int part_get_info_by_name(struct blk_desc *desc, const char *name,
struct disk_partition *info)
{
struct part_driver *part_drv;
int ret;
int i;
- part_drv = part_driver_lookup_type(dev_desc);
+ part_drv = part_driver_lookup_type(desc);
if (!part_drv)
return -1;
@@ -690,7 +708,7 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
}
for (i = 1; i < part_drv->max_entries; i++) {
- ret = part_drv->get_info(dev_desc, i, info);
+ ret = part_drv->get_info(desc, i, info);
if (ret != 0) {
/* no more entries in table */
break;
@@ -710,18 +728,18 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
* Parse a device number and partition name string in the form of
* "devicenum.hwpartnum#partition_name", for example "0.1#misc". devicenum and
* hwpartnum are both optional, defaulting to 0. If the partition is found,
- * sets dev_desc and part_info accordingly with the information of the
+ * sets desc and part_info accordingly with the information of the
* partition with the given partition_name.
*
* @param[in] dev_iface Device interface
* @param[in] dev_part_str Input string argument, like "0.1#misc"
- * @param[out] dev_desc Place to store the device description pointer
+ * @param[out] desc Place to store the device description pointer
* @param[out] part_info Place to store the partition information
* Return: 0 on success, or a negative on error
*/
static int part_get_info_by_dev_and_name(const char *dev_iface,
const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *part_info)
{
char *dup_str = NULL;
@@ -743,11 +761,11 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
return -EINVAL;
}
- ret = blk_get_device_by_str(dev_iface, dev_str, dev_desc);
+ ret = blk_get_device_by_str(dev_iface, dev_str, desc);
if (ret < 0)
goto cleanup;
- ret = part_get_info_by_name(*dev_desc, part_str, part_info);
+ ret = part_get_info_by_name(*desc, part_str, part_info);
if (ret < 0)
printf("Could not find \"%s\" partition\n", part_str);
@@ -758,35 +776,35 @@ cleanup:
int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *part_info,
int allow_whole_dev)
{
int ret;
/* Split the part_name if passed as "$dev_num#part_name". */
- ret = part_get_info_by_dev_and_name(dev_iface, dev_part_str,
- dev_desc, part_info);
+ ret = part_get_info_by_dev_and_name(dev_iface, dev_part_str, desc,
+ part_info);
if (ret >= 0)
return ret;
/*
* Couldn't lookup by name, try looking up the partition description
* directly.
*/
- ret = blk_get_device_part_str(dev_iface, dev_part_str,
- dev_desc, part_info, allow_whole_dev);
+ ret = blk_get_device_part_str(dev_iface, dev_part_str, desc, part_info,
+ allow_whole_dev);
if (ret < 0)
printf("Couldn't find partition %s %s\n",
dev_iface, dev_part_str);
return ret;
}
-void part_set_generic_name(const struct blk_desc *dev_desc,
- int part_num, char *name)
+void part_set_generic_name(const struct blk_desc *desc, int part_num,
+ char *name)
{
char *devtype;
- switch (dev_desc->uclass_id) {
+ switch (desc->uclass_id) {
case UCLASS_IDE:
case UCLASS_AHCI:
devtype = "hd";
@@ -805,7 +823,7 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
break;
}
- sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
+ sprintf(name, "%s%c%d", devtype, 'a' + desc->devnum, part_num);
}
int part_get_bootable(struct blk_desc *desc)
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 45d3a704866..65e30fea558 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -125,7 +125,7 @@ static void print_part_info(struct partition_block *p)
* the ID AMIGA_ID_RDISK ('RDSK') and needs to have a valid
* sum-to-zero checksum
*/
-struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
+struct rigid_disk_block *get_rdisk(struct blk_desc *desc)
{
int i;
int limit;
@@ -139,7 +139,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
for (i=0; i<limit; i++)
{
- ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer);
+ ulong res = blk_dread(desc, i, 1, (ulong *)block_buffer);
if (res == 1)
{
struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer;
@@ -165,7 +165,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
* Ridgid disk block
*/
-struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
+struct bootcode_block *get_bootcode(struct blk_desc *desc)
{
int i;
int limit;
@@ -181,7 +181,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
for (i = 0; i < limit; i++)
{
- ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer);
+ ulong res = blk_dread(desc, i, 1, (ulong *)block_buffer);
if (res == 1)
{
struct bootcode_block *boot = (struct bootcode_block *)block_buffer;
@@ -206,17 +206,17 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
* Test if the given partition has an Amiga partition table/Rigid
* Disk block
*/
-static int part_test_amiga(struct blk_desc *dev_desc)
+static int part_test_amiga(struct blk_desc *desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *bootcode;
PRINTF("part_test_amiga: Testing for an Amiga RDB partition\n");
- rdb = get_rdisk(dev_desc);
+ rdb = get_rdisk(desc);
if (rdb)
{
- bootcode = get_bootcode(dev_desc);
+ bootcode = get_bootcode(desc);
if (bootcode)
PRINTF("part_test_amiga: bootable Amiga disk\n");
else
@@ -235,7 +235,7 @@ static int part_test_amiga(struct blk_desc *dev_desc)
/*
* Find partition number partnum on the given drive.
*/
-static struct partition_block *find_partition(struct blk_desc *dev_desc,
+static struct partition_block *find_partition(struct blk_desc *desc,
int partnum)
{
struct rigid_disk_block *rdb;
@@ -243,7 +243,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
u32 block;
PRINTF("Trying to find partition block %d\n", partnum);
- rdb = get_rdisk(dev_desc);
+ rdb = get_rdisk(desc);
if (!rdb)
{
PRINTF("find_partition: no rdb found\n");
@@ -257,7 +257,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
while (block != 0xFFFFFFFF)
{
- ulong res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer);
+ ulong res = blk_dread(desc, block, 1, (ulong *)block_buffer);
if (res == 1)
{
p = (struct partition_block *)block_buffer;
@@ -289,10 +289,10 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
/*
* Get info about a partition
*/
-static int part_get_info_amiga(struct blk_desc *dev_desc, int part,
- struct disk_partition *info)
+static int part_get_info_amiga(struct blk_desc *desc, int part,
+ struct disk_partition *info)
{
- struct partition_block *p = find_partition(dev_desc, part-1);
+ struct partition_block *p = find_partition(desc, part - 1);
struct amiga_part_geometry *g;
u32 disk_type;
@@ -317,7 +317,7 @@ static int part_get_info_amiga(struct blk_desc *dev_desc, int part,
return 0;
}
-static void part_print_amiga(struct blk_desc *dev_desc)
+static void part_print_amiga(struct blk_desc *desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *boot;
@@ -325,7 +325,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)
u32 block;
int i = 1;
- rdb = get_rdisk(dev_desc);
+ rdb = get_rdisk(desc);
if (!rdb)
{
PRINTF("part_print_amiga: no rdb found\n");
@@ -353,7 +353,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)
PRINTF("Trying to load block #0x%X\n", block);
- res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer);
+ res = blk_dread(desc, block, 1, (ulong *)block_buffer);
if (res == 1)
{
p = (struct partition_block *)block_buffer;
@@ -370,7 +370,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)
} else block = 0xFFFFFFFF;
}
- boot = get_bootcode(dev_desc);
+ boot = get_bootcode(desc);
if (boot)
{
printf("Disk is bootable\n");
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 1b81297d967..33374384373 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -98,27 +98,26 @@ static int test_block_type(unsigned char *buffer)
return -1;
}
-static int part_test_dos(struct blk_desc *dev_desc)
+static int part_test_dos(struct blk_desc *desc)
{
#ifndef CONFIG_SPL_BUILD
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr,
- DIV_ROUND_UP(dev_desc->blksz, sizeof(legacy_mbr)));
+ DIV_ROUND_UP(desc->blksz, sizeof(legacy_mbr)));
- if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1)
+ if (blk_dread(desc, 0, 1, (ulong *)mbr) != 1)
return -1;
if (test_block_type((unsigned char *)mbr) != DOS_MBR)
return -1;
- if (dev_desc->sig_type == SIG_TYPE_NONE &&
- mbr->unique_mbr_signature != 0) {
- dev_desc->sig_type = SIG_TYPE_MBR;
- dev_desc->mbr_sig = mbr->unique_mbr_signature;
+ if (desc->sig_type == SIG_TYPE_NONE && mbr->unique_mbr_signature) {
+ desc->sig_type = SIG_TYPE_MBR;
+ desc->mbr_sig = mbr->unique_mbr_signature;
}
#else
- ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
- if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
+ if (blk_dread(desc, 0, 1, (ulong *)buffer) != 1)
return -1;
if (test_block_type(buffer) != DOS_MBR)
@@ -130,12 +129,12 @@ static int part_test_dos(struct blk_desc *dev_desc)
/* Print a partition that is relative to its Extended partition table
*/
-static void print_partition_extended(struct blk_desc *dev_desc,
+static void print_partition_extended(struct blk_desc *desc,
lbaint_t ext_part_sector,
lbaint_t relative,
int part_num, unsigned int disksig)
{
- ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
dos_partition_t *pt;
int i;
@@ -146,9 +145,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
return;
}
- if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
+ if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
- dev_desc->devnum, ext_part_sector);
+ desc->devnum, ext_part_sector);
return;
}
i=test_block_type(buffer);
@@ -189,9 +188,9 @@ static void print_partition_extended(struct blk_desc *dev_desc,
lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative;
- print_partition_extended(dev_desc, lba_start,
- ext_part_sector == 0 ? lba_start : relative,
- part_num, disksig);
+ print_partition_extended(desc, lba_start,
+ !ext_part_sector ? lba_start :
+ relative, part_num, disksig);
}
}
@@ -201,12 +200,12 @@ static void print_partition_extended(struct blk_desc *dev_desc,
/* Print a partition that is relative to its Extended partition table
*/
-static int part_get_info_extended(struct blk_desc *dev_desc,
+static int part_get_info_extended(struct blk_desc *desc,
lbaint_t ext_part_sector, lbaint_t relative,
int part_num, int which_part,
struct disk_partition *info, uint disksig)
{
- ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
struct disk_partition wdinfo = { 0 };
dos_partition_t *pt;
int i, ret;
@@ -219,9 +218,9 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1;
}
- if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
+ if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
- dev_desc->devnum, ext_part_sector);
+ desc->devnum, ext_part_sector);
return -1;
}
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
@@ -232,12 +231,10 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1;
}
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- if (!ext_part_sector)
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS) && !ext_part_sector)
disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]);
-#endif
- ret = part_get_info_whole_disk(dev_desc, &wdinfo);
+ ret = part_get_info_whole_disk(desc, &wdinfo);
if (ret)
return ret;
@@ -259,14 +256,17 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
info->start = (lbaint_t)(ext_part_sector +
get_unaligned_le32(pt->start4));
info->size = (lbaint_t)get_unaligned_le32(pt->size4);
- part_set_generic_name(dev_desc, part_num,
+ part_set_generic_name(desc, part_num,
(char *)info->name);
/* sprintf(info->type, "%d, pt->sys_ind); */
strcpy((char *)info->type, "U-Boot");
info->bootable = get_bootable(pt);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- sprintf(info->uuid, "%08x-%02x", disksig, part_num);
-#endif
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+ char str[12];
+
+ sprintf(str, "%08x-%02x", disksig, part_num);
+ disk_partition_set_uuid(info, str);
+ }
info->sys_ind = pt->sys_ind;
return 0;
}
@@ -285,7 +285,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative;
- return part_get_info_extended(dev_desc, lba_start,
+ return part_get_info_extended(desc, lba_start,
ext_part_sector == 0 ? lba_start : relative,
part_num, which_part, info, disksig);
}
@@ -296,32 +296,30 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
if (dos_type == DOS_PBR) {
info->start = 0;
- info->size = dev_desc->lba;
+ info->size = desc->lba;
if (wdinfo.blksz > DOS_PART_DEFAULT_SECTOR)
info->blksz = wdinfo.blksz;
else
info->blksz = DOS_PART_DEFAULT_SECTOR;
info->bootable = 0;
strcpy((char *)info->type, "U-Boot");
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- info->uuid[0] = 0;
-#endif
+ disk_partition_clr_uuid(info);
return 0;
}
return -1;
}
-static void __maybe_unused part_print_dos(struct blk_desc *dev_desc)
+static void __maybe_unused part_print_dos(struct blk_desc *desc)
{
printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n");
- print_partition_extended(dev_desc, 0, 0, 1, 0);
+ print_partition_extended(desc, 0, 0, 1, 0);
}
-static int __maybe_unused part_get_info_dos(struct blk_desc *dev_desc, int part,
- struct disk_partition *info)
+static int __maybe_unused part_get_info_dos(struct blk_desc *desc, int part,
+ struct disk_partition *info)
{
- return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
+ return part_get_info_extended(desc, 0, 0, 1, part, info, 0);
}
int is_valid_dos_buf(void *buf)
@@ -501,20 +499,20 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
}
#endif
-int write_mbr_sector(struct blk_desc *dev_desc, void *buf)
+int write_mbr_sector(struct blk_desc *desc, void *buf)
{
if (is_valid_dos_buf(buf))
return -1;
/* write MBR */
- if (blk_dwrite(dev_desc, 0, 1, buf) != 1) {
+ if (blk_dwrite(desc, 0, 1, buf) != 1) {
printf("%s: failed writing '%s' (1 blks at 0x0)\n",
__func__, "MBR");
return 1;
}
/* Update the partition table entries*/
- part_init(dev_desc);
+ part_init(desc);
return 0;
}
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 80a44dc9f07..39382c5faee 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -9,6 +9,9 @@
* when CONFIG_SYS_64BIT_LBA is not defined, lbaint_t is 32 bits; this
* limits the maximum size of addressable storage to < 2 tebibytes
*/
+
+#define LOG_CATEGORY LOGC_FS
+
#include <common.h>
#include <blk.h>
#include <log.h>
@@ -51,12 +54,12 @@ static inline u32 efi_crc32(const void *buf, u32 len)
static int pmbr_part_valid(struct partition *part);
static int is_pmbr_valid(legacy_mbr * mbr);
-static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
- gpt_header *pgpt_head, gpt_entry **pgpt_pte);
-static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
+static int is_gpt_valid(struct blk_desc *desc, u64 lba, gpt_header *pgpt_head,
+ gpt_entry **pgpt_pte);
+static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc,
gpt_header *pgpt_head);
static int is_pte_valid(gpt_entry * pte);
-static int find_valid_gpt(struct blk_desc *dev_desc, gpt_header *gpt_head,
+static int find_valid_gpt(struct blk_desc *desc, gpt_header *gpt_head,
gpt_entry **pgpt_pte);
static char *print_efiname(gpt_entry *pte)
@@ -195,14 +198,14 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h)
* UUID is displayed as 32 hexadecimal digits, in 5 groups,
* separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters
*/
-int get_disk_guid(struct blk_desc * dev_desc, char *guid)
+int get_disk_guid(struct blk_desc *desc, char *guid)
{
- ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
unsigned char *guid_bin;
/* This function validates AND fills in the GPT header and PTE */
- if (find_valid_gpt(dev_desc, gpt_head, &gpt_pte) != 1)
+ if (find_valid_gpt(desc, gpt_head, &gpt_pte) != 1)
return -EINVAL;
guid_bin = gpt_head->disk_guid.b;
@@ -213,15 +216,15 @@ int get_disk_guid(struct blk_desc * dev_desc, char *guid)
return 0;
}
-void part_print_efi(struct blk_desc *dev_desc)
+void part_print_efi(struct blk_desc *desc)
{
- ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
int i = 0;
unsigned char *uuid;
/* This function validates AND fills in the GPT header and PTE */
- if (find_valid_gpt(dev_desc, gpt_head, &gpt_pte) != 1)
+ if (find_valid_gpt(desc, gpt_head, &gpt_pte) != 1)
return;
debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -255,10 +258,10 @@ void part_print_efi(struct blk_desc *dev_desc)
return;
}
-int part_get_info_efi(struct blk_desc *dev_desc, int part,
+int part_get_info_efi(struct blk_desc *desc, int part,
struct disk_partition *info)
{
- ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
/* "part" argument must be at least 1 */
@@ -268,7 +271,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
}
/* This function validates AND fills in the GPT header and PTE */
- if (find_valid_gpt(dev_desc, gpt_head, &gpt_pte) != 1)
+ if (find_valid_gpt(desc, gpt_head, &gpt_pte) != 1)
return -EINVAL;
if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
@@ -283,20 +286,22 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
/* The ending LBA is inclusive, to calculate size, add 1 to it */
info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
- info->start;
- info->blksz = dev_desc->blksz;
+ info->blksz = desc->blksz;
snprintf((char *)info->name, sizeof(info->name), "%s",
print_efiname(&gpt_pte[part - 1]));
strcpy((char *)info->type, "U-Boot");
info->bootable = get_bootable(&gpt_pte[part - 1]);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
- UUID_STR_FORMAT_GUID);
-#endif
-#ifdef CONFIG_PARTITION_TYPE_GUID
- uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
- info->type_guid, UUID_STR_FORMAT_GUID);
-#endif
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+ uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b,
+ (char *)disk_partition_uuid(info),
+ UUID_STR_FORMAT_GUID);
+ }
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) {
+ uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
+ (char *)disk_partition_type_uuid(info),
+ UUID_STR_FORMAT_GUID);
+ }
log_debug("start 0x" LBAF ", size 0x" LBAF ", name %s\n", info->start,
info->size, info->name);
@@ -306,12 +311,12 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
return 0;
}
-static int part_test_efi(struct blk_desc *dev_desc)
+static int part_test_efi(struct blk_desc *desc)
{
- ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, desc->blksz);
/* Read legacy MBR from block 0 and validate it */
- if ((blk_dread(dev_desc, 0, 1, (ulong *)legacymbr) != 1)
+ if ((blk_dread(desc, 0, 1, (ulong *)legacymbr) != 1)
|| (is_pmbr_valid(legacymbr) != 1)) {
return -1;
}
@@ -320,23 +325,23 @@ static int part_test_efi(struct blk_desc *dev_desc)
/**
* set_protective_mbr(): Set the EFI protective MBR
- * @param dev_desc - block device descriptor
+ * @param desc - block device descriptor
*
* Return: - zero on success, otherwise error
*/
-static int set_protective_mbr(struct blk_desc *dev_desc)
+static int set_protective_mbr(struct blk_desc *desc)
{
/* Setup the Protective MBR */
- ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, p_mbr, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, p_mbr, 1, desc->blksz);
if (p_mbr == NULL) {
log_debug("calloc failed!\n");
return -ENOMEM;
}
/* Read MBR to backup boot code if it exists */
- if (blk_dread(dev_desc, 0, 1, p_mbr) != 1) {
+ if (blk_dread(desc, 0, 1, p_mbr) != 1) {
log_debug("** Can't read from device %d **\n",
- dev_desc->devnum);
+ desc->devnum);
return -EIO;
}
@@ -348,27 +353,26 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
p_mbr->signature = MSDOS_MBR_SIGNATURE;
p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT;
p_mbr->partition_record[0].start_sect = 1;
- p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
+ p_mbr->partition_record[0].nr_sects = (u32)desc->lba - 1;
/* Write MBR sector to the MMC device */
- if (blk_dwrite(dev_desc, 0, 1, p_mbr) != 1) {
- log_debug("** Can't write to device %d **\n", dev_desc->devnum);
+ if (blk_dwrite(desc, 0, 1, p_mbr) != 1) {
+ log_debug("** Can't write to device %d **\n", desc->devnum);
return -EIO;
}
return 0;
}
-int write_gpt_table(struct blk_desc *dev_desc,
- gpt_header *gpt_h, gpt_entry *gpt_e)
+int write_gpt_table(struct blk_desc *desc, gpt_header *gpt_h, gpt_entry *gpt_e)
{
const int pte_blk_cnt = BLOCK_CNT((gpt_h->num_partition_entries
- * sizeof(gpt_entry)), dev_desc);
+ * sizeof(gpt_entry)), desc);
u32 calc_crc32;
- debug("max lba: %x\n", (u32) dev_desc->lba);
+ debug("max lba: %x\n", (u32)desc->lba);
/* Setup the Protective MBR */
- if (set_protective_mbr(dev_desc) < 0)
+ if (set_protective_mbr(desc) < 0)
goto err;
/* Generate CRC for the Primary GPT Header */
@@ -382,20 +386,20 @@ int write_gpt_table(struct blk_desc *dev_desc,
gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
/* Write the First GPT to the block right after the Legacy MBR */
- if (blk_dwrite(dev_desc, 1, 1, gpt_h) != 1)
+ if (blk_dwrite(desc, 1, 1, gpt_h) != 1)
goto err;
- if (blk_dwrite(dev_desc, le64_to_cpu(gpt_h->partition_entry_lba),
+ if (blk_dwrite(desc, le64_to_cpu(gpt_h->partition_entry_lba),
pte_blk_cnt, gpt_e) != pte_blk_cnt)
goto err;
prepare_backup_gpt_header(gpt_h);
- if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
+ if (blk_dwrite(desc, (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
+ 1, pte_blk_cnt, gpt_e) != pte_blk_cnt)
goto err;
- if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
+ if (blk_dwrite(desc, (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
gpt_h) != 1)
goto err;
@@ -403,11 +407,11 @@ int write_gpt_table(struct blk_desc *dev_desc,
return 0;
err:
- log_debug("** Can't write to device %d **\n", dev_desc->devnum);
+ log_debug("** Can't write to device %d **\n", desc->devnum);
return -EIO;
}
-int gpt_fill_pte(struct blk_desc *dev_desc,
+int gpt_fill_pte(struct blk_desc *desc,
gpt_header *gpt_h, gpt_entry *gpt_e,
struct disk_partition *partitions, int parts)
{
@@ -416,10 +420,7 @@ int gpt_fill_pte(struct blk_desc *dev_desc,
le64_to_cpu(gpt_h->last_usable_lba);
int i, k;
size_t efiname_len, dosname_len;
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- char *str_uuid;
unsigned char *bin_uuid;
-#endif
#ifdef CONFIG_PARTITION_TYPE_GUID
char *str_type_guid;
unsigned char *bin_type_guid;
@@ -430,7 +431,7 @@ int gpt_fill_pte(struct blk_desc *dev_desc,
size_t pte_start = gpt_h->partition_entry_lba;
size_t pte_end = pte_start +
gpt_h->num_partition_entries * gpt_h->sizeof_partition_entry /
- dev_desc->blksz;
+ desc->blksz;
for (i = 0; i < parts; i++) {
/* partition starting lba */
@@ -488,16 +489,19 @@ int gpt_fill_pte(struct blk_desc *dev_desc,
&partition_basic_data_guid, 16);
#endif
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- str_uuid = partitions[i].uuid;
- bin_uuid = gpt_e[i].unique_partition_guid.b;
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+ const char *str_uuid;
- if (uuid_str_to_bin(str_uuid, bin_uuid, UUID_STR_FORMAT_GUID)) {
- log_debug("Partition no. %d: invalid guid: %s\n",
- i, str_uuid);
- return -EINVAL;
+ str_uuid = disk_partition_uuid(&partitions[i]);
+ bin_uuid = gpt_e[i].unique_partition_guid.b;
+
+ if (uuid_str_to_bin(str_uuid, bin_uuid,
+ UUID_STR_FORMAT_GUID)) {
+ log_debug("Partition no. %d: invalid guid: %s\n",
+ i, str_uuid);
+ return -EINVAL;
+ }
}
-#endif
/* partition attributes */
memset(&gpt_e[i].attributes, 0,
@@ -527,7 +531,7 @@ int gpt_fill_pte(struct blk_desc *dev_desc,
return 0;
}
-static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
+static uint32_t partition_entries_offset(struct blk_desc *desc)
{
uint32_t offset_blks = 2;
uint32_t __maybe_unused offset_bytes;
@@ -543,8 +547,8 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
* CONFIG_EFI_PARTITION_ENTRIES_OFF.
*/
offset_bytes =
- PAD_TO_BLOCKSIZE(CONFIG_EFI_PARTITION_ENTRIES_OFF, dev_desc);
- offset_blks = offset_bytes / dev_desc->blksz;
+ PAD_TO_BLOCKSIZE(CONFIG_EFI_PARTITION_ENTRIES_OFF, desc);
+ offset_blks = offset_bytes / desc->blksz;
#endif
#if defined(CONFIG_OF_CONTROL)
@@ -556,8 +560,8 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
config_offset = ofnode_conf_read_int(
"u-boot,efi-partition-entries-offset", -EINVAL);
if (config_offset != -EINVAL) {
- offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
- offset_blks = offset_bytes / dev_desc->blksz;
+ offset_bytes = PAD_TO_BLOCKSIZE(config_offset, desc);
+ offset_blks = offset_bytes / desc->blksz;
}
#endif
@@ -573,17 +577,17 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
return offset_blks;
}
-int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
- char *str_guid, int parts_count)
+int gpt_fill_header(struct blk_desc *desc, gpt_header *gpt_h, char *str_guid,
+ int parts_count)
{
gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE_UBOOT);
gpt_h->revision = cpu_to_le32(GPT_HEADER_REVISION_V1);
gpt_h->header_size = cpu_to_le32(sizeof(gpt_header));
gpt_h->my_lba = cpu_to_le64(1);
- gpt_h->alternate_lba = cpu_to_le64(dev_desc->lba - 1);
- gpt_h->last_usable_lba = cpu_to_le64(dev_desc->lba - 34);
+ gpt_h->alternate_lba = cpu_to_le64(desc->lba - 1);
+ gpt_h->last_usable_lba = cpu_to_le64(desc->lba - 34);
gpt_h->partition_entry_lba =
- cpu_to_le64(partition_entries_offset(dev_desc));
+ cpu_to_le64(partition_entries_offset(desc));
gpt_h->first_usable_lba =
cpu_to_le64(le64_to_cpu(gpt_h->partition_entry_lba) + 32);
gpt_h->num_partition_entries = cpu_to_le32(GPT_ENTRY_NUMBERS);
@@ -597,14 +601,14 @@ int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
return 0;
}
-int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
+int gpt_restore(struct blk_desc *desc, char *str_disk_guid,
struct disk_partition *partitions, int parts_count)
{
gpt_header *gpt_h;
gpt_entry *gpt_e;
int ret, size;
- size = PAD_TO_BLOCKSIZE(sizeof(gpt_header), dev_desc);
+ size = PAD_TO_BLOCKSIZE(sizeof(gpt_header), desc);
gpt_h = malloc_cache_aligned(size);
if (gpt_h == NULL) {
log_debug("calloc failed!\n");
@@ -613,7 +617,7 @@ int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
memset(gpt_h, 0, size);
size = PAD_TO_BLOCKSIZE(GPT_ENTRY_NUMBERS * sizeof(gpt_entry),
- dev_desc);
+ desc);
gpt_e = malloc_cache_aligned(size);
if (gpt_e == NULL) {
log_debug("calloc failed!\n");
@@ -623,17 +627,17 @@ int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
memset(gpt_e, 0, size);
/* Generate Primary GPT header (LBA1) */
- ret = gpt_fill_header(dev_desc, gpt_h, str_disk_guid, parts_count);
+ ret = gpt_fill_header(desc, gpt_h, str_disk_guid, parts_count);
if (ret)
goto err;
/* Generate partition entries */
- ret = gpt_fill_pte(dev_desc, gpt_h, gpt_e, partitions, parts_count);
+ ret = gpt_fill_pte(desc, gpt_h, gpt_e, partitions, parts_count);
if (ret)
goto err;
/* Write GPT partition table */
- ret = write_gpt_table(dev_desc, gpt_h, gpt_e);
+ ret = write_gpt_table(desc, gpt_h, gpt_e);
err:
free(gpt_e);
@@ -664,14 +668,14 @@ static void gpt_convert_efi_name_to_char(char *s, void *es, int n)
}
}
-int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
+int gpt_verify_headers(struct blk_desc *desc, gpt_header *gpt_head,
gpt_entry **gpt_pte)
{
/*
* This function validates AND
* fills in the GPT header and PTE
*/
- if (is_gpt_valid(dev_desc,
+ if (is_gpt_valid(desc,
GPT_PRIMARY_PARTITION_TABLE_LBA,
gpt_head, gpt_pte) != 1) {
log_debug("Invalid GPT\n");
@@ -684,12 +688,12 @@ int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
/*
* Check that the alternate_lba entry points to the last LBA
*/
- if (le64_to_cpu(gpt_head->alternate_lba) != (dev_desc->lba - 1)) {
+ if (le64_to_cpu(gpt_head->alternate_lba) != (desc->lba - 1)) {
log_debug("Misplaced Backup GPT\n");
return -1;
}
- if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+ if (is_gpt_valid(desc, (desc->lba - 1),
gpt_head, gpt_pte) != 1) {
log_debug("Invalid Backup GPT\n");
return -1;
@@ -698,7 +702,7 @@ int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
return 0;
}
-static void restore_primary_gpt_header(gpt_header *gpt_h, struct blk_desc *dev_desc)
+static void restore_primary_gpt_header(gpt_header *gpt_h, struct blk_desc *desc)
{
u32 calc_crc32;
u64 val;
@@ -707,7 +711,7 @@ static void restore_primary_gpt_header(gpt_header *gpt_h, struct blk_desc *dev_d
val = le64_to_cpu(gpt_h->my_lba);
gpt_h->my_lba = gpt_h->alternate_lba;
gpt_h->alternate_lba = cpu_to_le64(val);
- gpt_h->partition_entry_lba = cpu_to_le64(partition_entries_offset(dev_desc));
+ gpt_h->partition_entry_lba = cpu_to_le64(partition_entries_offset(desc));
gpt_h->header_crc32 = 0;
@@ -716,22 +720,22 @@ static void restore_primary_gpt_header(gpt_header *gpt_h, struct blk_desc *dev_d
gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
}
-static int write_one_gpt_table(struct blk_desc *dev_desc,
- gpt_header *gpt_h, gpt_entry *gpt_e)
+static int write_one_gpt_table(struct blk_desc *desc, gpt_header *gpt_h,
+ gpt_entry *gpt_e)
{
const int pte_blk_cnt = BLOCK_CNT((gpt_h->num_partition_entries
- * sizeof(gpt_entry)), dev_desc);
+ * sizeof(gpt_entry)), desc);
lbaint_t start;
int ret = 0;
start = le64_to_cpu(gpt_h->my_lba);
- if (blk_dwrite(dev_desc, start, 1, gpt_h) != 1) {
+ if (blk_dwrite(desc, start, 1, gpt_h) != 1) {
ret = -1;
goto out;
}
start = le64_to_cpu(gpt_h->partition_entry_lba);
- if (blk_dwrite(dev_desc, start, pte_blk_cnt, gpt_e) != pte_blk_cnt) {
+ if (blk_dwrite(desc, start, pte_blk_cnt, gpt_e) != pte_blk_cnt) {
ret = -1;
goto out;
}
@@ -740,17 +744,17 @@ static int write_one_gpt_table(struct blk_desc *dev_desc,
return ret;
}
-int gpt_repair_headers(struct blk_desc *dev_desc)
+int gpt_repair_headers(struct blk_desc *desc)
{
- ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_h1, 1, dev_desc->blksz);
- ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_h2, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_h1, 1, desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_h2, 1, desc->blksz);
gpt_entry *gpt_e1 = NULL, *gpt_e2 = NULL;
int is_gpt1_valid, is_gpt2_valid;
int ret = -1;
- is_gpt1_valid = is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
+ is_gpt1_valid = is_gpt_valid(desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
gpt_h1, &gpt_e1);
- is_gpt2_valid = is_gpt_valid(dev_desc, dev_desc->lba - 1,
+ is_gpt2_valid = is_gpt_valid(desc, desc->lba - 1,
gpt_h2, &gpt_e2);
if (is_gpt1_valid && is_gpt2_valid) {
@@ -760,13 +764,13 @@ int gpt_repair_headers(struct blk_desc *dev_desc)
if (is_gpt1_valid && !is_gpt2_valid) {
prepare_backup_gpt_header(gpt_h1);
- ret = write_one_gpt_table(dev_desc, gpt_h1, gpt_e1);
+ ret = write_one_gpt_table(desc, gpt_h1, gpt_e1);
goto out;
}
if (!is_gpt1_valid && is_gpt2_valid) {
- restore_primary_gpt_header(gpt_h2, dev_desc);
- ret = write_one_gpt_table(dev_desc, gpt_h2, gpt_e2);
+ restore_primary_gpt_header(gpt_h2, desc);
+ ret = write_one_gpt_table(desc, gpt_h2, gpt_e2);
goto out;
}
@@ -784,7 +788,7 @@ int gpt_repair_headers(struct blk_desc *dev_desc)
return ret;
}
-int gpt_verify_partitions(struct blk_desc *dev_desc,
+int gpt_verify_partitions(struct blk_desc *desc,
struct disk_partition *partitions, int parts,
gpt_header *gpt_head, gpt_entry **gpt_pte)
{
@@ -793,7 +797,7 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
gpt_entry *gpt_e;
int ret, i;
- ret = gpt_verify_headers(dev_desc, gpt_head, gpt_pte);
+ ret = gpt_verify_headers(desc, gpt_head, gpt_pte);
if (ret)
return ret;
@@ -862,28 +866,27 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
return 0;
}
-int is_valid_gpt_buf(struct blk_desc *dev_desc, void *buf)
+int is_valid_gpt_buf(struct blk_desc *desc, void *buf)
{
gpt_header *gpt_h;
gpt_entry *gpt_e;
/* determine start of GPT Header in the buffer */
- gpt_h = buf + (GPT_PRIMARY_PARTITION_TABLE_LBA *
- dev_desc->blksz);
+ gpt_h = buf + (GPT_PRIMARY_PARTITION_TABLE_LBA * desc->blksz);
if (validate_gpt_header(gpt_h, GPT_PRIMARY_PARTITION_TABLE_LBA,
- dev_desc->lba))
+ desc->lba))
return -1;
/* determine start of GPT Entries in the buffer */
gpt_e = buf + (le64_to_cpu(gpt_h->partition_entry_lba) *
- dev_desc->blksz);
+ desc->blksz);
if (validate_gpt_entries(gpt_h, gpt_e))
return -1;
return 0;
}
-int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
+int write_mbr_and_gpt_partitions(struct blk_desc *desc, void *buf)
{
gpt_header *gpt_h;
gpt_entry *gpt_e;
@@ -891,24 +894,22 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
lbaint_t lba;
int cnt;
- if (is_valid_gpt_buf(dev_desc, buf))
+ if (is_valid_gpt_buf(desc, buf))
return -1;
/* determine start of GPT Header in the buffer */
- gpt_h = buf + (GPT_PRIMARY_PARTITION_TABLE_LBA *
- dev_desc->blksz);
+ gpt_h = buf + (GPT_PRIMARY_PARTITION_TABLE_LBA * desc->blksz);
/* determine start of GPT Entries in the buffer */
- gpt_e = buf + (le64_to_cpu(gpt_h->partition_entry_lba) *
- dev_desc->blksz);
+ gpt_e = buf + (le64_to_cpu(gpt_h->partition_entry_lba) * desc->blksz);
gpt_e_blk_cnt = BLOCK_CNT((le32_to_cpu(gpt_h->num_partition_entries) *
le32_to_cpu(gpt_h->sizeof_partition_entry)),
- dev_desc);
+ desc);
/* write MBR */
lba = 0; /* MBR is always at 0 */
cnt = 1; /* MBR (1 block) */
- if (blk_dwrite(dev_desc, lba, cnt, buf) != cnt) {
+ if (blk_dwrite(desc, lba, cnt, buf) != cnt) {
log_debug("failed writing '%s' (%d blks at 0x" LBAF ")\n",
"MBR", cnt, lba);
return 1;
@@ -917,7 +918,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
/* write Primary GPT */
lba = GPT_PRIMARY_PARTITION_TABLE_LBA;
cnt = 1; /* GPT Header (1 block) */
- if (blk_dwrite(dev_desc, lba, cnt, gpt_h) != cnt) {
+ if (blk_dwrite(desc, lba, cnt, gpt_h) != cnt) {
log_debug("failed writing '%s' (%d blks at 0x" LBAF ")\n",
"Primary GPT Header", cnt, lba);
return 1;
@@ -925,7 +926,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
lba = le64_to_cpu(gpt_h->partition_entry_lba);
cnt = gpt_e_blk_cnt;
- if (blk_dwrite(dev_desc, lba, cnt, gpt_e) != cnt) {
+ if (blk_dwrite(desc, lba, cnt, gpt_e) != cnt) {
log_debug("failed writing '%s' (%d blks at 0x" LBAF ")\n",
"Primary GPT Entries", cnt, lba);
return 1;
@@ -936,7 +937,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
/* write Backup GPT */
lba = le64_to_cpu(gpt_h->partition_entry_lba);
cnt = gpt_e_blk_cnt;
- if (blk_dwrite(dev_desc, lba, cnt, gpt_e) != cnt) {
+ if (blk_dwrite(desc, lba, cnt, gpt_e) != cnt) {
log_debug("failed writing '%s' (%d blks at 0x" LBAF ")\n",
"Backup GPT Entries", cnt, lba);
return 1;
@@ -944,14 +945,14 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
lba = le64_to_cpu(gpt_h->my_lba);
cnt = 1; /* GPT Header (1 block) */
- if (blk_dwrite(dev_desc, lba, cnt, gpt_h) != cnt) {
+ if (blk_dwrite(desc, lba, cnt, gpt_h) != cnt) {
log_debug("failed writing '%s' (%d blks at 0x" LBAF ")\n",
"Backup GPT Header", cnt, lba);
return 1;
}
/* Update the partition table entries*/
- part_init(dev_desc);
+ part_init(desc);
return 0;
}
@@ -978,17 +979,23 @@ static int pmbr_part_valid(struct partition *part)
/*
* is_pmbr_valid(): test Protective MBR for validity
*
+ * @mbr: Pointer to Master Boot-Record data
+ *
* Returns: 1 if PMBR is valid, 0 otherwise.
* Validity depends on two things:
* 1) MSDOS signature is in the last two bytes of the MBR
* 2) One partition of type 0xEE is found, checked by pmbr_part_valid()
*/
-static int is_pmbr_valid(legacy_mbr * mbr)
+static int is_pmbr_valid(legacy_mbr *mbr)
{
+ uint sig = le16_to_cpu(mbr->signature);
int i = 0;
- if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
+ if (sig != MSDOS_MBR_SIGNATURE) {
+ log_debug("Invalid signature %x\n", sig);
return 0;
+ }
+ log_debug("Signature %x valid\n", sig);
for (i = 0; i < 4; i++) {
if (pmbr_part_valid(&mbr->partition_record[i])) {
@@ -1008,25 +1015,25 @@ static int is_pmbr_valid(legacy_mbr * mbr)
* Description: returns 1 if valid, 0 on error, 2 if ignored header
* If valid, returns pointers to PTEs.
*/
-static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
- gpt_header *pgpt_head, gpt_entry **pgpt_pte)
+static int is_gpt_valid(struct blk_desc *desc, u64 lba, gpt_header *pgpt_head,
+ gpt_entry **pgpt_pte)
{
/* Confirm valid arguments prior to allocation. */
- if (!dev_desc || !pgpt_head) {
+ if (!desc || !pgpt_head) {
log_debug("Invalid Argument(s)\n");
return 0;
}
- ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, mbr, 1, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, mbr, 1, desc->blksz);
/* Read MBR Header from device */
- if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) {
+ if (blk_dread(desc, 0, 1, (ulong *)mbr) != 1) {
log_debug("Can't read MBR header\n");
return 0;
}
/* Read GPT Header from device */
- if (blk_dread(dev_desc, (lbaint_t)lba, 1, pgpt_head) != 1) {
+ if (blk_dread(desc, (lbaint_t)lba, 1, pgpt_head) != 1) {
log_debug("Can't read GPT header\n");
return 0;
}
@@ -1037,23 +1044,23 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
return 2;
}
- if (validate_gpt_header(pgpt_head, (lbaint_t)lba, dev_desc->lba))
+ if (validate_gpt_header(pgpt_head, (lbaint_t)lba, desc->lba))
return 0;
- if (dev_desc->sig_type == SIG_TYPE_NONE) {
+ if (desc->sig_type == SIG_TYPE_NONE) {
efi_guid_t empty = {};
if (memcmp(&pgpt_head->disk_guid, &empty, sizeof(empty))) {
- dev_desc->sig_type = SIG_TYPE_GUID;
- memcpy(&dev_desc->guid_sig, &pgpt_head->disk_guid,
- sizeof(empty));
+ desc->sig_type = SIG_TYPE_GUID;
+ memcpy(&desc->guid_sig, &pgpt_head->disk_guid,
+ sizeof(empty));
} else if (mbr->unique_mbr_signature != 0) {
- dev_desc->sig_type = SIG_TYPE_MBR;
- dev_desc->mbr_sig = mbr->unique_mbr_signature;
+ desc->sig_type = SIG_TYPE_MBR;
+ desc->mbr_sig = mbr->unique_mbr_signature;
}
}
/* Read and allocate Partition Table Entries */
- *pgpt_pte = alloc_read_gpt_entries(dev_desc, pgpt_head);
+ *pgpt_pte = alloc_read_gpt_entries(desc, pgpt_head);
if (!*pgpt_pte)
return 0;
@@ -1075,20 +1082,20 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
* Description: returns 1 if found a valid gpt, 0 on error.
* If valid, returns pointers to PTEs.
*/
-static int find_valid_gpt(struct blk_desc *dev_desc, gpt_header *gpt_head,
+static int find_valid_gpt(struct blk_desc *desc, gpt_header *gpt_head,
gpt_entry **pgpt_pte)
{
int r;
- r = is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head,
+ r = is_gpt_valid(desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head,
pgpt_pte);
if (r != 1) {
if (r != 2)
log_debug("Invalid GPT\n");
- if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), gpt_head,
- pgpt_pte) != 1) {
+ if (is_gpt_valid(desc, desc->lba - 1, gpt_head, pgpt_pte)
+ != 1) {
log_debug("Invalid Backup GPT\n");
return 0;
}
@@ -1100,21 +1107,21 @@ static int find_valid_gpt(struct blk_desc *dev_desc, gpt_header *gpt_head,
/**
* alloc_read_gpt_entries(): reads partition entries from disk
- * @dev_desc
+ * @desc
* @gpt - GPT header
*
* Description: Returns ptes on success, NULL on error.
* Allocates space for PTEs based on information found in @gpt.
* Notes: remember to free pte when you're done!
*/
-static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
+static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc,
gpt_header *pgpt_head)
{
size_t count = 0, blk_cnt;
lbaint_t blk;
gpt_entry *pte = NULL;
- if (!dev_desc || !pgpt_head) {
+ if (!desc || !pgpt_head) {
log_debug("Invalid Argument(s)\n");
return NULL;
}
@@ -1130,7 +1137,7 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
/* Allocate memory for PTE, remember to FREE */
if (count != 0) {
pte = memalign(ARCH_DMA_MINALIGN,
- PAD_TO_BLOCKSIZE(count, dev_desc));
+ PAD_TO_BLOCKSIZE(count, desc));
}
if (count == 0 || pte == NULL) {
@@ -1141,8 +1148,8 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
/* Read GPT Entries from device */
blk = le64_to_cpu(pgpt_head->partition_entry_lba);
- blk_cnt = BLOCK_CNT(count, dev_desc);
- if (blk_dread(dev_desc, blk, (lbaint_t)blk_cnt, pte) != blk_cnt) {
+ blk_cnt = BLOCK_CNT(count, desc);
+ if (blk_dread(desc, blk, (lbaint_t)blk_cnt, pte) != blk_cnt) {
log_debug("Can't read GPT Entries\n");
free(pte);
return NULL;
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 4cd619bf46d..6ac6d95be92 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -46,7 +46,7 @@ unsigned long iso_dread(struct blk_desc *block_dev, lbaint_t start,
}
/* only boot records will be listed as valid partitions */
-int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
+int part_get_info_iso_verb(struct blk_desc *desc, int part_num,
struct disk_partition *info, int verb)
{
int i,offset,entry_num;
@@ -58,23 +58,23 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
iso_val_entry_t *pve = (iso_val_entry_t *)tmpbuf;
iso_init_def_entry_t *pide;
- if ((dev_desc->blksz != CD_SECTSIZE) && (dev_desc->blksz != 512))
+ if (desc->blksz != CD_SECTSIZE && desc->blksz != 512)
return -1;
/* the first sector (sector 0x10) must be a primary volume desc */
blkaddr=PVD_OFFSET;
- if (iso_dread(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
+ if (iso_dread(desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
return -1;
if(ppr->desctype!=0x01) {
if(verb)
printf ("** First descriptor is NOT a primary desc on %d:%d **\n",
- dev_desc->devnum, part_num);
+ desc->devnum, part_num);
return (-1);
}
if(strncmp((char *)ppr->stand_ident,"CD001",5)!=0) {
if(verb)
printf ("** Wrong ISO Ident: %s on %d:%d **\n",
- ppr->stand_ident, dev_desc->devnum, part_num);
+ ppr->stand_ident, desc->devnum, part_num);
return (-1);
}
lastsect = le32_to_cpu(ppr->firstsek_LEpathtab1_LE);
@@ -83,14 +83,14 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
PRINTF(" Lastsect:%08lx\n",lastsect);
for(i=blkaddr;i<lastsect;i++) {
PRINTF("Reading block %d\n", i);
- if (iso_dread(dev_desc, i, 1, (ulong *)tmpbuf) != 1)
+ if (iso_dread(desc, i, 1, (ulong *)tmpbuf) != 1)
return -1;
if(ppr->desctype==0x00)
break; /* boot entry found */
if(ppr->desctype==0xff) {
if(verb)
printf ("** No valid boot catalog found on %d:%d **\n",
- dev_desc->devnum, part_num);
+ desc->devnum, part_num);
return (-1);
}
}
@@ -98,15 +98,15 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if(strncmp(pbr->ident_str,"EL TORITO SPECIFICATION",23)!=0) {
if(verb)
printf ("** Wrong El Torito ident: %s on %d:%d **\n",
- pbr->ident_str, dev_desc->devnum, part_num);
+ pbr->ident_str, desc->devnum, part_num);
return (-1);
}
bootaddr = get_unaligned_le32(pbr->pointer);
PRINTF(" Boot Entry at: %08lX\n",bootaddr);
- if (iso_dread(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
+ if (iso_dread(desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
if(verb)
printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
- bootaddr, dev_desc->devnum, part_num);
+ bootaddr, desc->devnum, part_num);
return (-1);
}
chksum=0;
@@ -116,20 +116,20 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if(chksum!=0) {
if(verb)
printf("** Checksum Error in booting catalog validation entry on %d:%d **\n",
- dev_desc->devnum, part_num);
+ desc->devnum, part_num);
return (-1);
}
if((pve->key[0]!=0x55)||(pve->key[1]!=0xAA)) {
if(verb)
printf ("** Key 0x55 0xAA error on %d:%d **\n",
- dev_desc->devnum, part_num);
+ desc->devnum, part_num);
return(-1);
}
#ifdef CHECK_FOR_POWERPC_PLATTFORM
if(pve->platform!=0x01) {
if(verb)
printf ("** No PowerPC platform CD on %d:%d **\n",
- dev_desc->devnum, part_num);
+ desc->devnum, part_num);
return(-1);
}
#endif
@@ -137,7 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
entry_num=1;
offset=0x20;
strcpy((char *)info->type, "U-Boot");
- part_set_generic_name(dev_desc, part_num, (char *)info->name);
+ part_set_generic_name(desc, part_num, (char *)info->name);
/* the bootcatalog (including validation Entry) is limited to 2048Bytes
* (63 boot entries + validation entry) */
while(offset<2048) {
@@ -159,7 +159,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
else {
if(verb)
printf ("** Partition %d not found on device %d **\n",
- part_num, dev_desc->devnum);
+ part_num, desc->devnum);
return(-1);
}
}
@@ -167,13 +167,13 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
* searched w/o succsess */
if(verb)
printf ("** Partition %d not found on device %d **\n",
- part_num, dev_desc->devnum);
+ part_num, desc->devnum);
return(-1);
found:
if(pide->boot_ind!=0x88) {
if(verb)
printf("** Partition %d is not bootable on device %d **\n",
- part_num, dev_desc->devnum);
+ part_num, desc->devnum);
return (-1);
}
switch(pide->boot_media) {
@@ -189,7 +189,7 @@ found:
newblkaddr = get_unaligned_le32(pide->rel_block_addr);
info->start=newblkaddr;
- if (dev_desc->blksz == 512) {
+ if (desc->blksz == 512) {
info->size *= 4;
info->start *= 4;
info->blksz = 512;
@@ -199,20 +199,20 @@ found:
return 0;
}
-static int part_get_info_iso(struct blk_desc *dev_desc, int part_num,
+static int part_get_info_iso(struct blk_desc *desc, int part_num,
struct disk_partition *info)
{
- return part_get_info_iso_verb(dev_desc, part_num, info, 0);
+ return part_get_info_iso_verb(desc, part_num, info, 0);
}
-static void part_print_iso(struct blk_desc *dev_desc)
+static void part_print_iso(struct blk_desc *desc)
{
struct disk_partition info;
int i;
- if (part_get_info_iso_verb(dev_desc, 1, &info, 0) == -1) {
+ if (part_get_info_iso_verb(desc, 1, &info, 0) == -1) {
printf("** No boot partition found on device %d **\n",
- dev_desc->devnum);
+ desc->devnum);
return;
}
printf("Part Start Sect x Size Type\n");
@@ -221,14 +221,14 @@ static void part_print_iso(struct blk_desc *dev_desc)
printf(" %2d %8" LBAFlength "u %8" LBAFlength "u %6ld %.32s\n",
i, info.start, info.size, info.blksz, info.type);
i++;
- } while (part_get_info_iso_verb(dev_desc, i, &info, 0) != -1);
+ } while (part_get_info_iso_verb(desc, i, &info, 0) != -1);
}
-static int part_test_iso(struct blk_desc *dev_desc)
+static int part_test_iso(struct blk_desc *desc)
{
struct disk_partition info;
- return part_get_info_iso_verb(dev_desc, 1, &info, 0);
+ return part_get_info_iso_verb(desc, 1, &info, 0);
}
U_BOOT_PART_TYPE(iso) = {
diff --git a/disk/part_mac.c b/disk/part_mac.c
index ae8263f755a..db5e203be59 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -31,21 +31,20 @@ extern ldiv_t ldiv (long int __numer, long int __denom);
#endif
-static int part_mac_read_ddb(struct blk_desc *dev_desc,
- mac_driver_desc_t *ddb_p);
-static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
+static int part_mac_read_ddb(struct blk_desc *desc, mac_driver_desc_t *ddb_p);
+static int part_mac_read_pdb(struct blk_desc *desc, int part,
mac_partition_t *pdb_p);
/*
* Test for a valid MAC partition
*/
-static int part_test_mac(struct blk_desc *dev_desc)
+static int part_test_mac(struct blk_desc *desc)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
ulong i, n;
- if (part_mac_read_ddb (dev_desc, ddesc)) {
+ if (part_mac_read_ddb(desc, ddesc)) {
/*
* error reading Driver Descriptor Block,
* or no valid Signature
@@ -55,8 +54,8 @@ static int part_test_mac(struct blk_desc *dev_desc)
n = 1; /* assuming at least one partition */
for (i=1; i<=n; ++i) {
- if ((blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) ||
- (mpart->signature != MAC_PARTITION_MAGIC) ) {
+ if ((blk_dread(desc, i, 1, (ulong *)mpart) != 1) ||
+ mpart->signature != MAC_PARTITION_MAGIC) {
return (-1);
}
/* update partition count */
@@ -65,14 +64,14 @@ static int part_test_mac(struct blk_desc *dev_desc)
return (0);
}
-static void part_print_mac(struct blk_desc *dev_desc)
+static void part_print_mac(struct blk_desc *desc)
{
ulong i, n;
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
ldiv_t mb, gb;
- if (part_mac_read_ddb (dev_desc, ddesc)) {
+ if (part_mac_read_ddb(desc, ddesc)) {
/*
* error reading Driver Descriptor Block,
* or no valid Signature
@@ -110,15 +109,15 @@ static void part_print_mac(struct blk_desc *dev_desc)
char c;
printf ("%4ld: ", i);
- if (blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) {
+ if (blk_dread(desc, i, 1, (ulong *)mpart) != 1) {
printf ("** Can't read Partition Map on %d:%ld **\n",
- dev_desc->devnum, i);
+ desc->devnum, i);
return;
}
if (mpart->signature != MAC_PARTITION_MAGIC) {
printf("** Bad Signature on %d:%ld - expected 0x%04x, got 0x%04x\n",
- dev_desc->devnum, i, MAC_PARTITION_MAGIC,
+ desc->devnum, i, MAC_PARTITION_MAGIC,
mpart->signature);
return;
}
@@ -154,10 +153,9 @@ static void part_print_mac(struct blk_desc *dev_desc)
/*
* Read Device Descriptor Block
*/
-static int part_mac_read_ddb(struct blk_desc *dev_desc,
- mac_driver_desc_t *ddb_p)
+static int part_mac_read_ddb(struct blk_desc *desc, mac_driver_desc_t *ddb_p)
{
- if (blk_dread(dev_desc, 0, 1, (ulong *)ddb_p) != 1) {
+ if (blk_dread(desc, 0, 1, (ulong *)ddb_p) != 1) {
debug("** Can't read Driver Descriptor Block **\n");
return (-1);
}
@@ -171,7 +169,7 @@ static int part_mac_read_ddb(struct blk_desc *dev_desc,
/*
* Read Partition Descriptor Block
*/
-static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
+static int part_mac_read_pdb(struct blk_desc *desc, int part,
mac_partition_t *pdb_p)
{
int n = 1;
@@ -182,15 +180,15 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
* partition 1 first since this is the only way to
* know how many partitions we have.
*/
- if (blk_dread(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
- printf ("** Can't read Partition Map on %d:%d **\n",
- dev_desc->devnum, n);
+ if (blk_dread(desc, n, 1, (ulong *)pdb_p) != 1) {
+ printf("** Can't read Partition Map on %d:%d **\n",
+ desc->devnum, n);
return (-1);
}
if (pdb_p->signature != MAC_PARTITION_MAGIC) {
printf("** Bad Signature on %d:%d: expected 0x%04x, got 0x%04x\n",
- dev_desc->devnum, n, MAC_PARTITION_MAGIC,
+ desc->devnum, n, MAC_PARTITION_MAGIC,
pdb_p->signature);
return (-1);
}
@@ -199,10 +197,9 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
return (0);
if ((part < 1) || (part > pdb_p->map_count)) {
- printf ("** Invalid partition %d:%d [%d:1...%d:%d only]\n",
- dev_desc->devnum, part,
- dev_desc->devnum,
- dev_desc->devnum, pdb_p->map_count);
+ printf("** Invalid partition %d:%d [%d:1...%d:%d only]\n",
+ desc->devnum, part, desc->devnum, desc->devnum,
+ pdb_p->map_count);
return (-1);
}
@@ -213,21 +210,19 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
/* NOTREACHED */
}
-static int part_get_info_mac(struct blk_desc *dev_desc, int part,
- struct disk_partition *info)
+static int part_get_info_mac(struct blk_desc *desc, int part,
+ struct disk_partition *info)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
- if (part_mac_read_ddb (dev_desc, ddesc)) {
- return (-1);
- }
+ if (part_mac_read_ddb(desc, ddesc))
+ return -1;
info->blksz = ddesc->blk_size;
- if (part_mac_read_pdb (dev_desc, part, mpart)) {
- return (-1);
- }
+ if (part_mac_read_pdb(desc, part, mpart))
+ return -1;
info->start = mpart->start_block;
info->size = mpart->block_count;
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index ec313653578..c01e0971dc8 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -677,11 +677,12 @@ Assuming the bootmeth is happy, or at least indicates that it is willing to try
partition. If that works it tries to detect a file system. If that works then it
calls the bootmeth device once more, this time to read the bootflow.
-Note: At present a filesystem is needed for the bootmeth to be called on block
-devices, simply because we don't have any examples where this is not the case.
-This feature can be added as needed. Note that sandbox is a special case, since
-in that case the host filesystem can be accessed even though the block device
-is NULL.
+Note: Normally a filesystem is needed for the bootmeth to be called on block
+devices, but bootmeths which don't need that can set the BOOTMETHF_ANY_PART
+flag to indicate that they can scan any partition. An example is the ChromiumOS
+bootmeth which can store a kernel in a raw partition. Note also that sandbox is
+a special case, since in that case the host filesystem can be accessed even
+though the block device is NULL.
If we take the example of the `bootmeth_extlinux` driver, this call ends up at
`extlinux_read_bootflow()`. It has the filesystem ready, so tries various
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6e26b64fb81..60f8d6700ad 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -598,9 +598,10 @@ int device_probe(struct udevice *dev)
ret = device_notify(dev, EVT_DM_POST_PROBE);
if (ret)
- return ret;
+ goto fail_event;
return 0;
+fail_event:
fail_uclass:
if (device_remove(dev, DM_REMOVE_NORMAL)) {
dm_warn("%s: Device '%s' failed to remove on error path\n",
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index d1476aa433d..8ff1fd0ec83 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -110,9 +110,7 @@ int fat_register_device(struct blk_desc *dev_desc, int part_no)
info.name[0] = 0;
info.type[0] = 0;
info.bootable = 0;
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
- info.uuid[0] = 0;
-#endif
+ disk_partition_clr_uuid(&info);
}
return fat_set_blk_dev(dev_desc, &info);
diff --git a/include/bootmeth.h b/include/bootmeth.h
index d3d8d608cd7..0fc36104ece 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -16,9 +16,12 @@ struct udevice;
* enum bootmeth_flags - Flags for bootmeths
*
* @BOOTMETHF_GLOBAL: bootmeth handles bootdev selection automatically
+ * @BOOTMETHF_ANY_PART: bootmeth is willing to check any partition, even if it
+ * has no filesystem
*/
enum bootmeth_flags {
BOOTMETHF_GLOBAL = BIT(0),
+ BOOTMETHF_ANY_PART = BIT(1),
};
/**
diff --git a/include/os.h b/include/os.h
index 968412b0a82..fc8a1b15cbf 100644
--- a/include/os.h
+++ b/include/os.h
@@ -98,6 +98,16 @@ int os_close(int fd);
*/
int os_unlink(const char *pathname);
+/** os_persistent_fname() - Find the path to a test file
+ *
+ * @buf: Buffer to hold path
+ * @maxsize: Maximum size of buffer
+ * @fname: Leaf filename to find
+ * Returns: 0 on success, -ENOENT if file is not found, -ENOSPC if the buffer is
+ * too small
+ */
+int os_persistent_file(char *buf, int maxsize, const char *fname);
+
/**
* os_exit() - access to the OS exit() system call
*
diff --git a/include/part.h b/include/part.h
index be144768777..f321479a5e9 100644
--- a/include/part.h
+++ b/include/part.h
@@ -80,6 +80,73 @@ struct disk_partition {
#endif
};
+/* Accessors for struct disk_partition field ->uuid */
+extern char *__invalid_use_of_disk_partition_uuid;
+
+static inline const char *disk_partition_uuid(const struct disk_partition *info)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ return info->uuid;
+#else
+ return __invalid_use_of_disk_partition_uuid;
+#endif
+}
+
+static inline void disk_partition_set_uuid(struct disk_partition *info,
+ const char *val)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ strlcpy(info->uuid, val, UUID_STR_LEN + 1);
+#endif
+}
+
+static inline void disk_partition_clr_uuid(struct disk_partition *info)
+{
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ *info->uuid = '\0';
+#endif
+}
+
+/* Accessors for struct disk_partition field ->type_guid */
+extern char *__invalid_use_of_disk_partition_type_uuid;
+
+static inline const
+char *disk_partition_type_uuid(const struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ return info->type_guid;
+#else
+ return __invalid_use_of_disk_partition_type_uuid;
+#endif
+}
+
+static inline void disk_partition_set_type_guid(struct disk_partition *info,
+ const char *val)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ strlcpy(info->type_guid, val, UUID_STR_LEN + 1);
+#endif
+}
+
+static inline void disk_partition_clr_type_guid(struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+ *info->type_guid = '\0';
+#endif
+}
+
+/* Accessors for struct disk_partition field ->sys_ind */
+extern int __invalid_use_of_disk_partition_sys_ind;
+
+static inline uint disk_partition_sys_ind(const struct disk_partition *info)
+{
+#ifdef CONFIG_DOS_PARTITION
+ return info->sys_ind;
+#else
+ return __invalid_use_of_disk_partition_sys_ind;
+#endif
+}
+
struct disk_part {
int partnum;
struct disk_partition gpt_part_info;
@@ -113,7 +180,7 @@ struct blk_desc *mg_disk_get_dev(int dev);
* contained with the interface's data structure. There is no global
* numbering for block devices, so the interface name must be provided.
*
- * @dev_desc: Block device descriptor
+ * @desc: Block device descriptor
* @part: Partition number to read
* @part_type: Partition driver to use, or PART_TYPE_UNKNOWN to automatically
* choose a driver
@@ -121,24 +188,24 @@ struct blk_desc *mg_disk_get_dev(int dev);
*
* Return: 0 on success, negative errno on failure
*/
-int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type,
+int part_get_info_by_type(struct blk_desc *desc, int part, int part_type,
struct disk_partition *info);
-int part_get_info(struct blk_desc *dev_desc, int part,
+int part_get_info(struct blk_desc *desc, int part,
struct disk_partition *info);
/**
* part_get_info_whole_disk() - get partition info for the special case of
* a partition occupying the entire disk.
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @info: returned partition information
* Return: 0 on success
*/
-int part_get_info_whole_disk(struct blk_desc *dev_desc,
+int part_get_info_whole_disk(struct blk_desc *desc,
struct disk_partition *info);
-void part_print(struct blk_desc *dev_desc);
-void part_init(struct blk_desc *dev_desc);
-void dev_print(struct blk_desc *dev_desc);
+void part_print(struct blk_desc *desc);
+void part_init(struct blk_desc *desc);
+void dev_print(struct blk_desc *desc);
/**
* blk_get_device_by_str() - Get a block device given its interface/hw partition
@@ -162,11 +229,11 @@ void dev_print(struct blk_desc *dev_desc);
* containing the device number (e.g. "2") or the device number
* and hardware partition number (e.g. "2.4") for devices that
* support it (currently only MMC).
- * @dev_desc: Returns a pointer to the block device on success
+ * @desc: Returns a pointer to the block device on success
* Return: block device number (local to the interface), or -1 on error
*/
int blk_get_device_by_str(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc);
+ struct blk_desc **desc);
/**
* blk_get_device_part_str() - Get a block device and partition
@@ -196,7 +263,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,
*
* @ifname: Interface name (e.g. "ide", "scsi")
* @dev_part_str: Device and partition string
- * @dev_desc: Returns a pointer to the block device on success
+ * @desc: Returns a pointer to the block device on success
* @info: Returns partition information
* @allow_whole_dev: true to allow the user to select partition 0
* (which means the whole device), false to require a valid
@@ -205,22 +272,22 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,
*
*/
int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *info, int allow_whole_dev);
/**
* part_get_info_by_name() - Search for a partition by name
* among all available registered partitions
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @name: the specified table entry name
* @info: returns the disk partition info
*
* Return: the partition number on match (starting on 1), -1 on no match,
* otherwise error
*/
-int part_get_info_by_name(struct blk_desc *dev_desc,
- const char *name, struct disk_partition *info);
+int part_get_info_by_name(struct blk_desc *desc, const char *name,
+ struct disk_partition *info);
/**
* part_get_info_by_dev_and_name_or_num() - Get partition info from dev number
@@ -232,11 +299,11 @@ int part_get_info_by_name(struct blk_desc *dev_desc,
* (like "device_num#partition_name") or a device number plus a partition number
* separated by a ":". For example both "0#misc" and "0:1" can be valid
* partition descriptions for a given interface. If the partition is found, sets
- * dev_desc and part_info accordingly with the information of the partition.
+ * desc and part_info accordingly with the information of the partition.
*
* @dev_iface: Device interface
* @dev_part_str: Input partition description, like "0#misc" or "0:1"
- * @dev_desc: Place to store the device description pointer
+ * @desc: Place to store the device description pointer
* @part_info: Place to store the partition information
* @allow_whole_dev: true to allow the user to select partition 0
* (which means the whole device), false to require a valid
@@ -245,7 +312,7 @@ int part_get_info_by_name(struct blk_desc *dev_desc,
*/
int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *part_info,
int allow_whole_dev);
@@ -256,12 +323,12 @@ int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
* (DOS, ISO). Generates partition name out of the device type and partition
* number.
*
- * @dev_desc: pointer to the block device
+ * @desc: pointer to the block device
* @part_num: partition number for which the name is generated
* @name: buffer where the name is written
*/
-void part_set_generic_name(const struct blk_desc *dev_desc,
- int part_num, char *name);
+void part_set_generic_name(const struct blk_desc *desc, int part_num,
+ char *name);
extern const struct block_drvr block_drvr[];
#else
@@ -269,26 +336,25 @@ static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }
-static inline int part_get_info(struct blk_desc *dev_desc, int part,
+static inline int part_get_info(struct blk_desc *desc, int part,
struct disk_partition *info) { return -1; }
-static inline int part_get_info_whole_disk(struct blk_desc *dev_desc,
+static inline int part_get_info_whole_disk(struct blk_desc *desc,
struct disk_partition *info)
{ return -1; }
-static inline void part_print(struct blk_desc *dev_desc) {}
-static inline void part_init(struct blk_desc *dev_desc) {}
-static inline void dev_print(struct blk_desc *dev_desc) {}
+static inline void part_print(struct blk_desc *desc) {}
+static inline void part_init(struct blk_desc *desc) {}
+static inline void dev_print(struct blk_desc *desc) {}
static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc)
+ struct blk_desc **desc)
{ return -1; }
static inline int blk_get_device_part_str(const char *ifname,
const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *info,
int allow_whole_dev)
-{ *dev_desc = NULL; return -1; }
+{ *desc = NULL; return -1; }
-static inline int part_get_info_by_name(struct blk_desc *dev_desc,
- const char *name,
+static inline int part_get_info_by_name(struct blk_desc *desc, const char *name,
struct disk_partition *info)
{
return -ENOENT;
@@ -297,23 +363,15 @@ static inline int part_get_info_by_name(struct blk_desc *dev_desc,
static inline int
part_get_info_by_dev_and_name_or_num(const char *dev_iface,
const char *dev_part_str,
- struct blk_desc **dev_desc,
+ struct blk_desc **desc,
struct disk_partition *part_info,
int allow_whole_dev)
{
- *dev_desc = NULL;
+ *desc = NULL;
return -ENOSYS;
}
#endif
-/**
- * part_get_bootable() - Find the first bootable partition
- *
- * @desc: Block-device descriptor
- * @return first bootable partition, or 0 if there is none
- */
-int part_get_bootable(struct blk_desc *desc);
-
struct udevice;
/**
* disk_blk_read() - read blocks from a disk partition
@@ -382,29 +440,29 @@ struct part_driver {
/**
* @get_info: Get information about a partition
*
- * @get_info.dev_desc: Block device descriptor
+ * @get_info.desc: Block device descriptor
* @get_info.part: Partition number (1 = first)
* @get_info.info: Returns partition information
*/
- int (*get_info)(struct blk_desc *dev_desc, int part,
+ int (*get_info)(struct blk_desc *desc, int part,
struct disk_partition *info);
/**
* @print: Print partition information
*
- * @print.dev_desc: Block device descriptor
+ * @print.desc: Block device descriptor
*/
- void (*print)(struct blk_desc *dev_desc);
+ void (*print)(struct blk_desc *desc);
/**
* @test: Test if a device contains this partition type
*
- * @test.dev_desc: Block device descriptor
+ * @test.desc: Block device descriptor
* @test.Return:
* 0 if the block device appears to contain this partition type,
* -ve if not
*/
- int (*test)(struct blk_desc *dev_desc);
+ int (*test)(struct blk_desc *desc);
};
/* Declare a new U-Boot partition 'driver' */
@@ -418,19 +476,18 @@ struct part_driver {
/**
* write_gpt_table() - Write the GUID Partition Table to disk
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @gpt_h: pointer to GPT header representation
* @gpt_e: pointer to GPT partition table entries
*
* Return: zero on success, otherwise error
*/
-int write_gpt_table(struct blk_desc *dev_desc,
- gpt_header *gpt_h, gpt_entry *gpt_e);
+int write_gpt_table(struct blk_desc *desc, gpt_header *gpt_h, gpt_entry *gpt_e);
/**
* gpt_fill_pte() - Fill the GPT partition table entry
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @gpt_h: GPT header representation
* @gpt_e: GPT partition table entries
* @partitions: list of partitions
@@ -438,55 +495,54 @@ int write_gpt_table(struct blk_desc *dev_desc,
*
* Return: zero on success
*/
-int gpt_fill_pte(struct blk_desc *dev_desc,
- gpt_header *gpt_h, gpt_entry *gpt_e,
+int gpt_fill_pte(struct blk_desc *desc, gpt_header *gpt_h, gpt_entry *gpt_e,
struct disk_partition *partitions, int parts);
/**
* gpt_fill_header() - Fill the GPT header
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @gpt_h: GPT header representation
* @str_guid: disk guid string representation
* @parts_count: number of partitions
*
* Return: error on str_guid conversion error
*/
-int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
- char *str_guid, int parts_count);
+int gpt_fill_header(struct blk_desc *desc, gpt_header *gpt_h, char *str_guid,
+ int parts_count);
/**
* gpt_restore() - Restore GPT partition table
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @str_disk_guid: disk GUID
* @partitions: list of partitions
* @parts_count: number of partitions
*
* Return: 0 on success
*/
-int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
+int gpt_restore(struct blk_desc *desc, char *str_disk_guid,
struct disk_partition *partitions, const int parts_count);
/**
* is_valid_gpt_buf() - Ensure that the Primary GPT information is valid
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @buf: buffer which contains the MBR and Primary GPT info
*
* Return: 0 on success, otherwise error
*/
-int is_valid_gpt_buf(struct blk_desc *dev_desc, void *buf);
+int is_valid_gpt_buf(struct blk_desc *desc, void *buf);
/**
* write_mbr_and_gpt_partitions() - write MBR, Primary GPT and Backup GPT
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @buf: buffer which contains the MBR and Primary GPT info
*
* Return: 0 on success, otherwise error
*/
-int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf);
+int write_mbr_and_gpt_partitions(struct blk_desc *desc, void *buf);
/**
* gpt_verify_headers() - Read and check CRC32 of the GPT's header
@@ -494,24 +550,24 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf);
*
* As a side effect if sets gpt_head and gpt_pte so they point to GPT data.
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @gpt_head: pointer to GPT header data read from medium
* @gpt_pte: pointer to GPT partition table enties read from medium
*
* Return: 0 on success, otherwise error
*/
-int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
+int gpt_verify_headers(struct blk_desc *desc, gpt_header *gpt_head,
gpt_entry **gpt_pte);
/**
* gpt_repair_headers() - Function to repair the GPT's header
* and partition table entries (PTE)
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
*
* Return: 0 on success, otherwise error
*/
-int gpt_repair_headers(struct blk_desc *dev_desc);
+int gpt_repair_headers(struct blk_desc *desc);
/**
* gpt_verify_partitions() - Function to check if partitions' name, start and
@@ -521,7 +577,7 @@ int gpt_repair_headers(struct blk_desc *dev_desc);
* provided in '$partitions' environment variable. Specificially, name, start
* and size of the partition is checked.
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @partitions: partition data read from '$partitions' env variable
* @parts: number of partitions read from '$partitions' env variable
* @gpt_head: pointer to GPT header data read from medium
@@ -529,7 +585,7 @@ int gpt_repair_headers(struct blk_desc *dev_desc);
*
* Return: 0 on success, otherwise error
*/
-int gpt_verify_partitions(struct blk_desc *dev_desc,
+int gpt_verify_partitions(struct blk_desc *desc,
struct disk_partition *partitions, int parts,
gpt_header *gpt_head, gpt_entry **gpt_pte);
@@ -540,12 +596,12 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
* This function reads the GUID string from a block device whose descriptor
* is provided.
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @guid: pre-allocated string in which to return the GUID
*
* Return: 0 on success, otherwise error
*/
-int get_disk_guid(struct blk_desc *dev_desc, char *guid);
+int get_disk_guid(struct blk_desc *desc, char *guid);
#endif
@@ -562,12 +618,12 @@ int is_valid_dos_buf(void *buf);
/**
* write_mbr_sector() - write DOS MBR
*
- * @dev_desc: block device descriptor
+ * @desc: block device descriptor
* @buf: buffer which contains the MBR
*
* Return: 0 on success, otherwise error
*/
-int write_mbr_sector(struct blk_desc *dev_desc, void *buf);
+int write_mbr_sector(struct blk_desc *desc, void *buf);
int write_mbr_partitions(struct blk_desc *dev,
struct disk_partition *p, int count, unsigned int disksig);
@@ -606,12 +662,24 @@ static inline struct part_driver *part_driver_get_first(void)
*/
int part_get_type_by_name(const char *name);
+/**
+ * part_get_bootable() - Find the first bootable partition
+ *
+ * @desc: Block-device descriptor
+ * @return first bootable partition, or 0 if there is none
+ */
+int part_get_bootable(struct blk_desc *desc);
+
#else
static inline int part_driver_get_count(void)
{ return 0; }
static inline struct part_driver *part_driver_get_first(void)
{ return NULL; }
+
+static inline bool part_get_bootable(struct blk_desc *desc)
+{ return false; }
+
#endif /* CONFIG_PARTITIONS */
#endif /* _PART_H */
diff --git a/include/part_efi.h b/include/part_efi.h
index c68529b4daf..59b7895b8a2 100644
--- a/include/part_efi.h
+++ b/include/part_efi.h
@@ -60,6 +60,20 @@
EFI_GUID( 0x3de21764, 0x95bd, 0x54bd, \
0xa5, 0xc3, 0x4a, 0xbe, 0x78, 0x6f, 0x38, 0xa8)
+/* Special ChromiumOS things */
+#define PARTITION_CROS_KERNEL \
+ EFI_GUID(0xfe3a2a5d, 0x4f32, 0x41a7, \
+ 0xb7, 0x25, 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09)
+#define PARTITION_CROS_ROOT \
+ EFI_GUID(0x3cb8e202, 0x3b7e, 0x47dd, \
+ 0x8a, 0x3c, 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec)
+#define PARTITION_CROS_FIRMWARE \
+ EFI_GUID(0xcab6e88e, 0xabf3, 0x4102, \
+ 0xa0, 0x7a, 0xd4, 0xbb, 0x9b, 0xe3, 0xc1, 0xd3)
+#define PARTITION_CROS_RESERVED \
+ EFI_GUID(0x2e0a753d, 0x9e48, 0x43b0, \
+ 0x83, 0x37, 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e)
+
/* linux/include/efi.h */
typedef u16 efi_char16_t;
diff --git a/include/uuid.h b/include/uuid.h
index 89b93e642b7..f5a941250f4 100644
--- a/include/uuid.h
+++ b/include/uuid.h
@@ -12,6 +12,51 @@
#include <linux/bitops.h>
+/*
+ * UUID - Universally Unique IDentifier - 128 bits unique number.
+ * There are 5 versions and one variant of UUID defined by RFC4122
+ * specification. A UUID contains a set of fields. The set varies
+ * depending on the version of the UUID, as shown below:
+ * - time, MAC address(v1),
+ * - user ID(v2),
+ * - MD5 of name or URL(v3),
+ * - random data(v4),
+ * - SHA-1 of name or URL(v5),
+ *
+ * Layout of UUID:
+ * timestamp - 60-bit: time_low, time_mid, time_hi_and_version
+ * version - 4 bit (bit 4 through 7 of the time_hi_and_version)
+ * clock seq - 14 bit: clock_seq_hi_and_reserved, clock_seq_low
+ * variant: - bit 6 and 7 of clock_seq_hi_and_reserved
+ * node - 48 bit
+ *
+ * source: https://www.ietf.org/rfc/rfc4122.txt
+ *
+ * UUID binary format (16 bytes):
+ *
+ * 4B-2B-2B-2B-6B (big endian - network byte order)
+ *
+ * UUID string is 36 length of characters (36 bytes):
+ *
+ * 0 9 14 19 24
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ * be be be be be
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a binary UUID, le means the field should be converted
+ * to little endian and be means it should be converted to big endian.
+ *
+ * UUID is also used as GUID (Globally Unique Identifier) with the same binary
+ * format but it differs in string format like below.
+ *
+ * GUID:
+ * 0 9 14 19 24
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ * le le le be be
+ *
+ * GUID is used e.g. in GPT (GUID Partition Table) as a partiions unique id.
+ */
+
/* This is structure is in big-endian */
struct uuid {
unsigned int time_low;
@@ -40,20 +85,78 @@ struct uuid {
#define UUID_VARIANT 0x1
int uuid_str_valid(const char *uuid);
+
+/*
+ * uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
+ *
+ * @param uuid_str - pointer to UUID or GUID string [37B] or GUID shorcut
+ * @param uuid_bin - pointer to allocated array for big endian output [16B]
+ * @str_format - UUID string format: 0 - UUID; 1 - GUID
+ * Return: 0 if OK, -EINVAL if the string is not a valid UUID
+ */
int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
int str_format);
+
+/*
+ * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
+ *
+ * @param uuid_bin: pointer to binary data of UUID (big endian) [16B]
+ * @param uuid_str: pointer to allocated array for output string [37B]
+ * @str_format: bit 0: 0 - UUID; 1 - GUID
+ * bit 1: 0 - lower case; 2 - upper case
+ */
void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
int str_format);
+
+/*
+ * uuid_guid_get_bin() - this function get GUID bin for string
+ *
+ * @param guid_str - pointer to partition type string
+ * @param guid_bin - pointer to allocated array for big endian output [16B]
+ */
int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
+
+/*
+ * uuid_guid_get_str() - this function get string for GUID.
+ *
+ * @param guid_bin - pointer to string with partition type guid [16B]
+ *
+ * Returns NULL if the type GUID is not known.
+ */
const char *uuid_guid_get_str(const unsigned char *guid_bin);
+
+/*
+ * gen_rand_uuid() - this function generates a random binary UUID version 4.
+ * In this version all fields beside 4 bits of version and
+ * 2 bits of variant are randomly generated.
+ *
+ * @param uuid_bin - pointer to allocated array [16B]. Output is in big endian.
+ */
void gen_rand_uuid(unsigned char *uuid_bin);
+
+/*
+ * gen_rand_uuid_str() - this function generates UUID v4 (random) in two string
+ * formats UUID or GUID.
+ *
+ * @param uuid_str - pointer to allocated array [37B].
+ * @param - uuid output type: UUID - 0, GUID - 1
+ */
void gen_rand_uuid_str(char *uuid_str, int str_format);
/**
* uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
* @uuid_str: pointer to UUID string
* @uuid_bin: pointer to allocated array for little endian output [16B]
+ *
+ * UUID string is 36 characters (36 bytes):
+ *
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a little endian binary UUID, the string fields are reversed.
+ *
* Return:
+ *
* uuid_bin filled with little endian UUID data
* On success 0 is returned. Otherwise, failure code.
*/
diff --git a/lib/uuid.c b/lib/uuid.c
index d0187007d0e..afb40bff507 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -7,6 +7,8 @@
* Abdellatif El Khlifi <[email protected]>
*/
+#define LOG_CATEGOT LOGC_CORE
+
#include <common.h>
#include <command.h>
#include <efi_api.h>
@@ -23,50 +25,6 @@
#include <dm/uclass.h>
#include <rng.h>
-/*
- * UUID - Universally Unique IDentifier - 128 bits unique number.
- * There are 5 versions and one variant of UUID defined by RFC4122
- * specification. A UUID contains a set of fields. The set varies
- * depending on the version of the UUID, as shown below:
- * - time, MAC address(v1),
- * - user ID(v2),
- * - MD5 of name or URL(v3),
- * - random data(v4),
- * - SHA-1 of name or URL(v5),
- *
- * Layout of UUID:
- * timestamp - 60-bit: time_low, time_mid, time_hi_and_version
- * version - 4 bit (bit 4 through 7 of the time_hi_and_version)
- * clock seq - 14 bit: clock_seq_hi_and_reserved, clock_seq_low
- * variant: - bit 6 and 7 of clock_seq_hi_and_reserved
- * node - 48 bit
- *
- * source: https://www.ietf.org/rfc/rfc4122.txt
- *
- * UUID binary format (16 bytes):
- *
- * 4B-2B-2B-2B-6B (big endian - network byte order)
- *
- * UUID string is 36 length of characters (36 bytes):
- *
- * 0 9 14 19 24
- * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- * be be be be be
- *
- * where x is a hexadecimal character. Fields are separated by '-'s.
- * When converting to a binary UUID, le means the field should be converted
- * to little endian and be means it should be converted to big endian.
- *
- * UUID is also used as GUID (Globally Unique Identifier) with the same binary
- * format but it differs in string format like below.
- *
- * GUID:
- * 0 9 14 19 24
- * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- * le le le be be
- *
- * GUID is used e.g. in GPT (GUID Partition Table) as a partiions unique id.
- */
int uuid_str_valid(const char *uuid)
{
int i, valid;
@@ -105,6 +63,10 @@ static const struct {
{"swap", PARTITION_LINUX_SWAP_GUID},
{"lvm", PARTITION_LINUX_LVM_GUID},
{"u-boot-env", PARTITION_U_BOOT_ENVIRONMENT},
+ {"cros-kern", PARTITION_CROS_KERNEL},
+ {"cros-root", PARTITION_CROS_ROOT},
+ {"cros-fw", PARTITION_CROS_FIRMWARE},
+ {"cros-rsrv", PARTITION_CROS_RESERVED},
#endif
#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{
@@ -269,12 +231,6 @@ static const struct {
#endif
};
-/*
- * uuid_guid_get_bin() - this function get GUID bin for string
- *
- * @param guid_str - pointer to partition type string
- * @param guid_bin - pointer to allocated array for big endian output [16B]
- */
int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin)
{
int i;
@@ -288,13 +244,6 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin)
return -ENODEV;
}
-/*
- * uuid_guid_get_str() - this function get string for GUID.
- *
- * @param guid_bin - pointer to string with partition type guid [16B]
- *
- * Returns NULL if the type GUID is not known.
- */
const char *uuid_guid_get_str(const unsigned char *guid_bin)
{
int i;
@@ -307,13 +256,6 @@ const char *uuid_guid_get_str(const unsigned char *guid_bin)
return NULL;
}
-/*
- * uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
- *
- * @param uuid_str - pointer to UUID or GUID string [37B] or GUID shorcut
- * @param uuid_bin - pointer to allocated array for big endian output [16B]
- * @str_format - UUID string format: 0 - UUID; 1 - GUID
- */
int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
int str_format)
{
@@ -322,6 +264,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
uint64_t tmp64;
if (!uuid_str_valid(uuid_str)) {
+ log_debug("not valid\n");
#ifdef CONFIG_PARTITION_TYPE_GUID
if (!uuid_guid_get_bin(uuid_str, uuid_bin))
return 0;
@@ -358,23 +301,6 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
return 0;
}
-/**
- * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
- * @uuid_str: pointer to UUID string
- * @uuid_bin: pointer to allocated array for little endian output [16B]
- *
- * UUID string is 36 characters (36 bytes):
- *
- * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- *
- * where x is a hexadecimal character. Fields are separated by '-'s.
- * When converting to a little endian binary UUID, the string fields are reversed.
- *
- * Return:
- *
- * uuid_bin filled with little endian UUID data
- * On success 0 is returned. Otherwise, failure code.
- */
int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
{
u16 tmp16;
@@ -402,14 +328,6 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
return 0;
}
-/*
- * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
- *
- * @param uuid_bin: pointer to binary data of UUID (big endian) [16B]
- * @param uuid_str: pointer to allocated array for output string [37B]
- * @str_format: bit 0: 0 - UUID; 1 - GUID
- * bit 1: 0 - lower case; 2 - upper case
- */
void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
int str_format)
{
@@ -449,13 +367,6 @@ void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
}
}
-/*
- * gen_rand_uuid() - this function generates a random binary UUID version 4.
- * In this version all fields beside 4 bits of version and
- * 2 bits of variant are randomly generated.
- *
- * @param uuid_bin - pointer to allocated array [16B]. Output is in big endian.
-*/
#if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID)
void gen_rand_uuid(unsigned char *uuid_bin)
{
@@ -493,13 +404,6 @@ void gen_rand_uuid(unsigned char *uuid_bin)
memcpy(uuid_bin, uuid, 16);
}
-/*
- * gen_rand_uuid_str() - this function generates UUID v4 (random) in two string
- * formats UUID or GUID.
- *
- * @param uuid_str - pointer to allocated array [37B].
- * @param - uuid output type: UUID - 0, GUID - 1
- */
void gen_rand_uuid_str(char *uuid_str, int str_format)
{
unsigned char uuid_bin[UUID_BIN_LEN];
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 8a4e090e9bc..1ff2320c036 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -27,6 +27,7 @@
DECLARE_GLOBAL_DATA_PTR;
+extern U_BOOT_DRIVER(bootmeth_cros);
extern U_BOOT_DRIVER(bootmeth_script);
static int inject_response(struct unit_test_state *uts)
@@ -167,21 +168,22 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts)
ut_assert_nextline("Seq Method State Uclass Part Name Filename");
ut_assert_nextlinen("---");
ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':");
- ut_assert_nextline(" 0 extlinux media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_nextline(" 0 extlinux media mmc 0 mmc2.bootdev.whole ");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported");
- ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole ");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported");
ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':");
- ut_assert_nextline(" 2 extlinux media mmc 0 mmc1.bootdev.whole <NULL>");
+ ut_assert_nextline(" 2 extlinux media mmc 0 mmc1.bootdev.whole ");
ut_assert_nextline(" ** No partition found, err=-2: No such file or directory");
- ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole <NULL>");
+ ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole ");
ut_assert_nextline(" ** No partition found, err=-2: No such file or directory");
ut_assert_nextline(" 4 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 efi/boot/bootsbox.efi");
ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
- ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole <NULL>");
+ ut_assert_skip_to_line(
+ " 3f efi media mmc 0 mmc0.bootdev.whole ");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported");
ut_assert_nextline("No more bootdevs");
ut_assert_nextlinen("---");
@@ -192,10 +194,11 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts)
ut_assert_nextline("Showing all bootflows");
ut_assert_nextline("Seq Method State Uclass Part Name Filename");
ut_assert_nextlinen("---");
- ut_assert_nextline(" 0 extlinux media mmc 0 mmc2.bootdev.whole <NULL>");
- ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole <NULL>");
- ut_assert_skip_to_line(" 4 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
- ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole <NULL>");
+ ut_assert_nextline(" 0 extlinux media mmc 0 mmc2.bootdev.whole ");
+ ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole ");
+ ut_assert_skip_to_line(
+ " 4 extlinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole ");
ut_assert_nextlinen("---");
ut_assert_nextline("(64 bootflows, 1 valid)");
ut_assert_console_end();
@@ -384,7 +387,7 @@ static int bootflow_system(struct unit_test_state *uts)
console_record_reset_enable();
ut_assertok(run_command("bootflow scan -lH", 0));
ut_assert_skip_to_line(
- " 0 efi_mgr ready (none) 0 <NULL> <NULL>");
+ " 0 efi_mgr ready (none) 0 <NULL> ");
ut_assert_skip_to_line("No more bootdevs");
ut_assert_skip_to_line("(2 bootflows, 2 valid)");
ut_assert_console_end();
@@ -506,21 +509,25 @@ static int bootflow_cmd_boot(struct unit_test_state *uts)
BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
/**
- * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
+ * prep_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
*
* @uts: Unit test state
+ * @mmc_dev: MMC device to use, e.g. "mmc4"
* Returns 0 on success, -ve on failure
*/
-static int prep_mmc4_bootdev(struct unit_test_state *uts)
+static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
+ bool bind_cros)
{
- static const char *order[] = {"mmc2", "mmc1", "mmc4", NULL};
+ const char *order[] = {"mmc2", "mmc1", mmc_dev, NULL};
struct udevice *dev, *bootstd;
struct bootstd_priv *std;
const char **old_order;
- ofnode node;
+ ofnode root, node;
/* Enable the mmc4 node since we need a second bootflow */
- node = ofnode_path("/mmc4");
+ root = oftree_root(oftree_default());
+ node = ofnode_find_subnode(root, mmc_dev);
+ ut_assert(ofnode_valid(node));
ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
/* Enable the script bootmeth too */
@@ -528,7 +535,14 @@ static int prep_mmc4_bootdev(struct unit_test_state *uts)
ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_script),
"bootmeth_script", 0, ofnode_null(), &dev));
- /* Change the order to include mmc4 */
+ /* Enable the cros bootmeth if needed */
+ if (bind_cros) {
+ ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+ ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_cros),
+ "cros", 0, ofnode_null(), &dev));
+ }
+
+ /* Change the order to include the device */
std = dev_get_priv(bootstd);
old_order = std->bootdev_order;
std->bootdev_order = order;
@@ -543,6 +557,19 @@ static int prep_mmc4_bootdev(struct unit_test_state *uts)
return 0;
}
+/**
+ * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
+ *
+ * @uts: Unit test state
+ * Returns 0 on success, -ve on failure
+ */
+static int prep_mmc4_bootdev(struct unit_test_state *uts)
+{
+ ut_assertok(prep_mmc_bootdev(uts, "mmc4", false));
+
+ return 0;
+}
+
/* Check 'bootflow menu' to select a bootflow */
static int bootflow_cmd_menu(struct unit_test_state *uts)
{
@@ -945,3 +972,24 @@ static int bootflow_cmdline(struct unit_test_state *uts)
return 0;
}
BOOTSTD_TEST(bootflow_cmdline, 0);
+
+/* Test ChromiumOS bootmeth */
+static int bootflow_cros(struct unit_test_state *uts)
+{
+ ut_assertok(prep_mmc_bootdev(uts, "mmc5", true));
+ ut_assertok(run_command("bootflow list", 0));
+
+ ut_assert_nextlinen("Showing all");
+ ut_assert_nextlinen("Seq");
+ ut_assert_nextlinen("---");
+ ut_assert_nextlinen(" 0 extlinux");
+ ut_assert_nextlinen(" 1 cros ready mmc 2 mmc5.bootdev.part_2 ");
+ ut_assert_nextlinen(" 2 cros ready mmc 4 mmc5.bootdev.part_4 ");
+ ut_assert_nextlinen("---");
+ ut_assert_skip_to_line("(3 bootflows, 3 valid)");
+
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cros, 0);
diff --git a/test/dm/host.c b/test/dm/host.c
index 355ba7770af..85f21f9839e 100644
--- a/test/dm/host.c
+++ b/test/dm/host.c
@@ -8,6 +8,7 @@
#include <blk.h>
#include <dm.h>
#include <fs.h>
+#include <os.h>
#include <sandbox_host.h>
#include <asm/test.h>
#include <dm/device-internal.h>
@@ -15,9 +16,6 @@
#include <test/test.h>
#include <test/ut.h>
-static const char filename[] = "2MB.ext2.img";
-static const char filename2[] = "1MB.fat32.img";
-
/* Basic test of host interface */
static int dm_test_host(struct unit_test_state *uts)
{
@@ -25,6 +23,7 @@ static int dm_test_host(struct unit_test_state *uts)
struct udevice *dev, *part, *chk, *blk;
struct host_sb_plat *plat;
struct blk_desc *desc;
+ char fname[256];
ulong mem_start;
loff_t actwrite;
@@ -40,13 +39,15 @@ static int dm_test_host(struct unit_test_state *uts)
ut_assert(label != plat->label);
ut_asserteq(0, plat->fd);
- /* Attach a file created in test_host.py */
- ut_assertok(host_attach_file(dev, filename));
+ /* Attach a file created in test_ut_dm_init */
+ ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+
+ ut_assertok(host_attach_file(dev, fname));
ut_assertok(uclass_first_device_err(UCLASS_HOST, &chk));
ut_asserteq_ptr(chk, dev);
- ut_asserteq_str(filename, plat->filename);
- ut_assert(filename != plat->filename);
+ ut_asserteq_str(fname, plat->filename);
+ ut_assert(fname != plat->filename);
ut_assert(plat->fd != 0);
/* Get the block device */
@@ -79,12 +80,14 @@ static int dm_test_host_dup(struct unit_test_state *uts)
{
static char label[] = "test";
struct udevice *dev, *chk;
+ char fname[256];
ut_asserteq(0, uclass_id_count(UCLASS_HOST));
ut_assertok(host_create_device(label, true, &dev));
- /* Attach a file created in test_host.py */
- ut_assertok(host_attach_file(dev, filename));
+ /* Attach a file created in test_ut_dm_init */
+ ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+ ut_assertok(host_attach_file(dev, fname));
ut_assertok(uclass_first_device_err(UCLASS_HOST, &chk));
ut_asserteq_ptr(chk, dev);
ut_asserteq(1, uclass_id_count(UCLASS_HOST));
@@ -92,8 +95,10 @@ static int dm_test_host_dup(struct unit_test_state *uts)
/* Create another device with the same label (should remove old one) */
ut_assertok(host_create_device(label, true, &dev));
- /* Attach a different file created in test_host.py */
- ut_assertok(host_attach_file(dev, filename2));
+ /* Attach a different file created in test_ut_dm_init */
+ ut_assertok(os_persistent_file(fname, sizeof(fname), "1MB.fat32.img"));
+ ut_assertok(host_attach_file(dev, fname));
+
ut_assertok(uclass_first_device_err(UCLASS_HOST, &chk));
ut_asserteq_ptr(chk, dev);
@@ -109,6 +114,7 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
{
struct udevice *dev, *blk;
struct blk_desc *desc;
+ char fname[256];
console_record_reset();
@@ -117,7 +123,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assert_nextline("dev blocks label path");
ut_assert_console_end();
- ut_assertok(run_commandf("host bind -r test2 %s", filename));
+ ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+ ut_assertok(run_commandf("host bind -r test2 %s", fname));
/* Check the -r flag worked */
ut_assertok(uclass_first_device_err(UCLASS_HOST, &dev));
@@ -127,10 +134,11 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assertok(run_command("host info", 0));
ut_assert_nextline("dev blocks label path");
- ut_assert_nextline(" 0 4096 test2 2MB.ext2.img");
+ ut_assert_nextlinen(" 0 4096 test2");
ut_assert_console_end();
- ut_assertok(run_commandf("host bind fat %s", filename2));
+ ut_assertok(os_persistent_file(fname, sizeof(fname), "1MB.fat32.img"));
+ ut_assertok(run_commandf("host bind fat %s", fname));
/* Check it is not removable (no '-r') */
ut_assertok(uclass_next_device_err(&dev));
@@ -140,8 +148,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assertok(run_command("host info", 0));
ut_assert_nextline("dev blocks label path");
- ut_assert_nextline(" 0 4096 test2 2MB.ext2.img");
- ut_assert_nextline(" 1 2048 fat 1MB.fat32.img");
+ ut_assert_nextlinen(" 0 4096 test2");
+ ut_assert_nextlinen(" 1 2048 fat");
ut_assert_console_end();
ut_asserteq(1, run_command("host info test", 0));
@@ -150,7 +158,7 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assertok(run_command("host info fat", 0));
ut_assert_nextline("dev blocks label path");
- ut_assert_nextline(" 1 2048 fat 1MB.fat32.img");
+ ut_assert_nextlinen(" 1 2048 fat");
ut_assert_console_end();
/* check 'host dev' */
@@ -187,7 +195,7 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assertok(run_command("host info", 0));
ut_assert_nextline("dev blocks label path");
- ut_assert_nextline(" 1 2048 fat 1MB.fat32.img");
+ ut_assert_nextlinen(" 1 2048 fat");
ut_assert_console_end();
return 0;
diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py
index 17151bcd08e..9882ddb1daa 100644
--- a/test/py/tests/fs_helper.py
+++ b/test/py/tests/fs_helper.py
@@ -9,7 +9,7 @@ import re
import os
from subprocess import call, check_call, check_output, CalledProcessError
-def mk_fs(config, fs_type, size, prefix, use_src_dir=False):
+def mk_fs(config, fs_type, size, prefix):
"""Create a file system volume
Args:
@@ -17,14 +17,12 @@ def mk_fs(config, fs_type, size, prefix, use_src_dir=False):
fs_type (str): File system type, e.g. 'ext4'
size (int): Size of file system in bytes
prefix (str): Prefix string of volume's file name
- use_src_dir (bool): true to put the file in the source directory
Raises:
CalledProcessError: if any error occurs when creating the filesystem
"""
fs_img = f'{prefix}.{fs_type}.img'
- fs_img = os.path.join(config.source_dir if use_src_dir
- else config.persistent_data_dir, fs_img)
+ fs_img = os.path.join(config.persistent_data_dir, fs_img)
if fs_type == 'fat16':
mkfs_opt = '-F 16'
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 6a59c306322..82932a662bf 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+import collections
import getpass
import gzip
import os
@@ -282,6 +283,146 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
copy_prepared_image(cons, mmc_dev, fname)
+def setup_cros_image(cons):
+ """Create a 20MB disk image with ChromiumOS partitions"""
+ Partition = collections.namedtuple('part', 'start,size,name')
+ parts = {}
+ disk_data = None
+
+ def pack_kernel(cons, arch, kern, dummy):
+ """Pack a kernel containing some fake data
+
+ Args:
+ cons (ConsoleBase): Console to use
+ arch (str): Architecture to use ('x86' or 'arm')
+ kern (str): Filename containing kernel
+ dummy (str): Dummy filename to use for config and bootloader
+
+ Return:
+ bytes: Packed-kernel data
+ """
+ kern_part = os.path.join(cons.config.result_dir, 'kern-part-{arch}.bin')
+ u_boot_utils.run_and_log(
+ cons,
+ f'futility vbutil_kernel --pack {kern_part} '
+ '--keyblock doc/chromium/files/devkeys/kernel.keyblock '
+ '--signprivate doc/chromium/files/devkeys/kernel_data_key.vbprivk '
+ f'--version 1 --config {dummy} --bootloader {dummy} '
+ f'--vmlinuz {kern}')
+
+ with open(kern_part, 'rb') as inf:
+ kern_part_data = inf.read()
+ return kern_part_data
+
+ def set_part_data(partnum, data):
+ """Set the contents of a disk partition
+
+ This updates disk_data by putting data in the right place
+
+ Args:
+ partnum (int): Partition number to set
+ data (bytes): Data for that partition
+ """
+ nonlocal disk_data
+
+ start = parts[partnum].start * sect_size
+ disk_data = disk_data[:start] + data + disk_data[start + len(data):]
+
+ mmc_dev = 5
+ fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
+ u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname)
+ #mnt = os.path.join(cons.config.persistent_data_dir, 'mnt')
+ #mkdir_cond(mnt)
+ u_boot_utils.run_and_log(cons, f'cgpt create {fname}')
+
+ uuid_state = 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7'
+ uuid_kern = 'fe3a2a5d-4f32-41a7-b725-accc3285a309'
+ uuid_root = '3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec'
+ uuid_rwfw = 'cab6e88e-abf3-4102-a07a-d4bb9be3c1d3'
+ uuid_reserved = '2e0a753d-9e48-43b0-8337-b15192cb1b5e'
+ uuid_efi = 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b'
+
+ ptr = 40
+
+ # Number of sectors in 1MB
+ sect_size = 512
+ sect_1mb = (1 << 20) // sect_size
+
+ required_parts = [
+ {'num': 0xb, 'label':'RWFW', 'type': uuid_rwfw, 'size': '1'},
+ {'num': 6, 'label':'KERN_C', 'type': uuid_kern, 'size': '1'},
+ {'num': 7, 'label':'ROOT_C', 'type': uuid_root, 'size': '1'},
+ {'num': 9, 'label':'reserved', 'type': uuid_reserved, 'size': '1'},
+ {'num': 0xa, 'label':'reserved', 'type': uuid_reserved, 'size': '1'},
+
+ {'num': 2, 'label':'KERN_A', 'type': uuid_kern, 'size': '1M'},
+ {'num': 4, 'label':'KERN_B', 'type': uuid_kern, 'size': '1M'},
+
+ {'num': 8, 'label':'OEM', 'type': uuid_state, 'size': '1M'},
+ {'num': 0xc, 'label':'EFI-SYSTEM', 'type': uuid_efi, 'size': '1M'},
+
+ {'num': 5, 'label':'ROOT_B', 'type': uuid_root, 'size': '1'},
+ {'num': 3, 'label':'ROOT_A', 'type': uuid_root, 'size': '1'},
+ {'num': 1, 'label':'STATE', 'type': uuid_state, 'size': '1M'},
+ ]
+
+ for part in required_parts:
+ size_str = part['size']
+ if 'M' in size_str:
+ size = int(size_str[:-1]) * sect_1mb
+ else:
+ size = int(size_str)
+ u_boot_utils.run_and_log(
+ cons,
+ f"cgpt add -i {part['num']} -b {ptr} -s {size} -t {part['type']} {fname}")
+ ptr += size
+
+ u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}')
+ out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}')
+ '''We expect something like this:
+ 8239 2048 1 Basic data
+ 45 2048 2 ChromeOS kernel
+ 8238 1 3 ChromeOS rootfs
+ 2093 2048 4 ChromeOS kernel
+ 8237 1 5 ChromeOS rootfs
+ 41 1 6 ChromeOS kernel
+ 42 1 7 ChromeOS rootfs
+ 4141 2048 8 Basic data
+ 43 1 9 ChromeOS reserved
+ 44 1 10 ChromeOS reserved
+ 40 1 11 ChromeOS firmware
+ 6189 2048 12 EFI System Partition
+ '''
+
+ # Create a dict (indexed by partition number) containing the above info
+ for line in out.splitlines():
+ start, size, num, name = line.split(maxsplit=3)
+ parts[int(num)] = Partition(int(start), int(size), name)
+
+ dummy = os.path.join(cons.config.result_dir, 'dummy.txt')
+ with open(dummy, 'wb') as outf:
+ outf.write(b'dummy\n')
+
+ # For now we just use dummy kernels. This limits testing to just detecting
+ # a signed kernel. We could add support for the x86 data structures so that
+ # testing could cover getting the cmdline, setup.bin and other pieces.
+ kern = os.path.join(cons.config.result_dir, 'kern.bin')
+ with open(kern, 'wb') as outf:
+ outf.write(b'kernel\n')
+
+ with open(fname, 'rb') as inf:
+ disk_data = inf.read()
+
+ # put x86 kernel in partition 2 and arm one in partition 4
+ set_part_data(2, pack_kernel(cons, 'x86', kern, dummy))
+ set_part_data(4, pack_kernel(cons, 'arm', kern, dummy))
+
+ with open(fname, 'wb') as outf:
+ outf.write(disk_data)
+
+ return fname
+
+
def setup_cedit_file(cons):
infname = os.path.join(cons.config.source_dir,
'test/boot/files/expo_layout.dts')
@@ -319,10 +460,8 @@ def test_ut_dm_init(u_boot_console):
u_boot_utils.run_and_log(
u_boot_console, f'sfdisk {fn}', stdin=b'type=83')
- fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB',
- use_src_dir=True)
- fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB',
- use_src_dir=True)
+ fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB')
+ fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB')
@pytest.mark.buildconfigspec('cmd_bootflow')
def test_ut_dm_init_bootstd(u_boot_console):
@@ -331,6 +470,7 @@ def test_ut_dm_init_bootstd(u_boot_console):
setup_bootflow_image(u_boot_console)
setup_bootmenu_image(u_boot_console)
setup_cedit_file(u_boot_console)
+ setup_cros_image(u_boot_console)
# Restart so that the new mmc1.img is picked up
u_boot_console.restart_uboot()
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index b05001194e4..79c7c11a110 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -499,7 +499,7 @@ class Toolchains:
if arch == 'aarch64':
arch = 'arm64'
base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
- versions = ['13.1.0', '12.2.0']
+ versions = ['13.2.0', '12.2.0']
links = []
for version in versions:
url = '%s/%s/%s/' % (base, arch, version)
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 3d2b64a355f..279b3a3504c 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -2,7 +2,7 @@
# This Dockerfile is used to build an image containing basic stuff to be used
# to build U-Boot and run our test suites.
-FROM ubuntu:jammy-20230624
+FROM ubuntu:jammy-20230804
MAINTAINER Tom Rini <[email protected]>
LABEL Description=" This image is for building U-Boot inside a container"
@@ -14,19 +14,19 @@ RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main | tee /etc/apt/sources.list.d/llvm.list
-# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.1.0
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
-RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
+# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
# Manually install other toolchains
RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz
@@ -39,6 +39,7 @@ RUN apt-get update && apt-get install -y \
binutils-dev \
bison \
build-essential \
+ cgpt \
clang-16 \
coreutils \
cpio \
@@ -115,6 +116,8 @@ RUN apt-get update && apt-get install -y \
util-linux \
uuid-dev \
virtualenv \
+ vboot-kernel-utils \
+ vboot-utils \
xxd \
zip \
&& rm -rf /var/lib/apt/lists/*
@@ -134,11 +137,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
mkdir -p /opt/grub && \
./configure --target=aarch64 --with-platform=efi \
CC=gcc \
- TARGET_CC=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
- TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
- TARGET_STRIP=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
- TARGET_NM=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
- TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
+ TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
+ TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
+ TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
+ TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
+ TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
make && \
./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
@@ -148,11 +151,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
make clean && \
./configure --target=arm --with-platform=efi \
CC=gcc \
- TARGET_CC=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
- TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
- TARGET_STRIP=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
- TARGET_NM=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
- TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
+ TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
+ TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
+ TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
+ TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
+ TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
make && \
./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
@@ -162,11 +165,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
make clean && \
./configure --target=riscv64 --with-platform=efi \
CC=gcc \
- TARGET_CC=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
- TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
- TARGET_STRIP=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
- TARGET_NM=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
- TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
+ TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
+ TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
+ TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
+ TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
+ TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
make && \
./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
@@ -277,7 +280,7 @@ RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
# Create the buildman config file
RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
-RUN /bin/echo -e "kernelorg = /opt/gcc-13.1.0-nolibc/*" >> ~/.buildman
+RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman