[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/3] hw/nvram/nrf51_nvm: Add nRF51 non-volati
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/3] hw/nvram/nrf51_nvm: Add nRF51 non-volatile memories |
Date: |
Thu, 31 Jan 2019 13:24:02 +0000 |
On Wed, 30 Jan 2019 at 07:21, Stefan Hajnoczi <address@hidden> wrote:
> +static void flash_write(void *opaque, hwaddr offset, uint64_t value,
> + unsigned int size)
> +{
> + NRF51NVMState *s = NRF51_NVM(opaque);
> +
> + if (s->config & NRF51_NVMC_CONFIG_WEN) {
> + uint32_t oldval;
> +
> + assert(offset < s->flash_size);
This would be better as "offset + 4 < s->flash_size", since we're
going to be reading 4 bytes, not just 1. (Or "offset + size",
though our MemoryRegionOps fields guarantee that size == 4.)
> +
> + /* NOR Flash only allows bits to be flipped from 1's to 0's on write
> */
> + oldval = ldl_le_p(s->storage + offset);
> + oldval &= value;
> + stl_le_p(s->storage + offset, oldval);
> +
> + memory_region_flush_rom_device(&s->flash, offset, size);
> + } else {
> + qemu_log_mask(LOG_GUEST_ERROR,
> + "%s: Flash write 0x%" HWADDR_PRIx" while flash not
> writable.\n",
> + __func__, offset);
> + }
> +}
otherwise
Reviewed-by: Peter Maydell <address@hidden>
thanks
-- PMM