- char *boot_device = NULL;
- char *ep;
- int dev, part = 0;
- ulong addr, cnt;
- disk_partition_t info;
- image_header_t *hdr;
- int rcode = 0;
-#if defined(CONFIG_FIT)
- const void *fit_hdr = NULL;
-#endif
-
- show_boot_progress (41);
- switch (argc) {
- case 1:
- addr = CONFIG_SYS_LOAD_ADDR;
- boot_device = getenv ("bootdevice");
- break;
- case 2:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = getenv ("bootdevice");
- break;
- case 3:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = argv[2];
- break;
- default:
- show_boot_progress (-42);
- return cmd_usage(cmdtp);
- }
- show_boot_progress (42);
-
- if (!boot_device) {
- puts ("\n** No boot device **\n");
- show_boot_progress (-43);
- return 1;
- }
- show_boot_progress (43);
-
- dev = simple_strtoul(boot_device, &ep, 16);
-
- if (ide_dev_desc[dev].type==DEV_TYPE_UNKNOWN) {
- printf ("\n** Device %d not available\n", dev);
- show_boot_progress (-44);
- return 1;
- }
- show_boot_progress (44);
-
- if (*ep) {
- if (*ep != ':') {
- puts ("\n** Invalid boot device, use `dev[:part]' **\n");
- show_boot_progress (-45);
- return 1;
- }
- part = simple_strtoul(++ep, NULL, 16);
- }
- show_boot_progress (45);
- if (get_partition_info (&ide_dev_desc[dev], part, &info)) {
- show_boot_progress (-46);
- return 1;
- }
- show_boot_progress (46);
- if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
- (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
- printf ("\n** Invalid partition type \"%.32s\""
- " (expect \"" BOOT_PART_TYPE "\")\n",
- info.type);
- show_boot_progress (-47);
- return 1;
- }
- show_boot_progress (47);
-
- printf ("\nLoading from IDE device %d, partition %d: "
- "Name: %.32s Type: %.32s\n",
- dev, part, info.name, info.type);
-
- debug ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
- info.start, info.size, info.blksz);
-
- if (ide_dev_desc[dev].block_read (dev, info.start, 1, (ulong *)addr) != 1) {
- printf ("** Read error on %d:%d\n", dev, part);
- show_boot_progress (-48);
- return 1;
- }
- show_boot_progress (48);
-
- switch (genimg_get_format ((void *)addr)) {
- case IMAGE_FORMAT_LEGACY:
- hdr = (image_header_t *)addr;