summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootefi.c10
-rw-r--r--cmd/gpt.c13
-rw-r--r--cmd/ubi.c38
-rw-r--r--cmd/usb.c3
4 files changed, 47 insertions, 17 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index d3a2331870..216906527f 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -206,9 +206,13 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
#endif
/* Call our payload! */
-#ifdef DEBUG_EFI
- printf("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
-#endif
+ debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
+
+ if (setjmp(&loaded_image_info.exit_jmp)) {
+ efi_status_t status = loaded_image_info.exit_status;
+ return status == EFI_SUCCESS ? 0 : -EINVAL;
+ }
+
return entry(&loaded_image_info, &systab);
}
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 8ffaef30f5..3d9706b679 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -181,6 +181,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
disk_partition_t *parts;
int errno = 0;
uint64_t size_ll, start_ll;
+ lbaint_t offset = 0;
debug("%s: lba num: 0x%x %d\n", __func__,
(unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
@@ -296,8 +297,14 @@ static int set_gpt_info(struct blk_desc *dev_desc,
}
if (extract_env(val, &p))
p = val;
- size_ll = ustrtoull(p, &p, 0);
- parts[i].size = lldiv(size_ll, dev_desc->blksz);
+ if ((strcmp(p, "-") == 0)) {
+ /* remove first usable lba and last block */
+ parts[i].size = dev_desc->lba - 34 - 1 - offset;
+ } else {
+ size_ll = ustrtoull(p, &p, 0);
+ parts[i].size = lldiv(size_ll, dev_desc->blksz);
+ }
+
free(val);
/* start address */
@@ -310,6 +317,8 @@ static int set_gpt_info(struct blk_desc *dev_desc,
free(val);
}
+ offset += parts[i].size + parts[i].start;
+
/* bootable */
if (found_key(tok, "bootable"))
parts[i].bootable = 1;
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 753a4dba3d..4a92d840b6 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -443,14 +443,8 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev,
return 0;
}
-int ubi_part(char *part_name, const char *vid_header_offset)
+int ubi_detach(void)
{
- int err = 0;
- char mtd_dev[16];
- struct mtd_device *dev;
- struct part_info *part;
- u8 pnum;
-
if (mtdparts_init() != 0) {
printf("Error initializing mtdparts!\n");
return 1;
@@ -466,17 +460,28 @@ int ubi_part(char *part_name, const char *vid_header_offset)
cmd_ubifs_umount();
#endif
- /* todo: get dev number for NAND... */
- ubi_dev.nr = 0;
-
/*
* Call ubi_exit() before re-initializing the UBI subsystem
*/
if (ubi_initialized) {
ubi_exit();
del_mtd_partitions(ubi_dev.mtd_info);
+ ubi_initialized = 0;
}
+ ubi_dev.selected = 0;
+ return 0;
+}
+
+int ubi_part(char *part_name, const char *vid_header_offset)
+{
+ int err = 0;
+ char mtd_dev[16];
+ struct mtd_device *dev;
+ struct part_info *part;
+ u8 pnum;
+
+ ubi_detach();
/*
* Search the mtd device number where this partition
* is located
@@ -517,6 +522,15 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc < 2)
return CMD_RET_USAGE;
+
+ if (strcmp(argv[1], "detach") == 0) {
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ return ubi_detach();
+ }
+
+
if (strcmp(argv[1], "part") == 0) {
const char *vid_header_offset = NULL;
@@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
ubi, 6, 1, do_ubi,
"ubi commands",
- "part [part] [offset]\n"
+ "detach"
+ " - detach ubi from a mtd partition\n"
+ "ubi part [part] [offset]\n"
" - Show or set current partition (with optional VID"
" header offset)\n"
"ubi info [l[ayout]]"
diff --git a/cmd/usb.c b/cmd/usb.c
index b83d3233b7..58d9db29d7 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -800,7 +800,8 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf("\nUSB device %d: ", dev);
stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, dev);
- if (stor_dev == NULL) {
+ if ((stor_dev == NULL) ||
+ (stor_dev->if_type == IF_TYPE_UNKNOWN)) {
printf("unknown device\n");
return 1;
}
OpenPOWER on IntegriCloud