On Thu, May 03, 2018 at 06:35:31PM +0930, Joel Stanley wrote: > diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c > new file mode 100644 > index 000000000000..a2e3d6f013f0 > --- /dev/null > +++ b/hw/arm/nrf51_soc.c > @@ -0,0 +1,101 @@ > +/* > + * Nordic Semiconductor nRF51 SoC > + * > + * Copyright 2018 Joel Stanley <j...@jms.id.au> > + * > + * This code is licensed under the GPL version 2 or later. See > + * the COPYING file in the top-level directory.
Please include the link in the comment: The reference manual is available here: http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf > +static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) > +{ > + NRF51State *s = NRF51_SOC(dev_soc); > + DeviceState *nvic; > + Error *err = NULL; > + > + /* IO space */ > + create_unimplemented_device("nrf51_soc.io", IOMEM_BASE, IOMEM_SIZE); > + > + /* FICR */ > + create_unimplemented_device("nrf51_soc.ficr", FICR_BASE, FICR_SIZE); > + > + MemoryRegion *system_memory = get_system_memory(); > + MemoryRegion *sram = g_new(MemoryRegion, 1); > + MemoryRegion *flash = g_new(MemoryRegion, 1); > + > + memory_region_init_ram_nomigrate(flash, NULL, "nrf51.flash", FLASH_SIZE, > + &err); > + if (err) { > + error_propagate(errp, err); > + return; Please free resources (e.g. sram and flash) in error code paths.
signature.asc
Description: PGP signature