X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=disk%2Fpart_iso.c;h=e733227f5996b8ef83ccb4a1fa5ac1f7b02a8699;hb=3eae864a23480978bcaafe1b143bf787bb375f47;hp=b7a538143e602b4c36d7956c8a342b82a09d468a;hpb=ef9e6de5409535bde164f087c31ac865800cbf14;p=u-boot diff --git a/disk/part_iso.c b/disk/part_iso.c index b7a538143e..e733227f59 100644 --- a/disk/part_iso.c +++ b/disk/part_iso.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2001 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch. - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -10,7 +9,7 @@ #include #include "part_iso.h" -#ifdef HAVE_BLOCK_DEVICE +#ifdef CONFIG_HAVE_BLOCK_DEVICE /* #define ISO_PART_DEBUG */ @@ -24,7 +23,26 @@ #undef CHECK_FOR_POWERPC_PLATTFORM #define CD_SECTSIZE 2048 -static unsigned char tmpbuf[CD_SECTSIZE]; +static unsigned char tmpbuf[CD_SECTSIZE] __aligned(ARCH_DMA_MINALIGN); + +unsigned long iso_dread(struct blk_desc *block_dev, lbaint_t start, + lbaint_t blkcnt, void *buffer) +{ + unsigned long ret; + + if (block_dev->blksz == 512) { + /* Convert from 2048 to 512 sector size */ + start *= 4; + blkcnt *= 4; + } + + ret = blk_dread(block_dev, start, blkcnt, buffer); + + if (block_dev->blksz == 512) + ret /= 4; + + return ret; +} /* only boot records will be listed as valid partitions */ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, @@ -39,12 +57,12 @@ 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) + if ((dev_desc->blksz != CD_SECTSIZE) && (dev_desc->blksz != 512)) return -1; /* the first sector (sector 0x10) must be a primary volume desc */ blkaddr=PVD_OFFSET; - if (blk_dread(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1) + if (iso_dread(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1) return -1; if(ppr->desctype!=0x01) { if(verb) @@ -64,7 +82,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, PRINTF(" Lastsect:%08lx\n",lastsect); for(i=blkaddr;idesctype==0x00) break; /* boot entry found */ @@ -84,7 +102,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, } bootaddr = get_unaligned_le32(pbr->pointer); PRINTF(" Boot Entry at: %08lX\n",bootaddr); - if (blk_dread(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) { + if (iso_dread(dev_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); @@ -115,33 +133,10 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, } #endif /* the validation entry seems to be ok, now search the "partition" */ - entry_num=0; + entry_num=1; offset=0x20; strcpy((char *)info->type, "U-Boot"); - switch(dev_desc->if_type) { - case IF_TYPE_IDE: - case IF_TYPE_SATA: - case IF_TYPE_ATAPI: - sprintf ((char *)info->name, "hd%c%d", - 'a' + dev_desc->devnum, part_num); - break; - case IF_TYPE_SCSI: - sprintf ((char *)info->name, "sd%c%d", - 'a' + dev_desc->devnum, part_num); - break; - case IF_TYPE_USB: - sprintf ((char *)info->name, "usbd%c%d", - 'a' + dev_desc->devnum, part_num); - break; - case IF_TYPE_DOC: - sprintf ((char *)info->name, "docd%c%d", - 'a' + dev_desc->devnum, part_num); - break; - default: - sprintf ((char *)info->name, "xx%c%d", - 'a' + dev_desc->devnum, part_num); - break; - } + part_set_generic_name(dev_desc, part_num, (char *)info->name); /* the bootcatalog (including validation Entry) is limited to 2048Bytes * (63 boot entries + validation entry) */ while(offset<2048) { @@ -192,14 +187,21 @@ found: } newblkaddr = get_unaligned_le32(pide->rel_block_addr); info->start=newblkaddr; - PRINTF(" part %d found @ %lx size %lx\n",part_num,newblkaddr,info->size); + + if (dev_desc->blksz == 512) { + info->size *= 4; + info->start *= 4; + info->blksz = 512; + } + + PRINTF(" part %d found @ %lx size %lx\n",part_num,info->start,info->size); return 0; } static int part_get_info_iso(struct blk_desc *dev_desc, int part_num, disk_partition_t *info) { - return part_get_info_iso_verb(dev_desc, part_num, info, 1); + return part_get_info_iso_verb(dev_desc, part_num, info, 0); } static void part_print_iso(struct blk_desc *dev_desc) @@ -207,13 +209,13 @@ static void part_print_iso(struct blk_desc *dev_desc) disk_partition_t info; int i; - if (part_get_info_iso_verb(dev_desc, 0, &info, 0) == -1) { + if (part_get_info_iso_verb(dev_desc, 1, &info, 0) == -1) { printf("** No boot partition found on device %d **\n", dev_desc->devnum); return; } printf("Part Start Sect x Size Type\n"); - i=0; + i=1; do { printf(" %2d " LBAFU " " LBAFU " %6ld %.32s\n", i, info.start, info.size, info.blksz, info.type); @@ -225,12 +227,13 @@ static int part_test_iso(struct blk_desc *dev_desc) { disk_partition_t info; - return part_get_info_iso_verb(dev_desc, 0, &info, 0); + return part_get_info_iso_verb(dev_desc, 1, &info, 0); } U_BOOT_PART_TYPE(iso) = { .name = "ISO", .part_type = PART_TYPE_ISO, + .max_entries = ISO_ENTRY_NUMBERS, .get_info = part_get_info_iso, .print = part_print_iso, .test = part_test_iso,