[Skiboot] [RFC,PATCH 1/3] core/flash: Add flash API
Joel Stanley
joel at jms.id.au
Mon Feb 9 12:07:13 AEDT 2015
On Fri, Feb 6, 2015 at 9:39 PM, Jeremy Kerr <jk at ozlabs.org> wrote:
> diff --git a/core/flash.c b/core/flash.c
> new file mode 100644
> index 0000000..4a4198d
> --- /dev/null
> +++ b/core/flash.c
> +static int64_t opal_flash_op(uint64_t id, uint64_t offset, uint64_t buf,
> + uint64_t size, uint64_t token, enum flash_op op)
> +{
> + struct flash *flash;
> + uint32_t mask;
> + int rc;
> +
> + if (id >= ARRAY_SIZE(flashes))
> + return OPAL_PARAMETER;
> +
> + if (!try_lock(&flash_lock))
> + return OPAL_BUSY;
> +
> + flash = &flashes[id];
> + if (!flash->registered) {
> + rc = OPAL_PARAMETER;
> + goto err;
> + }
> +
> + if (size >= flash->size || offset >= flash->size
> + || offset + size >= flash->size) {
Do we want to check for overflow here?
> + rc = OPAL_PARAMETER;
> + goto err;
> + }
> +
> + mask = flash->block_size - 1;
> + if (size & mask || offset & mask) {
> + rc = OPAL_PARAMETER;
> + goto err;
> + }
> +
More information about the Skiboot
mailing list