fastboot: sparse: implement reserve()
In order to process the CHUNK_TYPE_DONT_CARE properly, there is a requirement to be able to 'reserve' a specified number of blocks in the storage media. Because of the special handling of "bad blocks" in NAND devices, this is implemented in a storage abstraction function. Signed-off-by: Steve Rae <srae@broadcom.com> Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This commit is contained in:
parent
9bc34799c8
commit
2c72404687
@ -53,6 +53,12 @@ static lbaint_t fb_mmc_sparse_write(struct sparse_storage *info,
|
|||||||
return blk_dwrite(dev_desc, blk, blkcnt, buffer);
|
return blk_dwrite(dev_desc, blk, blkcnt, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,
|
||||||
|
lbaint_t blk, lbaint_t blkcnt)
|
||||||
|
{
|
||||||
|
return blkcnt;
|
||||||
|
}
|
||||||
|
|
||||||
static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
|
static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
|
||||||
const char *part_name, void *buffer,
|
const char *part_name, void *buffer,
|
||||||
unsigned int download_bytes)
|
unsigned int download_bytes)
|
||||||
@ -131,6 +137,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
|
|||||||
sparse.start = info.start;
|
sparse.start = info.start;
|
||||||
sparse.size = info.size;
|
sparse.size = info.size;
|
||||||
sparse.write = fb_mmc_sparse_write;
|
sparse.write = fb_mmc_sparse_write;
|
||||||
|
sparse.reserve = fb_mmc_sparse_reserve;
|
||||||
|
|
||||||
printf("Flashing sparse image at offset " LBAFU "\n",
|
printf("Flashing sparse image at offset " LBAFU "\n",
|
||||||
sparse.start);
|
sparse.start);
|
||||||
|
@ -126,6 +126,25 @@ static lbaint_t fb_nand_sparse_write(struct sparse_storage *info,
|
|||||||
return written / info->blksz;
|
return written / info->blksz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
|
||||||
|
lbaint_t blk, lbaint_t blkcnt)
|
||||||
|
{
|
||||||
|
int bad_blocks = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO - implement a function to determine the total number
|
||||||
|
* of blocks which must be used in order to reserve the specified
|
||||||
|
* number ("blkcnt") of "good-blocks", starting at "blk"...
|
||||||
|
* ( possibly something like the "check_skip_len()" function )
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the return value must be 'blkcnt' ("good-blocks") plus the
|
||||||
|
* number of "bad-blocks" encountered within this space...
|
||||||
|
*/
|
||||||
|
return blkcnt + bad_blocks;
|
||||||
|
}
|
||||||
|
|
||||||
void fb_nand_flash_write(const char *cmd, void *download_buffer,
|
void fb_nand_flash_write(const char *cmd, void *download_buffer,
|
||||||
unsigned int download_bytes)
|
unsigned int download_bytes)
|
||||||
{
|
{
|
||||||
@ -155,6 +174,7 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
|
|||||||
sparse.start = part->offset / sparse.blksz;
|
sparse.start = part->offset / sparse.blksz;
|
||||||
sparse.size = part->size / sparse.blksz;
|
sparse.size = part->size / sparse.blksz;
|
||||||
sparse.write = fb_nand_sparse_write;
|
sparse.write = fb_nand_sparse_write;
|
||||||
|
sparse.reserve = fb_nand_sparse_reserve;
|
||||||
|
|
||||||
printf("Flashing sparse image at offset " LBAFU "\n",
|
printf("Flashing sparse image at offset " LBAFU "\n",
|
||||||
sparse.start);
|
sparse.start);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, Google Inc.
|
* Copyright (c) 2009, Google Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -210,10 +211,8 @@ void write_sparse_image(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CHUNK_TYPE_DONT_CARE:
|
case CHUNK_TYPE_DONT_CARE:
|
||||||
#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
|
blk += info->reserve(info, blk, blkcnt);
|
||||||
blk += blkcnt;
|
|
||||||
total_blocks += chunk_header->chunk_sz;
|
total_blocks += chunk_header->chunk_sz;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHUNK_TYPE_CRC32:
|
case CHUNK_TYPE_CRC32:
|
||||||
|
@ -19,6 +19,10 @@ struct sparse_storage {
|
|||||||
lbaint_t blk,
|
lbaint_t blk,
|
||||||
lbaint_t blkcnt,
|
lbaint_t blkcnt,
|
||||||
const void *buffer);
|
const void *buffer);
|
||||||
|
|
||||||
|
lbaint_t (*reserve)(struct sparse_storage *info,
|
||||||
|
lbaint_t blk,
|
||||||
|
lbaint_t blkcnt);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline int is_sparse_image(void *buf)
|
static inline int is_sparse_image(void *buf)
|
||||||
|
Loading…
Reference in New Issue
Block a user