#include <common.h>
#include <command.h>
#include <ide.h>
-#include <cmd_disk.h>
#include "part_dos.h"
-#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)) && defined(CONFIG_DOS_PARTITION)
+#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)
/* Convert char[4] in little endian format to the host format integer
*/
(is_extended (p->sys_ind) ? " Extd" : ""));
}
+static int test_block_type(unsigned char *buffer)
+{
+ if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
+ (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
+ return (-1);
+ } /* no DOS Signature at all */
+ if(strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0)
+ return DOS_PBR; /* is PBR */
+ return DOS_MBR; /* Is MBR */
+}
int test_part_dos (block_dev_desc_t *dev_desc)
if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) ||
(buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
- return (-1);
+ return (-1);
}
return (0);
}
dev_desc->dev, ext_part_sector);
return;
}
- if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
- buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
+ i=test_block_type(buffer);
+ if(i==-1) {
printf ("bad MBR sector signature 0x%02x%02x\n",
buffer[DOS_PART_MAGIC_OFFSET],
buffer[DOS_PART_MAGIC_OFFSET + 1]);
return;
}
-
+ if(i==DOS_PBR) {
+ printf (" 1\t\t 0\t%10ld\t%2x\n",
+ dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
+ return;
+ }
/* Print all primary/logical partitions */
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
for (i = 0; i < 4; i++, pt++) {
/*
- * fdisk does not show the extended partitions that
+ * fdisk does not show the extended partitions that
* are not in the MBR
*/
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
for (i = 0; i < 4; i++, pt++) {
/*
- * fdisk does not show the extended partitions that
- * are not in the MBR
+ * fdisk does not show the extended partitions that
+ * are not in the MBR
*/
- if (pt->sys_ind != 0 && part_num == which_part) {
+ if (((pt->boot_ind & ~0x80) == 0) &&
+ (pt->sys_ind != 0) &&
+ (part_num == which_part) &&
+ (is_extended(pt->sys_ind) == 0)) {
info->blksz = 512;
info->start = ext_part_sector + le32_to_int (pt->start4);
info->size = le32_to_int (pt->size4);
switch(dev_desc->if_type) {
case IF_TYPE_IDE:
+ case IF_TYPE_SATA:
case IF_TYPE_ATAPI:
- sprintf (info->name, "hd%c%d\n", 'a' + dev_desc->dev, part_num);
+ sprintf ((char *)info->name, "hd%c%d",
+ 'a' + dev_desc->dev, part_num);
break;
case IF_TYPE_SCSI:
- sprintf (info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
+ sprintf ((char *)info->name, "sd%c%d",
+ 'a' + dev_desc->dev, part_num);
break;
case IF_TYPE_USB:
- sprintf (info->name, "usbd%c%d\n", 'a' + dev_desc->dev, part_num);
+ sprintf ((char *)info->name, "usbd%c%d",
+ 'a' + dev_desc->dev, part_num);
break;
case IF_TYPE_DOC:
- sprintf (info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
+ sprintf ((char *)info->name, "docd%c%d",
+ 'a' + dev_desc->dev, part_num);
break;
default:
- sprintf (info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
+ sprintf ((char *)info->name, "xx%c%d",
+ 'a' + dev_desc->dev, part_num);
break;
}
/* sprintf(info->type, "%d, pt->sys_ind); */
- sprintf (info->type, "U-Boot");
+ sprintf ((char *)info->type, "U-Boot");
return 0;
}
}
-
-#endif /* (CONFIG_COMMANDS & CFG_CMD_IDE) && CONFIG_DOS_PARTITION */
+#endif