#endif
#if (defined(CONFIG_CMD_IDE) || \
+ defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
#endif
#if defined(CONFIG_SYSTEMACE)
{ .name = "ace", .get_dev = systemace_get_dev, },
+#endif
+#if defined(CONFIG_CMD_MG_DISK)
+ { .name = "mgd", .get_dev = mg_disk_get_dev, },
#endif
{ },
};
{
const struct block_drvr *drvr = block_drvr;
block_dev_desc_t* (*reloc_get_dev)(int dev);
+ char *name;
- while (drvr->name) {
- reloc_get_dev = drvr->get_dev + gd->reloc_off;
- if (strncmp(ifname, drvr->name, strlen(drvr->name)) == 0)
+ name = drvr->name;
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+ name += gd->reloc_off;
+#endif
+ while (name) {
+ name = drvr->name;
+ reloc_get_dev = drvr->get_dev;
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+ name += gd->reloc_off;
+ reloc_get_dev += gd->reloc_off;
+#endif
+ if (strncmp(ifname, name, strlen(name)) == 0)
return reloc_get_dev(dev);
drvr++;
}
#endif
#if (defined(CONFIG_CMD_IDE) || \
+ defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
/*
* reports device info to the user
*/
-void dev_print (block_dev_desc_t *dev_desc)
-{
+
#ifdef CONFIG_LBA48
- uint64_t lba512; /* number of blocks if 512bytes block size */
+typedef uint64_t lba512_t;
#else
- lbaint_t lba512;
+typedef lbaint_t lba512_t;
#endif
+/*
+ * Overflowless variant of (block_count * mul_by / div_by)
+ * when div_by > mul_by
+ */
+static lba512_t lba512_muldiv (lba512_t block_count, lba512_t mul_by, lba512_t div_by)
+{
+ lba512_t bc_quot, bc_rem;
+
+ /* x * m / d == x / d * m + (x % d) * m / d */
+ bc_quot = block_count / div_by;
+ bc_rem = block_count - div_by * bc_quot;
+ return bc_quot * mul_by + (bc_rem * mul_by) / div_by;
+}
+
+void dev_print (block_dev_desc_t *dev_desc)
+{
+ lba512_t lba512; /* number of blocks if 512bytes block size */
+
+ if (dev_desc->type == DEV_TYPE_UNKNOWN) {
+ puts ("not available\n");
+ return;
+ }
+
switch (dev_desc->if_type) {
case IF_TYPE_SCSI:
printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
lba = dev_desc->lba;
lba512 = (lba * (dev_desc->blksz/512));
- mb = (10 * lba512) / 2048; /* 2048 = (1024 * 1024) / 512 MB */
/* round to 1 digit */
+ mb = lba512_muldiv(lba512, 10, 2048); /* 2048 = (1024 * 1024) / 512 MB */
+
mb_quot = mb / 10;
mb_rem = mb - (10 * mb_quot);
if (dev_desc->lba48)
printf (" Supports 48-bit addressing\n");
#endif
-#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF)
+#if defined(CONFIG_SYS_64BIT_LBA)
printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%Ld x %ld)\n",
mb_quot, mb_rem,
gb_quot, gb_rem,
#endif
#if (defined(CONFIG_CMD_IDE) || \
+ defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
defined(CONFIG_MMC) || \
- defined(CONFIG_SYSTEMACE) )
+ defined(CONFIG_SYSTEMACE) )
#if defined(CONFIG_MAC_PARTITION) || \
defined(CONFIG_DOS_PARTITION) || \
case IF_TYPE_DOC:
puts ("DOC");
break;
+ case IF_TYPE_MMC:
+ puts ("MMC");
+ break;
default:
puts ("UNKNOWN");
break;