
on vxWorks targets the filesystem with its MBR starts from a higher offset in the emmc flash for limiting space which is accesible by the user.
Signed-off-by: Hannes Petermaier oe5hpm@oevsv.at
--- Changes for V2: None --- board/BuR/kwb/board.c | 6 ++++++ disk/part_dos.c | 11 ++++++++--- drivers/mmc/mmc.c | 8 ++++++++ fs/fat/fat.c | 5 +++-- fs/fat/fat_write.c | 7 ++++--- include/part.h | 10 +++++++++- 6 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/board/BuR/kwb/board.c b/board/BuR/kwb/board.c index 892311e..8578c06 100644 --- a/board/BuR/kwb/board.c +++ b/board/BuR/kwb/board.c @@ -27,6 +27,7 @@ #include <power/tps65217.h> #include "../common/bur_common.h" #include <lcd.h> +#include <mmc.h>
/* -------------------------------------------------------------------------*/ /* -- defines for used GPIO Hardware -- */ @@ -162,6 +163,11 @@ int board_init(void) gpmc_init(); return 0; } +void board_mmc_geometry(struct mmc *mmc) +{ + mmc->block_dev.lba_fs = mmc->block_dev.lba - 0x2A8000; + mmc->block_dev.lba_offset = 0x2A8000; +}
#ifdef CONFIG_BOARD_LATE_INIT int board_late_init(void) diff --git a/disk/part_dos.c b/disk/part_dos.c index cf1a36e..9c34107 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -89,7 +89,8 @@ int test_part_dos (block_dev_desc_t *dev_desc) { ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
- if (dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) + if (dev_desc->block_read(dev_desc->dev, dev_desc->lba_offset, 1, + (ulong *)buffer) != 1) return -1;
if (test_block_type(buffer) != DOS_MBR) @@ -108,7 +109,9 @@ static void print_partition_extended(block_dev_desc_t *dev_desc, dos_partition_t *pt; int i;
- if (dev_desc->block_read(dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) { + if (dev_desc->block_read(dev_desc->dev, + ext_part_sector + dev_desc->lba_offset, 1, + (ulong *)buffer) != 1) { printf ("** Can't read partition table on %d:%d **\n", dev_desc->dev, ext_part_sector); return; @@ -172,7 +175,9 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part int i; int dos_type;
- if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) { + if (dev_desc->block_read(dev_desc->dev, + ext_part_sector + dev_desc->lba_offset, 1, + (ulong *)buffer) != 1) { printf ("** Can't read partition table on %d:%d **\n", dev_desc->dev, ext_part_sector); return -1; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index b8039cd..52e8cf5 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -531,6 +531,12 @@ static int mmc_change_freq(struct mmc *mmc) return 0; }
+void __weak board_mmc_geometry(struct mmc *mmc) +{ + mmc->block_dev.lba_fs = mmc->block_dev.lba; + mmc->block_dev.lba_offset = 0; +} + static int mmc_set_capacity(struct mmc *mmc, int part_num) { switch (part_num) { @@ -556,6 +562,8 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
mmc->block_dev.lba = lldiv(mmc->capacity, mmc->read_bl_len);
+ board_mmc_geometry(mmc); + return 0; }
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index bccc3e3..46f7da6 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -49,7 +49,8 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf) return -1;
return cur_dev->block_read(cur_dev->dev, - cur_part_info.start + block, nr_blocks, buf); + cur_part_info.start + block + cur_dev->lba_offset, + nr_blocks, buf); }
int fat_set_blk_dev(block_dev_desc_t *dev_desc, disk_partition_t *info) @@ -97,7 +98,7 @@ int fat_register_device(block_dev_desc_t *dev_desc, int part_no) }
info.start = 0; - info.size = dev_desc->lba; + info.size = dev_desc->lba_fs; info.blksz = dev_desc->blksz; info.name[0] = 0; info.type[0] = 0; diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 98b88ad..7ed656e 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -33,14 +33,15 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf) if (!cur_dev || !cur_dev->block_write) return -1;
- if (cur_part_info.start + block + nr_blocks > - cur_part_info.start + total_sector) { + if (cur_part_info.start + block + nr_blocks + cur_dev->lba_offset > + cur_part_info.start + total_sector + cur_dev->lba_offset) { printf("error: overflow occurs\n"); return -1; }
return cur_dev->block_write(cur_dev->dev, - cur_part_info.start + block, nr_blocks, buf); + cur_part_info.start + block + cur_dev->lba_offset, + nr_blocks, buf); }
/* diff --git a/include/part.h b/include/part.h index 8ea9b30..1f80c35 100644 --- a/include/part.h +++ b/include/part.h @@ -21,7 +21,15 @@ typedef struct block_dev_desc { #ifdef CONFIG_LBA48 unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ #endif - lbaint_t lba; /* number of blocks */ + lbaint_t lba_offset; /* + * offset from which file-systems + * do their work + */ + lbaint_t lba_fs; /* + * number of blocks available to the + * file-system + */ + lbaint_t lba; /* total number of blocks-available */ unsigned long blksz; /* block size */ int log2blksz; /* for convenience: log2(blksz) */ char vendor [40+1]; /* IDE model, SCSI Vendor */