target-arm queue
target-arm queue: the data driven register API patchset, plus the AST2400 SMC/SPIU patchset, and a pile of bugfixes. I have some more stuff in my to-review queue but I wanted to get this lot out first.
thanks
-- PMM
The following changes since commit e2c8f9e44e07d8210049abaa6042ec3c956f1dd4:
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2016-07-04 10:49:17 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20160704
for you to fetch changes up to e1ad9bc405afbd7581831ca1705f39e73c94c5ff:
ast2400: create SPI flash slaves (2016-07-04 13:15:22 +0100)
----------------------------------------------------------------
target-arm queue:
* fix semihosting SYS_HEAPINFO call for A64 guests
* fix crash if guest tries to write to ROM on imx boards
* armv7m_nvic: fix crash for debugger reads from some registers
* virt: mark PCIe host controller as dma-coherent in the DT
* add data-driven register API
* Xilinx Zynq: add devcfg device model
* m25p80: fix various bugs
* ast2400: add SMC controllers and SPI flash slaves
----------------------------------------------------------------
Alistair Francis (4):
bitops: Add MAKE_64BIT_MASK macro
register: Add Register API
register: Add Memory API glue
dma: Add Xilinx Zynq devcfg device model
Andrey Smirnov (1):
armv7m_nvic: Use qemu_get_cpu(0) instead of current_cpu
Ard Biesheuvel (1):
hw/arm/virt: mark the PCIe host controller as DMA coherent in the DT
Cédric Le Goater (4):
ssi: change ssi_slave_init to be a realize ops
ast2400: add SMC controllers (FMC and SPI)
ast2400: add SPI flash slaves
ast2400: create SPI flash slaves
Paolo Bonzini (4):
m25p80: do not put iovec on the stack
m25p80: avoid out of bounds accesses
m25p80: change cur_addr to 32 bit integer
m25p80: qdev-ify drive property
Peter Crosthwaite (4):
register: Define REG and FIELD macros
register: QOMify
register: Add block initialise helper
xilinx_zynq: Connect devcfg to the Zynq machine model
Peter Maydell (5):
linux-user: Make semihosting heap/stack fields abi_ulongs target-arm/arm-semi.c: Fix SYS_HEAPINFO for 64-bit guests
memory: Provide memory_region_init_rom()
imx: Use memory_region_init_rom() for ROMs
memory: Assert that memory_region_init_rom_device() ops aren't NULL
default-configs/arm-softmmu.mak | 1 + docs/memory.txt | 9 +- hw/arm/ast2400.c | 40 ++- hw/arm/fsl-imx25.c | 8 +- hw/arm/fsl-imx31.c | 9 +- hw/arm/fsl-imx6.c | 8 +- hw/arm/palmetto-bmc.c | 31 +++ hw/arm/sabrelite.c | 18 +- hw/arm/spitz.c | 12 +- hw/arm/tosa.c | 5 +- hw/arm/virt.c | 1 + hw/arm/xilinx_zynq.c | 14 +- hw/arm/xlnx-ep108.c | 9 +- hw/arm/z2.c | 6 +- hw/block/m25p80.c | 76 +++--- hw/core/Makefile.objs | 1 + hw/core/register.c | 287 ++++++++++++++++++++++ hw/display/ads7846.c | 5 +- hw/display/ssd0323.c | 5 +- hw/dma/Makefile.objs | 1 + hw/dma/xlnx-zynq-devcfg.c | 400 ++++++++++++++++++++++++++++++ hw/intc/armv7m_nvic.c | 8 +- hw/microblaze/petalogix_ml605_mmu.c | 9 +- hw/misc/max111x.c | 12 +- hw/sd/ssi-sd.c | 9 +- hw/ssi/Makefile.objs | 1 + hw/ssi/aspeed_smc.c | 470 ++++++++++++++++++++++++++++++++++++ hw/ssi/ssi.c | 6 +- include/exec/memory.h | 24 +- include/hw/arm/ast2400.h | 3 + include/hw/dma/xlnx-zynq-devcfg.h | 62 +++++ include/hw/register.h | 255 +++++++++++++++++++ include/hw/ssi/aspeed_smc.h | 100 ++++++++ include/hw/ssi/ssi.h | 2 +- include/qemu/bitops.h | 3 + linux-user/qemu.h | 6 +- memory.c | 16 ++ target-arm/arm-semi.c | 47 ++-- 38 files changed, 1847 insertions(+), 132 deletions(-) create mode 100644 hw/core/register.c create mode 100644 hw/dma/xlnx-zynq-devcfg.c create mode 100644 hw/ssi/aspeed_smc.c create mode 100644 include/hw/dma/xlnx-zynq-devcfg.h create mode 100644 include/hw/register.h create mode 100644 include/hw/ssi/aspeed_smc.h
[Qemu-devel] [PULL 11/23] register: Define REG and FIELD macros
From: Peter Crosthwaite <[email protected]>
Define some macros that can be used for defining registers and fields.
The REG32 macro will define A_FOO, for the byte address of a register as well as R_FOO for the uint32_t[] register number (A_FOO / 4).
The FIELD macro will define FOO_BAR_MASK, FOO_BAR_SHIFT and FOO_BAR_LENGTH constants for field BAR in register FOO.
Finally, there are some shorthand helpers for extracting/depositing fields from registers based on these naming schemes.
Usage can greatly reduce the verbosity of device code.
The deposit and extract macros (eg FIELD_EX32, FIELD_DP32 etc.) can be used to generate extract and deposits without any repetition of the name stems.
Message-id: bbd87a3c03b1f173b1ed73a6d502c0196c18a72f.1467053537.git.alistair.francis@xilinx.com [ EI Changes:
* Add Deposit macros
]
--- include/hw/register.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
include/hw/register.h +46 -0
@@ -152,4 +152,50 @@ void register_write_memory(void *opaque, hwaddr addr, uint64_t value,uint64_t register_read_memory (void *opaque,hwaddr addr,unsigned size); +/* Define constants for a 32 bit register */ + +/* This macro will define A_FOO, for the byte address of a register +* as well as R_FOO for the uint32_t[] register number (A_FOO / 4). +*/ +#define REG32 (reg, addr) \ + enum { A_ ## reg = (addr) }; \ + enum { R_ ## reg = (addr) / 4 }; + +/* Define SHIFT, LENGTH and MASK constants for a field within a register */ + +/* This macro will define FOO_BAR_MASK, FOO_BAR_SHIFT and FOO_BAR_LENGTH +* constants for field BAR in register FOO. +*/ +#define FIELD (reg, field, shift, length) \ + enum { R_ ## reg ## _ ## field ## _SHIFT = (shift)}; \ + enum { R_ ## reg ## _ ## field ## _LENGTH = (length)}; \ + enum { R_ ## reg ## _ ## field ## _MASK = \ + MAKE_64BIT_MASK(shift, length)}; + +/* Extract a field from a register */ +#define FIELD_EX32 (storage, reg, field) \ + extract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) + +/* Extract a field from an array of registers */ +#define ARRAY_FIELD_EX32 (regs, reg, field) \ + FIELD_EX32((regs)[R_ ## reg], reg, field) + +/* Deposit a register field. +* Assigning values larger then the target field will result in +* compilation warnings. +*/ +#define FIELD_DP32 (storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint32_t d; \ + d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; }) + +/* Deposit a field to array of registers. */ +#define ARRAY_FIELD_DP32 (regs, reg, field, val) \ + (regs)[R_ ## reg] = FIELD_DP32((regs)[R_ ## reg], reg, field, val); +#endif
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 12/23] register: QOMify
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
QOMify registers as a child of TYPE_DEVICE. This allows registers to define GPIOs.
Define an init helper that will do QOM initialisation.
Message-id: 2545f71db26bf5586ca0c08a3e3cf1b217450552.1467053537.git.alistair.francis@xilinx.com
--- hw/core/register.c | 23 +++++++++++++++++++++++ include/hw/register.h | 14 ++++++++++++++ 2 files changed, 37 insertions(+)
hw/core/register.c +23 -0
@@ -159,6 +159,17 @@ void register_reset(RegisterInfo *reg)register_write_val (reg, reg->access->reset); } +void register_init (RegisterInfo *reg) +{ +assert (reg); + +if (!reg->data || !reg->access) { +return ; + } + +object_initialize ((void *)reg,sizeof (*reg),TYPE_REGISTER ); +} +void register_write_memory (void *opaque,hwaddr addr,uint64_t value,unsigned size) {
@@ -217,3 +228,15 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,return extract64 (read_val,0 , size *8 ); } + +static const TypeInfo register_info = { + .name =TYPE_REGISTER , + .parent =TYPE_DEVICE , +}; + +static void register_register_types (void ) +{ +type_register_static (®ister_info); +} + +type_init (register_register_types)
include/hw/register.h +14 -0
@@ -11,6 +11,7 @@#ifndef REGISTER_H #define REGISTER_H +#include "hw/qdev-core.h" #include "exec/memory.h" typedef struct RegisterInfo RegisterInfo ;
@@ -72,6 +73,9 @@ struct RegisterAccessInfo {*/ struct RegisterInfo { +/* <private> */ +DeviceState parent_obj; +/* <public> */ void *data;int data_size;
@@ -81,6 +85,9 @@ struct RegisterInfo {void *opaque; }; +#define TYPE_REGISTER "qemu,register" +#define REGISTER (obj) OBJECT_CHECK(RegisterInfo, (obj), TYPE_REGISTER) +/** * This structure is used to group all of the individual registers which are * modeled using the RegisterInfo structure.
@@ -132,6 +139,13 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,void register_reset (RegisterInfo *reg);/** +* Initialize a register. +* @reg: Register to initialize +*/ + +void register_init (RegisterInfo *reg); + +/** * Memory API MMIO write handler that will write to a Register API register. * @opaque: RegisterInfo to write to * @addr: Address to write
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 13/23] register: Add block initialise helper
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
Add a helper that will scan a static RegisterAccessInfo Array and populate a container MemoryRegion with registers as defined.
Message-id: 347b810b2799e413c98d5bbeca97bcb1557946c3.1467053537.git.alistair.francis@xilinx.com
--- hw/core/register.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/register.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
hw/core/register.c +45 -0
@@ -229,6 +229,51 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,return extract64 (read_val,0 , size *8 ); } +RegisterInfoArray *register_init_block32 (DeviceState *owner, +const RegisterAccessInfo *rae, +int num,RegisterInfo *ri, +uint32_t *data, +const MemoryRegionOps *ops, +bool debug_enabled, +uint64_t memory_size) +{ +const char *device_prefix =object_get_typename (OBJECT (owner)); +RegisterInfoArray *r_array =g_new0 (RegisterInfoArray,1 ); +int i; + + r_array->r = g_new0(RegisterInfo *, num); + r_array->num_elements = num; + r_array->debug = debug_enabled; + r_array->prefix = device_prefix; + +for (i =0 ; i < num; i++) { +int index = rae[i].addr /4 ; +RegisterInfo *r = &ri[index]; + + *r = (RegisterInfo ) { + .data = &data[index], + .data_size =sizeof (uint32_t ), + .access = &rae[i], + .opaque = owner, + }; +register_init (r); + + r_array->r[i] = r; + } + +memory_region_init_io (&r_array->mem,OBJECT (owner), ops, r_array, + device_prefix, memory_size); + +return r_array; +} + +void register_finalize_block (RegisterInfoArray *r_array) +{ +object_unparent (OBJECT (&r_array->mem)); +g_free (r_array->r); +g_free (r_array); +} +static const TypeInfo register_info = { .name =TYPE_REGISTER , .parent =TYPE_DEVICE ,
include/hw/register.h +40 -0
@@ -100,6 +100,8 @@ struct RegisterInfo {*/ struct RegisterInfoArray { +MemoryRegion mem; +int num_elements;RegisterInfo **r;
@@ -166,6 +168,44 @@ void register_write_memory(void *opaque, hwaddr addr, uint64_t value,uint64_t register_read_memory (void *opaque,hwaddr addr,unsigned size); +/** +* Init a block of registers into a container MemoryRegion. A +* number of constant register definitions are parsed to create a corresponding +* array of RegisterInfo's. +* +* @owner: device owning the registers +* @rae: Register definitions to init +* @num: number of registers to init (length of @rae) +* @ri: Register array to init, must already be allocated +* @data: Array to use for register data, must already be allocated +* @ops: Memory region ops to access registers. +* @debug enabled: turn on/off verbose debug information +* returns: A structure containing all of the registers and an initialized +* memory region (r_array->mem) the caller should add to a container. +*/ + +RegisterInfoArray *register_init_block32 (DeviceState *owner, +const RegisterAccessInfo *rae, +int num,RegisterInfo *ri, +uint32_t *data, +const MemoryRegionOps *ops, +bool debug_enabled, +uint64_t memory_size); + +/** +* This function should be called to cleanup the registers that were initialized +* when calling register_init_block32(). This function should only be called +* from the device's instance_finalize function. +* +* Any memory operations that the device performed that require cleanup (such +* as creating subregions) need to be called before calling this function. +* +* @r_array: A structure containing all of the registers, as returned by +* register_init_block32() +*/ + +void register_finalize_block (RegisterInfoArray *r_array); +/* Define constants for a 32 bit register */ /* This macro will define A_FOO, for the byte address of a register
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 16/23] ssi: change ssi_slave_init to be a realize ops
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
This enables qemu to handle late inits and report errors. All the SSI slave routine names were changed accordingly. Code was modified to handle errors when possible (m25p80 and ssi-sd)
Tested with the m25p80 slave object.
Message-id: [email protected]
--- hw/arm/spitz.c | 12 ++++-------- hw/arm/tosa.c | 5 ++--- hw/arm/z2.c | 6 ++---- hw/block/m25p80.c | 12 +++++------- hw/display/ads7846.c | 5 ++--- hw/display/ssd0323.c | 5 ++--- hw/misc/max111x.c | 12 ++++++------ hw/sd/ssi-sd.c | 9 +++++---- hw/ssi/ssi.c | 6 +++--- include/hw/ssi/ssi.h | 2 +- 10 files changed, 32 insertions(+), 42 deletions(-)
hw/arm/spitz.c +4 -8
@@ -598,15 +598,13 @@ static uint32_t spitz_lcdtg_transfer(SSISlave *dev, uint32_t value)return 0 ; } -static int spitz_lcdtg_init (SSISlave *dev) +static void spitz_lcdtg_realize (SSISlave *dev,Error **errp) {SpitzLCDTG *s =FROM_SSI_SLAVE (SpitzLCDTG, dev); spitz_lcdtg = s; s->bl_power =0 ; s->bl_intensity =0x20 ; - -return 0 ; }/* SSP devices */
@@ -666,7 +664,7 @@ static void spitz_adc_temp_on(void *opaque, int line, int level)max111x_set_input (max1111,MAX1111_BATT_TEMP ,0 ); } -static int corgi_ssp_init (SSISlave *d) +static void corgi_ssp_realize (SSISlave *d,Error **errp) {DeviceState *dev =DEVICE (d);CorgiSSPState *s =FROM_SSI_SLAVE (CorgiSSPState, d);
@@ -675,8 +673,6 @@ static int corgi_ssp_init(SSISlave *d) s->bus[0 ] =ssi_create_bus (dev,"ssi0" ); s->bus[1 ] =ssi_create_bus (dev,"ssi1" ); s->bus[2 ] =ssi_create_bus (dev,"ssi2" ); - -return 0 ; }static void spitz_ssp_attach (PXA2xxState *cpu)
@@ -1121,7 +1117,7 @@ static void corgi_ssp_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = corgi_ssp_init; + k->realize = corgi_ssp_realize; k->transfer = corgi_ssp_transfer; dc->vmsd = &vmstate_corgi_ssp_regs; }
@@ -1150,7 +1146,7 @@ static void spitz_lcdtg_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = spitz_lcdtg_init; + k->realize = spitz_lcdtg_realize; k->transfer = spitz_lcdtg_transfer; dc->vmsd = &vmstate_spitz_lcdtg_regs; }
hw/arm/tosa.c +2 -3
@@ -127,10 +127,9 @@ static uint32_t tosa_ssp_tansfer(SSISlave *dev, uint32_t value)return 0 ; } -static int tosa_ssp_init (SSISlave *dev) +static void tosa_ssp_realize (SSISlave *dev,Error **errp) {/* Nothing to do. */ -return 0 ; }#define TYPE_TOSA_DAC "tosa_dac"
@@ -283,7 +282,7 @@ static void tosa_ssp_class_init(ObjectClass *klass, void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = tosa_ssp_init; + k->realize = tosa_ssp_realize; k->transfer = tosa_ssp_tansfer; }
hw/arm/z2.c +2 -4
@@ -151,14 +151,12 @@ static void z2_lcd_cs(void *opaque, int line, int level) z2_lcd->selected = !level; } -static int zipit_lcd_init (SSISlave *dev) +static void zipit_lcd_realize (SSISlave *dev,Error **errp) {ZipitLCD *z =FROM_SSI_SLAVE (ZipitLCD, dev); z->selected =0 ; z->enabled =0 ; z->pos =0 ; - -return 0 ; }static VMStateDescription vmstate_zipit_lcd_state = {
@@ -181,7 +179,7 @@ static void zipit_lcd_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = zipit_lcd_init; + k->realize = zipit_lcd_realize; k->transfer = zipit_lcd_transfer; dc->vmsd = &vmstate_zipit_lcd_state; }
hw/block/m25p80.c +5 -7
@@ -28,6 +28,7 @@#include "hw/ssi/ssi.h" #include "qemu/bitops.h" #include "qemu/log.h" +#include "qapi/error.h" #ifndef M25P80_ERR_DEBUG #define M25P80_ERR_DEBUG 0
@@ -1132,7 +1133,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)return r; } -static int m25p80_init (SSISlave *ss) +static void m25p80_realize (SSISlave *ss,Error **errp) {DriveInfo *dinfo;Flash *s =M25P80 (ss);
@@ -1153,18 +1154,15 @@ static int m25p80_init(SSISlave *ss) s->storage =blk_blockalign (s->blk, s->size); -/* FIXME: Move to late init */ if (blk_pread (s->blk,0 , s->storage, s->size) != s->size) { -fprintf (stderr,"Failed to initialize SPI flash!\n" ); -return 1 ; +error_setg (errp,"failed to read the initial flash content" ); +return ; } }else {DB_PRINT_L (0 ,"No BDRV - binding to RAM\n" ); s->storage =blk_blockalign (NULL , s->size);memset (s->storage,0xFF , s->size); } - -return 0 ; }static void m25p80_reset (DeviceState *d)
@@ -1224,7 +1222,7 @@ static void m25p80_class_init(ObjectClass *klass, void *data)SSISlaveClass *k =SSI_SLAVE_CLASS (klass);M25P80Class *mc =M25P80_CLASS (klass); - k->init = m25p80_init; + k->realize = m25p80_realize; k->transfer = m25p80_transfer8; k->set_cs = m25p80_cs; k->cs_polarity =SSI_CS_LOW ;
hw/display/ads7846.c +2 -3
@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_ads7846 = { } }; -static int ads7846_init (SSISlave *d) +static void ads7846_realize (SSISlave *d,Error **errp) {DeviceState *dev =DEVICE (d);ADS7846State *s =FROM_SSI_SLAVE (ADS7846State, d);
@@ -152,14 +152,13 @@ static int ads7846_init(SSISlave *d)ads7846_int_update (s);vmstate_register (NULL ,-1 , &vmstate_ads7846, s); -return 0 ; }static void ads7846_class_init (ObjectClass *klass,void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = ads7846_init; + k->realize = ads7846_realize; k->transfer = ads7846_transfer; }
hw/display/ssd0323.c +2 -3
@@ -361,7 +361,7 @@ static const GraphicHwOps ssd0323_ops = { .gfx_update = ssd0323_update_display, }; -static int ssd0323_init (SSISlave *d) +static void ssd0323_realize (SSISlave *d,Error **errp) {DeviceState *dev =DEVICE (d);ssd0323_state *s =FROM_SSI_SLAVE (ssd0323_state, d);
@@ -375,14 +375,13 @@ static int ssd0323_init(SSISlave *d)register_savevm (dev,"ssd0323_oled" ,-1 ,1 , ssd0323_save, ssd0323_load, s); -return 0 ; }static void ssd0323_class_init (ObjectClass *klass,void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = ssd0323_init; + k->realize = ssd0323_realize; k->transfer = ssd0323_transfer; k->cs_polarity =SSI_CS_HIGH ; }
hw/misc/max111x.c +6 -6
@@ -147,14 +147,14 @@ static int max111x_init(SSISlave *d, int inputs)return 0 ; } -static int max1110_init (SSISlave *dev) +static void max1110_realize (SSISlave *dev,Error **errp) { -return max111x_init (dev,8 ); +max111x_init (dev,8 ); } -static int max1111_init (SSISlave *dev) +static void max1111_realize (SSISlave *dev,Error **errp) { -return max111x_init (dev,4 ); +max111x_init (dev,4 ); }void max111x_set_input (DeviceState *dev,int line,uint8_t value)
@@ -183,7 +183,7 @@ static void max1110_class_init(ObjectClass *klass, void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = max1110_init; + k->realize = max1110_realize; }static const TypeInfo max1110_info = {
@@ -196,7 +196,7 @@ static void max1111_class_init(ObjectClass *klass, void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = max1111_init; + k->realize = max1111_realize; }static const TypeInfo max1111_info = {
hw/sd/ssi-sd.c +5 -4
@@ -15,6 +15,7 @@#include "sysemu/blockdev.h" #include "hw/ssi/ssi.h" #include "hw/sd/sd.h" +#include "qapi/error.h" //#define DEBUG_SSI_SD 1
@@ -249,7 +250,7 @@ static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -static int ssi_sd_init (SSISlave *d) +static void ssi_sd_realize (SSISlave *d,Error **errp) {DeviceState *dev =DEVICE (d);ssi_sd_state *s =FROM_SSI_SLAVE (ssi_sd_state, d);
@@ -260,17 +261,17 @@ static int ssi_sd_init(SSISlave *d) dinfo =drive_get_next (IF_SD ); s->sd =sd_init (dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , true);if (s->sd ==NULL ) { -return -1 ; +error_setg (errp,"Device initialization failed." ); +return ; }register_savevm (dev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s); -return 0 ; }static void ssi_sd_class_init (ObjectClass *klass,void *data) {SSISlaveClass *k =SSI_SLAVE_CLASS (klass); - k->init = ssi_sd_init; + k->realize = ssi_sd_realize; k->transfer = ssi_sd_transfer; k->cs_polarity =SSI_CS_LOW ; }
hw/ssi/ssi.c +3 -3
@@ -54,7 +54,7 @@ static uint32_t ssi_transfer_raw_default(SSISlave *dev, uint32_t val)return 0 ; } -static int ssi_slave_init (DeviceState *dev) +static void ssi_slave_realize (DeviceState *dev,Error **errp) {SSISlave *s =SSI_SLAVE (dev);SSISlaveClass *ssc =SSI_SLAVE_GET_CLASS (s);
@@ -64,7 +64,7 @@ static int ssi_slave_init(DeviceState *dev)qdev_init_gpio_in_named (dev, ssi_cs_default,SSI_GPIO_CS ,1 ); } -return ssc->init (s); + ssc->realize (s, errp); }static void ssi_slave_class_init (ObjectClass *klass,void *data)
@@ -72,7 +72,7 @@ static void ssi_slave_class_init(ObjectClass *klass, void *data)SSISlaveClass *ssc =SSI_SLAVE_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); - dc->init = ssi_slave_init; + dc->realize = ssi_slave_realize; dc->bus_type =TYPE_SSI_BUS ;if (!ssc->transfer_raw) { ssc->transfer_raw = ssi_transfer_raw_default;
include/hw/ssi/ssi.h +1 -1
@@ -37,7 +37,7 @@ enum SSICSMode {struct SSISlaveClass {DeviceClass parent_class; -int (*init)(SSISlave *dev); +void (*realize)(SSISlave *dev,Error **errp);/* if you have standard or no CS behaviour, just override transfer. * This is called when the device cs is active (true by default).
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 19/23] m25p80: change cur_addr to 32 bit integer
In reply to Peter MaydellFrom: Paolo Bonzini <[email protected]>
The maximum amount of storage that can be addressed by the m25p80 command set is 4 GiB. However, cur_addr is currently a 64-bit integer. To avoid further problems related to sign extension of signed 32-bit integer expressions, change cur_addr to a 32 bit integer. Preserve migration format by adding a dummy 4-byte field in place of the (big-endian) high four bytes in the formerly 64-bit cur_addr field.
Message-id: [email protected]
--- hw/block/m25p80.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
hw/block/m25p80.c +8 -7
@@ -390,7 +390,7 @@ typedef struct Flash {uint32_t pos;uint8_t needed_bytes;uint8_t cmd_in_progress; -uint64_t cur_addr; +uint32_t cur_addr;uint32_t nonvolatile_cfg;/* Configuration register for Macronix */ uint32_t volatile_cfg;
@@ -536,9 +536,9 @@ static inline void flash_sync_dirty(Flash *s, int64_t newpage) }static inline -void flash_write8 (Flash *s,uint64_t addr,uint8_t data) +void flash_write8 (Flash *s,uint32_t addr,uint8_t data) { -int64_t page = addr / s->pi->page_size; +uint32_t page = addr / s->pi->page_size;uint8_t prev = s->storage[s->cur_addr];if (!s->write_enable) {
@@ -546,7 +546,7 @@ void flash_write8(Flash *s, uint64_t addr, uint8_t data) }if ((prev ^ data) & data) { -DB_PRINT_L (1 ,"programming zero to one! addr=%" PRIx64" %" PRIx8 +DB_PRINT_L (1 ,"programming zero to one! addr=%" PRIx32" %" PRIx8" -> %" PRIx8"\n" , addr, prev, data); }
@@ -1095,7 +1095,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)switch (s->state) {case STATE_PAGE_PROGRAM : -DB_PRINT_L (1 ,"page program cur_addr=%#" PRIx64" data=%" PRIx8"\n" , +DB_PRINT_L (1 ,"page program cur_addr=%#" PRIx32" data=%" PRIx8"\n" , s->cur_addr, (uint8_t )tx);flash_write8 (s, s->cur_addr, (uint8_t )tx); s->cur_addr = (s->cur_addr +1 ) & (s->size -1 );
@@ -1103,7 +1103,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)case STATE_READ : r = s->storage[s->cur_addr]; -DB_PRINT_L (1 ,"READ 0x%" PRIx64"=%" PRIx8"\n" , s->cur_addr, +DB_PRINT_L (1 ,"READ 0x%" PRIx32"=%" PRIx8"\n" , s->cur_addr, (uint8_t )r); s->cur_addr = (s->cur_addr +1 ) & (s->size -1 );break ;
@@ -1202,7 +1202,8 @@ static const VMStateDescription vmstate_m25p80 = {VMSTATE_UINT32 (pos, Flash),VMSTATE_UINT8 (needed_bytes, Flash),VMSTATE_UINT8 (cmd_in_progress, Flash), -VMSTATE_UINT64 (cur_addr, Flash), +VMSTATE_UNUSED (4 ), +VMSTATE_UINT32 (cur_addr, Flash),VMSTATE_BOOL (write_enable, Flash),VMSTATE_BOOL_V (reset_enable, Flash,2 ), VMSTATE_UINT8_V(ear, Flash, 2),
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 08/23] bitops: Add MAKE_64BIT_MASK macro
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
Add a macro that creates a 64bit value which has length number of ones shifted across by the value of shift.
Message-id: 9773244aa1c8c26b8b82cb261d8f5dd4b7b9fcf9.1467053537.git.alistair.francis@xilinx.com
--- include/qemu/bitops.h | 3 +++ 1 file changed, 3 insertions(+)
include/qemu/bitops.h +3 -0
@@ -24,6 +24,9 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define MAKE_64BIT_MASK (shift, length) \ + (((~0ULL) >> (64 - (length))) << (shift)) +/** * set_bit - Set a bit in memory * @nr: the bit to set
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 10/23] register: Add Memory API glue
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
Add memory io handlers that glue the register API to the memory API. Just translation functions at this stage. Although it does allow for devices to be created without all-in-one mmio r/w handlers.
This patch also adds the RegisterInfoArray struct, which allows all of the individual RegisterInfo structs to be grouped into a single memory region.
Message-id: f7704d8ac6ac0f469ed35401f8151a38bd01468b.1467053537.git.alistair.francis@xilinx.com
--- hw/core/register.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/register.h | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+)
hw/core/register.c +59 -0
@@ -158,3 +158,62 @@ void register_reset(RegisterInfo *reg)register_write_val (reg, reg->access->reset); } + +void register_write_memory (void *opaque,hwaddr addr, +uint64_t value,unsigned size) +{ +RegisterInfoArray *reg_array = opaque; +RegisterInfo *reg =NULL ; +uint64_t we; +int i; + +for (i =0 ; i < reg_array->num_elements; i++) { +if (reg_array->r[i]->access->addr == addr) { + reg = reg_array->r[i]; +break ; + } + } + +if (!reg) { +qemu_log_mask (LOG_GUEST_ERROR ,"Write to unimplemented register at " \ +"address: %#" PRIx64"\n" , addr); +return ; + } + +/* Generate appropriate write enable mask */ +if (reg->data_size < size) { + we =MAKE_64BIT_MASK (0 , reg->data_size *8 ); + }else { + we =MAKE_64BIT_MASK (0 , size *8 ); + } + +register_write (reg, value, we, reg_array->prefix, + reg_array->debug); +} + +uint64_t register_read_memory (void *opaque,hwaddr addr, +unsigned size) +{ +RegisterInfoArray *reg_array = opaque; +RegisterInfo *reg =NULL ; +uint64_t read_val; +int i; + +for (i =0 ; i < reg_array->num_elements; i++) { +if (reg_array->r[i]->access->addr == addr) { + reg = reg_array->r[i]; +break ; + } + } + +if (!reg) { +qemu_log_mask (LOG_GUEST_ERROR ,"Read to unimplemented register at " \ +"address: %#" PRIx64"\n" , addr); +return 0 ; + } + + read_val =register_read (reg, size *8 , reg_array->prefix, + reg_array->debug); + +return extract64 (read_val,0 , size *8 ); +}
include/hw/register.h +43 -0
65 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 01/23] linux-user: Make semihosting heap/stack fields abi_ulongs
In reply to Peter MaydellThe fields in the TaskState heap_base, heap_limit and stack_base are all guest addresses (representing the locations of the heap and stack for the guest binary), so they should be abi_ulong rather than uint32_t. (This only in practice affects ARM AArch64 since all the other semihosting implementations are 32-bit.)
Message-id: [email protected]
--- linux-user/qemu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/qemu.h +3 -3
@@ -116,10 +116,10 @@ typedef struct TaskState {#endif #if defined(TARGET_ARM ) || defined(TARGET_M68K ) || defined(TARGET_UNICORE32 )/* Extra fields for semihosted binaries. */ -uint32_t heap_base; -uint32_t heap_limit; +abi_ulong heap_base; +abi_ulong heap_limit;#endif -uint32_t stack_base; +abi_ulong stack_base;int used;/* non zero if used */ struct image_info *info;struct linux_binprm *bprm;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 20/23] m25p80: qdev-ify drive property
In reply to Peter MaydellFrom: Paolo Bonzini <[email protected]>
This allows specifying the property via -drive if=none and creating the flash device with -device.
Message-id: [email protected] [clg: added an extra fix for sabrelite_init()
keeping the test on flash_dev did not seem necessary. ]
--- hw/arm/sabrelite.c | 18 ++++++++++++------ hw/arm/xilinx_zynq.c | 8 +++++++- hw/arm/xlnx-ep108.c | 9 ++++++++- hw/block/m25p80.c | 10 ++-------- hw/microblaze/petalogix_ml605_mmu.c | 9 ++++++++- 5 files changed, 37 insertions(+), 17 deletions(-)
hw/arm/sabrelite.c +12 -6
@@ -86,13 +86,19 @@ static void sabrelite_init(MachineState *machine) spi_bus = (SSIBus *)qdev_get_child_bus (DEVICE (spi_dev),"spi" );if (spi_bus) {DeviceState *flash_dev; - - flash_dev =ssi_create_slave (spi_bus,"sst25vf016b" ); -if (flash_dev) { -qemu_irq cs_line =qdev_get_gpio_in_named (flash_dev, -SSI_GPIO_CS ,0 ); -sysbus_connect_irq (SYS_BUS_DEVICE (spi_dev),1 , cs_line); +qemu_irq cs_line; +DriveInfo *dinfo =drive_get_next (IF_MTD ); + + flash_dev =ssi_create_slave_no_init (spi_bus,"sst25vf016b" ); +if (dinfo) { +qdev_prop_set_drive (flash_dev,"drive" , +blk_by_legacy_dinfo (dinfo), + &error_fatal); } +qdev_init_nofail (flash_dev); + + cs_line =qdev_get_gpio_in_named (flash_dev,SSI_GPIO_CS ,0 ); +sysbus_connect_irq (SYS_BUS_DEVICE (spi_dev),1 , cs_line); } } }
hw/arm/xilinx_zynq.c +7 -1
@@ -138,7 +138,13 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, spi = (SSIBus *)qdev_get_child_bus (dev, bus_name);for (j =0 ; j < num_ss; ++j) { - flash_dev =ssi_create_slave (spi,"n25q128" ); +DriveInfo *dinfo =drive_get_next (IF_MTD ); + flash_dev =ssi_create_slave_no_init (spi,"n25q128" ); +if (dinfo) { +qdev_prop_set_drive (flash_dev,"drive" , +blk_by_legacy_dinfo (dinfo), &error_fatal); + } +qdev_init_nofail (flash_dev); cs_line =qdev_get_gpio_in_named (flash_dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (busdev, i * num_ss + j +1 , cs_line);
hw/arm/xlnx-ep108.c +8 -1
@@ -88,12 +88,19 @@ static void xlnx_ep108_init(MachineState *machine)SSIBus *spi_bus;DeviceState *flash_dev;qemu_irq cs_line; +DriveInfo *dinfo =drive_get_next (IF_MTD );gchar *bus_name =g_strdup_printf ("spi%d" , i); spi_bus = (SSIBus *)qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name); - flash_dev =ssi_create_slave (spi_bus,"sst25wf080" ); + flash_dev =ssi_create_slave_no_init (spi_bus,"sst25wf080" ); +if (dinfo) { +qdev_prop_set_drive (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); + } +qdev_init_nofail (flash_dev); + cs_line =qdev_get_gpio_in_named (flash_dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (SYS_BUS_DEVICE (&s->soc.spi[i]),1 , cs_line);
hw/block/m25p80.c +2 -8
@@ -1138,7 +1138,6 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)static void m25p80_realize (SSISlave *ss,Error **errp) { -DriveInfo *dinfo;Flash *s =M25P80 (ss);M25P80Class *mc =M25P80_GET_CLASS (s);
@@ -1147,14 +1146,8 @@ static void m25p80_realize(SSISlave *ss, Error **errp) s->size = s->pi->sector_size * s->pi->n_sectors; s->dirty_page =-1 ; -/* FIXME use a qdev drive property instead of drive_get_next() */ - dinfo =drive_get_next (IF_MTD ); - -if (dinfo) { +if (s->blk) {DB_PRINT_L (0 ,"Binding to IF_MTD drive\n" ); - s->blk =blk_by_legacy_dinfo (dinfo); -blk_attach_dev_nofail (s->blk, s); - s->storage =blk_blockalign (s->blk, s->size);if (blk_pread (s->blk,0 , s->storage, s->size) != s->size) {
@@ -1187,6 +1180,7 @@ static Property m25p80_properties[] = {DEFINE_PROP_UINT8 ("spansion-cr2nv" , Flash, spansion_cr2nv,0x8 ),DEFINE_PROP_UINT8 ("spansion-cr3nv" , Flash, spansion_cr3nv,0x2 ),DEFINE_PROP_UINT8 ("spansion-cr4nv" , Flash, spansion_cr4nv,0x10 ), +DEFINE_PROP_DRIVE ("drive" , Flash, blk), DEFINE_PROP_END_OF_LIST(), };
hw/microblaze/petalogix_ml605_mmu.c +8 -1
@@ -191,9 +191,16 @@ petalogix_ml605_init(MachineState *machine) spi = (SSIBus *)qdev_get_child_bus (dev,"spi" );for (i =0 ; i <NUM_SPI_FLASHES ; i++) { +DriveInfo *dinfo =drive_get_next (IF_MTD );qemu_irq cs_line; - dev =ssi_create_slave (spi,"n25q128" ); + dev =ssi_create_slave_no_init (spi,"n25q128" ); +if (dinfo) { +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); + } +qdev_init_nofail (dev); + cs_line =qdev_get_gpio_in_named (dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (busdev, i+1 , cs_line); }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 02/23] target-arm/arm-semi.c: Fix SYS_HEAPINFO for 64-bit guests
In reply to Peter MaydellSYS_HEAPINFO is one of the few semihosting calls which has to write values back into a parameter block in memory. When we added support for 64-bit semihosting we updated the code which reads from the parameter block to read 64-bit words but forgot to change the code that writes back into the block. Update it to treat the block as a set of words of the appropriate width for the guest.
Message-id: [email protected]
--- target-arm/arm-semi.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
target-arm/arm-semi.c +26 -21
@@ -564,8 +564,10 @@ target_ulong do_arm_semihosting(CPUARMState *env) }case TARGET_SYS_HEAPINFO : { -uint32_t *ptr; +target_ulong retvals[4 ];uint32_t limit; +int i; +GET_ARG (0 );#ifdef CONFIG_USER_ONLY
@@ -587,30 +589,33 @@ target_ulong do_arm_semihosting(CPUARMState *env) ts->heap_limit = limit; } - ptr =lock_user (VERIFY_WRITE , arg0,16 ,0 ); -if (!ptr) { -/* FIXME - should this error code be -TARGET_EFAULT ? */ -return (uint32_t )-1 ; - } - ptr[0 ] =tswap32 (ts->heap_base); - ptr[1 ] =tswap32 (ts->heap_limit); - ptr[2 ] =tswap32 (ts->stack_base); - ptr[3 ] =tswap32 (0 );/* Stack limit. */ -unlock_user (ptr, arg0,16 ); + retvals[0 ] = ts->heap_base; + retvals[1 ] = ts->heap_limit; + retvals[2 ] = ts->stack_base; + retvals[3 ] =0 ;/* Stack limit. */ #else limit = ram_size; - ptr =lock_user (VERIFY_WRITE , arg0,16 ,0 ); -if (!ptr) { -/* FIXME - should this error code be -TARGET_EFAULT ? */ -return (uint32_t )-1 ; - }/* TODO: Make this use the limit of the loaded application. */ - ptr[0 ] =tswap32 (limit /2 ); - ptr[1 ] =tswap32 (limit); - ptr[2 ] =tswap32 (limit);/* Stack base */ - ptr[3 ] =tswap32 (0 );/* Stack limit. */ -unlock_user (ptr, arg0,16 ); + retvals[0 ] = limit /2 ; + retvals[1 ] = limit; + retvals[2 ] = limit;/* Stack base */ + retvals[3 ] =0 ;/* Stack limit. */ #endif + +for (i =0 ; i <ARRAY_SIZE (retvals); i++) { +bool fail; + +if (is_a64 (env)) { + fail =put_user_u64 (retvals[i], arg0 + i *8 ); + }else { + fail =put_user_u32 (retvals[i], arg0 + i *4 ); + } + +if (fail) { +/* Couldn't write back to argument block */ +return -1 ; + } + }return 0 ; }case TARGET_SYS_EXIT :
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 03/23] memory: Provide memory_region_init_rom()
In reply to Peter MaydellProvide a new helper function memory_region_init_rom() for memory regions which are read-only (and unlike those created by memory_region_init_rom_device() don't have special behaviour for writes). This has the same behaviour as calling memory_region_init_ram() and then memory_region_set_readonly() (which is what we do today in boards with pure ROMs) but is a more easily discoverable API for the purpose.
Message-id: [email protected]
--- docs/memory.txt | 9 +++++++-- include/exec/memory.h | 19 +++++++++++++++++++ memory.c | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-)
docs/memory.txt +7 -2
@@ -41,8 +41,13 @@ MemoryRegion): MemoryRegionOps structure describing the callbacks. - ROM: a ROM memory region works like RAM for reads (directly accessing - a region of host memory), but like MMIO for writes (invoking a callback). - You initialize these with memory_region_init_rom_device(). + a region of host memory), and forbids writes. You initialize these with + memory_region_init_rom(). + +- ROM device: a ROM device memory region works like RAM for reads + (directly accessing a region of host memory), but like MMIO for + writes (invoking a callback). You initialize these with + memory_region_init_rom_device(). - IOMMU region: an IOMMU region translates addresses of accesses made to it and forwards them to some other target memory region. As the name suggests,
include/exec/memory.h +19 -0
@@ -445,6 +445,25 @@ void memory_region_init_alias(MemoryRegion *mr, uint64_t size);/** +* memory_region_init_rom: Initialize a ROM memory region. +* +* This has the same effect as calling memory_region_init_ram() +* and then marking the resulting region read-only with +* memory_region_set_readonly(). +* +* @mr: the #MemoryRegion to be initialized. +* @owner: the object that tracks the region's reference count +* @name: the name of the region. +* @size: size of the region. +* @errp: pointer to Error*, to store an error if it happens. +*/ +void memory_region_init_rom (MemoryRegion *mr, +struct Object *owner, +const char *name, +uint64_t size, +Error **errp); + +/** * memory_region_init_rom_device: Initialize a ROM memory region. Writes are * handled via callbacks. *
memory.c +15 -0
@@ -1376,6 +1376,21 @@ void memory_region_init_alias(MemoryRegion *mr, mr->alias_offset = offset; } +void memory_region_init_rom (MemoryRegion *mr, +struct Object *owner, +const char *name, +uint64_t size, +Error **errp) +{ +memory_region_init (mr, owner, name, size); + mr->ram = true; + mr->readonly = true; + mr->terminates = true; + mr->destructor = memory_region_destructor_ram; + mr->ram_block =qemu_ram_alloc (size, mr, errp); + mr->dirty_log_mask =tcg_enabled () ? (1 <<DIRTY_MEMORY_CODE ) :0 ; +} + void memory_region_init_rom_device(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 05/23] memory: Assert that memory_region_init_rom_device() ops aren't NULL
In reply to Peter MaydellIt doesn't make sense to pass a NULL ops argument to memory_region_init_rom_device(), because the effect will be that if the guest tries to write to the memory region then QEMU will segfault. Catch the bug earlier by sanity checking the arguments to this function, and remove the misleading documentation that suggests that passing NULL might be sensible.
Message-id: [email protected]
--- include/exec/memory.h | 5 +---- memory.c | 1 + 2 files changed, 2 insertions(+), 4 deletions(-)
include/exec/memory.h +1 -4
@@ -467,12 +467,9 @@ void memory_region_init_rom(MemoryRegion *mr,* memory_region_init_rom_device: Initialize a ROM memory region. Writes are * handled via callbacks. * -* If NULL callbacks pointer is given, then I/O space is not supposed to be -* handled by QEMU itself. Any access via the memory API will cause an abort(). -* * @mr: the #MemoryRegion to be initialized. * @owner: the object that tracks the region's reference count -* @ops: callbacks for write access handling. +* @ops: callbacks for write access handling (must not be NULL). * @name: the name of the region. * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens.
memory.c +1 -0
@@ -1399,6 +1399,7 @@ void memory_region_init_rom_device(MemoryRegion *mr,uint64_t size, Error **errp) { +assert (ops );memory_region_init (mr, owner, name, size); mr->ops = ops; mr->opaque = opaque;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 07/23] hw/arm/virt: mark the PCIe host controller as DMA coherent in the DT
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Since QEMU performs cacheable accesses to guest memory when doing DMA as part of the implementation of emulated PCI devices, guest drivers should use cacheable accesses as well when running under KVM. Since this essentially means that emulated PCI devices are DMA coherent, set the 'dma-coherent' DT property on the PCIe host controller DT node.
This brings the DT description into line with the ACPI description, which already marks the PCI bridge as cache coherent (see commit bc64b96c984abf).
Message-id: [email protected]
--- hw/arm/virt.c | 1 + 1 file changed, 1 insertion(+)
hw/arm/virt.c +1 -0
@@ -1021,6 +1021,7 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,qemu_fdt_setprop_cell (vbi->fdt, nodename,"#size-cells" ,2 );qemu_fdt_setprop_cells (vbi->fdt, nodename,"bus-range" ,0 , nr_pcie_buses -1 ); +qemu_fdt_setprop (vbi->fdt, nodename,"dma-coherent" ,NULL ,0 );if (vbi->v2m_phandle) { qemu_fdt_setprop_cells(vbi->fdt, nodename, "msi-parent",
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 09/23] register: Add Register API
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
This API provides some encapsulation of registers and factors out some common functionality to common code. Bits of device state (usually MMIO registers) often have all sorts of access restrictions and semantics associated with them. This API allows you to define what those restrictions are on a bit-by-bit basis.
Helper functions are then used to access the register which observe the semantics defined by the RegisterAccessInfo struct.
Some features:
Bits can be marked as read_only (ro field)
Bits can be marked as write-1-clear (w1c field)
Bits can be marked as reserved (rsvd field)
Reset values can be defined (reset)
Bits can be marked clear on read (cor)
Pre and post action callbacks can be added to read and write ops Verbose debugging info can be enabled/disabled
Useful for defining device register spaces in a data driven way. Cuts down on a lot of the verbosity and repetition in the switch-case blocks in the standard foo_mmio_read/write functions.
Also useful for automated generation of device models from hardware design sources.
Message-id: 40d62c7e1bf6e63bb4193ec46b15092a7d981e59.1467053537.git.alistair.francis@xilinx.com
--- hw/core/Makefile.objs | 1 + hw/core/register.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/register.h | 112 +++++++++++++++++++++++++++++++++++ 3 files changed, 273 insertions(+) create mode 100644 hw/core/register.c create mode 100644 include/hw/register.h
hw/core/Makefile.objs +1 -0
@@ -15,4 +15,5 @@ common-obj-$(CONFIG_SOFTMMU) += machine.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o +common-obj-$(CONFIG_SOFTMMU) += register.o common-obj-$(CONFIG_PLATFORM_BUS) += platform-bus.o
hw/core/register.c new file +160 -0
160 lines not on this page · raw message
include/hw/register.h new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 18/23] m25p80: avoid out of bounds accesses
In reply to Peter MaydellFrom: Paolo Bonzini <[email protected]>
s->cur_addr can be made to point outside s->storage, either by writing a value >= 128 to s->ear (because s->ear * MAX_3BYTES_SIZE is a signed integer and sign-extends into the 64-bit cur_addr), or just by writing an address beyond the size of the flash being emulated. Avoid the sign extension to make the code cleaner, and on top of that mask s->cur_addr to s->size.
Message-id: [email protected] Reviewed by: Marcin Krzeminski <[email protected]>
--- hw/block/m25p80.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
hw/block/m25p80.c +7 -9
@@ -587,18 +587,16 @@ static inline int get_addr_length(Flash *s)static void complete_collecting_data (Flash *s) { -int i; - - s->cur_addr =0 ; +int i, n; -for (i =0 ; i <get_addr_length (s); ++i) { + n =get_addr_length (s); + s->cur_addr = (n ==3 ? s->ear :0 ); +for (i =0 ; i < n; ++i) { s->cur_addr <<=8 ; s->cur_addr |= s->data[i]; } -if (get_addr_length (s) ==3 ) { - s->cur_addr += s->ear *MAX_3BYTES_SIZE ; - } + s->cur_addr &= s->size -1 ; s->state =STATE_IDLE ;
@@ -1100,14 +1098,14 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)DB_PRINT_L (1 ,"page program cur_addr=%#" PRIx64" data=%" PRIx8"\n" , s->cur_addr, (uint8_t )tx);flash_write8 (s, s->cur_addr, (uint8_t )tx); - s->cur_addr++; + s->cur_addr = (s->cur_addr +1 ) & (s->size -1 );break ;case STATE_READ : r = s->storage[s->cur_addr];DB_PRINT_L (1 ,"READ 0x%" PRIx64"=%" PRIx8"\n" , s->cur_addr, (uint8_t )r); - s->cur_addr = (s->cur_addr +1 ) % s->size; + s->cur_addr = (s->cur_addr +1 ) & (s->size -1 );break ;case STATE_COLLECTING_DATA :
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 23/23] ast2400: create SPI flash slaves
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
A set of SPI flash slaves is attached under the flash controllers of the palmetto platform. "n25q256a" flash modules are used for the BMC and "mx25l25635e" for the host. These types are common in the OpenPower ecosystem.
Message-id: [email protected]
--- hw/arm/palmetto-bmc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
hw/arm/palmetto-bmc.c +31 -0
@@ -18,6 +18,8 @@#include "hw/arm/ast2400.h" #include "hw/boards.h" #include "qemu/log.h" +#include "sysemu/block-backend.h" +#include "sysemu/blockdev.h" static struct arm_boot_info palmetto_bmc_binfo = { .loader_start =AST2400_SDRAM_BASE ,
@@ -30,6 +32,32 @@ typedef struct PalmettoBMCState {MemoryRegion ram; } PalmettoBMCState; +static void palmetto_bmc_init_flashes (AspeedSMCState *s,const char *flashtype, +Error **errp) +{ +int i ; + +for (i =0 ; i < s->num_cs; ++i) { +AspeedSMCFlash *fl = &s->flashes[i]; +DriveInfo *dinfo =drive_get_next (IF_MTD ); +qemu_irq cs_line; + +/* +* FIXME: check that we are not using a flash module exceeding +* the controller segment size +*/ + fl->flash =ssi_create_slave_no_init (s->spi, flashtype); +if (dinfo) { +qdev_prop_set_drive (fl->flash,"drive" ,blk_by_legacy_dinfo (dinfo), + errp); + } +qdev_init_nofail (fl->flash); + + cs_line =qdev_get_gpio_in_named (fl->flash,SSI_GPIO_CS ,0 ); +sysbus_connect_irq (SYS_BUS_DEVICE (s), i +1 , cs_line); + } +} +static void palmetto_bmc_init (MachineState *machine) {PalmettoBMCState *bmc;
@@ -49,6 +77,9 @@ static void palmetto_bmc_init(MachineState *machine)object_property_set_bool (OBJECT (&bmc->soc), true,"realized" , &error_abort); +palmetto_bmc_init_flashes (&bmc->soc.smc,"n25q256a" , &error_abort); +palmetto_bmc_init_flashes (&bmc->soc.spi,"mx25l25635e" , &error_abort); + palmetto_bmc_binfo.kernel_filename = machine->kernel_filename; palmetto_bmc_binfo.initrd_filename = machine->initrd_filename; palmetto_bmc_binfo.kernel_cmdline = machine->kernel_cmdline;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 06/23] armv7m_nvic: Use qemu_get_cpu(0) instead of current_cpu
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Starting QEMU with -S results in current_cpu containing its initial value of NULL. It is however possible to connect to such QEMU instance and query various CPU registers, one example being CPUID, and doing that results in QEMU segfaulting.
Using qemu_get_cpu(0) seem reasonable enough given that ARMv7M architecture is a single core architecture.
--- hw/intc/armv7m_nvic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/intc/armv7m_nvic.c +4 -4
@@ -187,11 +187,11 @@ static uint32_t nvic_readl(nvic_state *s, uint32_t offset)case 0x1c :/* SysTick Calibration Value. */ return 10000 ;case 0xd00 :/* CPUID Base. */ - cpu =ARM_CPU (current_cpu); + cpu =ARM_CPU (qemu_get_cpu (0 ));return cpu->midr;case 0xd04 :/* Interrupt Control State. */ /* VECTACTIVE */ - cpu =ARM_CPU (current_cpu); + cpu =ARM_CPU (qemu_get_cpu (0 )); val = cpu->env.v7m.exception;if (val ==1023 ) { val =0 ;
@@ -222,7 +222,7 @@ static uint32_t nvic_readl(nvic_state *s, uint32_t offset) val |= (1 <<31 );return val;case 0xd08 :/* Vector Table Offset. */ - cpu =ARM_CPU (current_cpu); + cpu =ARM_CPU (qemu_get_cpu (0 ));return cpu->env.v7m.vecbase;case 0xd0c :/* Application Interrupt/Reset Control. */ return 0xfa050000 ;
@@ -349,7 +349,7 @@ static void nvic_writel(nvic_state *s, uint32_t offset, uint32_t value) }break ;case 0xd08 :/* Vector Table Offset. */ - cpu =ARM_CPU (current_cpu); + cpu =ARM_CPU (qemu_get_cpu (0 )); cpu->env.v7m.vecbase = value &0xffffff80 ;break ;case 0xd0c :/* Application Interrupt/Reset Control. */
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 22/23] ast2400: add SPI flash slaves
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Each controller on the ast2400 has a memory range on which it maps its flash module slaves. Each slave is assigned a memory segment for its mapping that can be changed at bootime with the Segment Address Register. This is not supported in the current implementation so we are using the defaults provided by the specs.
Each SPI flash slave can then be accessed in two modes: Command and User. When in User mode, accesses to the memory segment of the slaves are translated in SPI transfers. When in Command mode, the HW generates the SPI commands automatically and the memory segment is accessed as if doing a MMIO. Other SPI controllers call that mode linear addressing mode.
For this purpose, we are adding below each crontoller an array of structs gathering for each SPI flash module, a segment rank, a MemoryRegion to handle the memory accesses and the associated SPI slave device, which should be a m25p80.
Only the User mode is supported for now but we are preparing ground for the Command mode. The framework is sufficient to support Linux.
Message-id: [email protected]
--- hw/arm/ast2400.c | 5 ++ hw/ssi/aspeed_smc.c | 150 +++++++++++++++++++++++++++++++++++++++++++- include/hw/ssi/aspeed_smc.h | 21 +++++++ 3 files changed, 173 insertions(+), 3 deletions(-)
hw/arm/ast2400.c +5 -0
@@ -31,6 +31,9 @@#define AST2400_TIMER_BASE 0x1E782000#define AST2400_I2C_BASE 0x1E78A000 +#define AST2400_FMC_FLASH_BASE 0x20000000 +#define AST2400_SPI_FLASH_BASE 0x30000000 +#define AST2400_A0_SILICON_REV 0x02000303static const int uart_irqs[] = {9 ,32 ,33 ,34 ,10 };
@@ -168,6 +171,7 @@ static void ast2400_realize(DeviceState *dev, Error **errp)return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->smc),0 ,AST2400_FMC_BASE ); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->smc),1 ,AST2400_FMC_FLASH_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->smc),0 ,qdev_get_gpio_in (DEVICE (&s->vic),19 ));
@@ -180,6 +184,7 @@ static void ast2400_realize(DeviceState *dev, Error **errp)return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi),0 ,AST2400_SPI_BASE ); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi),1 ,AST2400_SPI_FLASH_BASE ); }static void ast2400_class_init (ObjectClass *oc,void *data)
hw/ssi/aspeed_smc.c +147 -3
172 lines not on this page · raw message
include/hw/ssi/aspeed_smc.h +21 -0
@@ -27,6 +27,12 @@#include "hw/ssi/ssi.h" +typedef struct AspeedSegments { +hwaddr addr; +uint32_t size; +}AspeedSegments ; + +struct AspeedSMCState ; typedef struct AspeedSMCController { const char *name; uint8_t r_conf;
@@ -35,8 +41,20 @@ typedef struct AspeedSMCController {uint8_t r_timings;uint8_t conf_enable_w0;uint8_t max_slaves; +const AspeedSegments *segments; +uint32_t mapping_window_size; } AspeedSMCController; +typedef struct AspeedSMCFlash { +const struct AspeedSMCState *controller; + +uint8_t id; +uint32_t size; + +MemoryRegion mmio; +DeviceState *flash; +}AspeedSMCFlash ; +#define TYPE_ASPEED_SMC "aspeed.smc"#define ASPEED_SMC (obj) OBJECT_CHECK(AspeedSMCState, (obj), TYPE_ASPEED_SMC)#define ASPEED_SMC_CLASS (klass) \
@@ -57,6 +75,7 @@ typedef struct AspeedSMCState {const AspeedSMCController *ctrl;MemoryRegion mmio; +MemoryRegion mmio_flash;qemu_irq irq;int irqline;
@@ -74,6 +93,8 @@ typedef struct AspeedSMCState {uint8_t r_ctrl0;uint8_t r_timings;uint8_t conf_enable_w0; + + AspeedSMCFlash *flashes; } AspeedSMCState;#endif /* ASPEED_SMC_H */
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 14/23] dma: Add Xilinx Zynq devcfg device model
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
Add a minimal model for the devcfg device which is part of Zynq. This model supports DMA capabilities and interrupt generation.
Message-id: 83df49d8fa2d203a421ca71620809e4b04754e65.1467053537.git.alistair.francis@xilinx.com
--- default-configs/arm-softmmu.mak | 1 + hw/dma/Makefile.objs | 1 + hw/dma/xlnx-zynq-devcfg.c | 400 ++++++++++++++++++++++++++++++++++++++ include/hw/dma/xlnx-zynq-devcfg.h | 62 ++++++ 4 files changed, 464 insertions(+) create mode 100644 hw/dma/xlnx-zynq-devcfg.c create mode 100644 include/hw/dma/xlnx-zynq-devcfg.h
default-configs/arm-softmmu.mak +1 -0
@@ -66,6 +66,7 @@ CONFIG_PXA2XX=y CONFIG_BITBANG_I2C=y CONFIG_FRAMEBUFFER=y CONFIG_XILINX_SPIPS=y +CONFIG_ZYNQ_DEVCFG=y CONFIG_ARM11SCU=y CONFIG_A9SCU=y
hw/dma/Makefile.objs +1 -0
@@ -5,6 +5,7 @@ common-obj-$(CONFIG_PL330) += pl330.o common-obj-$(CONFIG_I82374) += i82374.o common-obj-$(CONFIG_I8257) += i8257.o common-obj-$(CONFIG_XILINX_AXI) += xilinx_axidma.o +common-obj-$(CONFIG_ZYNQ_DEVCFG) += xlnx-zynq-devcfg.o common-obj-$(CONFIG_ETRAXFS) += etraxfs_dma.o common-obj-$(CONFIG_STP2000) += sparc32_dma.o common-obj-$(CONFIG_SUN4M) += sun4m_iommu.o
hw/dma/xlnx-zynq-devcfg.c new file +400 -0
400 lines not on this page · raw message
include/hw/dma/xlnx-zynq-devcfg.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 21/23] ast2400: add SMC controllers (FMC and SPI)
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The Aspeed AST2400 soc includes a static memory controller for the BMC which supports NOR, NAND and SPI flash memory modules. This controller has two modes : the SMC for the legacy interface which supports only one module and the FMC for the new interface which supports up to five modules. The AST2400 also includes a SPI only controller used for the host firmware, commonly called BIOS on Intel. It can be used in three mode : a SPI master, SPI slave and SPI pass-through
Below is the initial framework for the SMC controller (FMC mode only) and the SPI controller: the sysbus object, MMIO for registers configuration and controls. Each controller has a SPI bus and a configurable number of CS lines for SPI flash slaves.
The differences between the controllers are small, so they are abstracted using indirections on the register numbers.
Only SPI flash modules are supported.
Message-id: [email protected]
--- hw/arm/ast2400.c | 35 ++++- hw/ssi/Makefile.objs | 1 + hw/ssi/aspeed_smc.c | 326 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/ast2400.h | 3 + include/hw/ssi/aspeed_smc.h | 79 +++++++++++ 5 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 hw/ssi/aspeed_smc.c create mode 100644 include/hw/ssi/aspeed_smc.h
hw/arm/ast2400.c +34 -1
@@ -23,6 +23,9 @@#define AST2400_UART_5_BASE 0x00184000#define AST2400_IOMEM_SIZE 0x00200000#define AST2400_IOMEM_BASE 0x1E600000 +#define AST2400_SMC_BASE AST2400_IOMEM_BASE/* Legacy SMC */ +#define AST2400_FMC_BASE 0X1E620000 +#define AST2400_SPI_BASE 0X1E630000#define AST2400_VIC_BASE 0x1E6C0000#define AST2400_SCU_BASE 0x1E6E2000#define AST2400_TIMER_BASE 0x1E782000
@@ -85,13 +88,21 @@ static void ast2400_init(Object *obj) "hw-strap1", &error_abort);object_property_add_alias (obj,"hw-strap2" ,OBJECT (&s->scu),"hw-strap2" , &error_abort); + +object_initialize (&s->smc,sizeof (s->smc),"aspeed.smc.fmc" ); +object_property_add_child (obj,"smc" ,OBJECT (&s->smc),NULL ); +qdev_set_parent_bus (DEVICE (&s->smc),sysbus_get_default ()); + +object_initialize (&s->spi,sizeof (s->spi),"aspeed.smc.spi" ); +object_property_add_child (obj,"spi" ,OBJECT (&s->spi),NULL ); +qdev_set_parent_bus (DEVICE (&s->spi),sysbus_get_default ()); }static void ast2400_realize (DeviceState *dev,Error **errp) {int i;AST2400State *s =AST2400 (dev); -Error *err =NULL ; +Error *err =NULL , *local_err =NULL ;/* IO space */ memory_region_init_io(&s->iomem, NULL, &ast2400_io_ops, NULL,
@@ -147,6 +158,28 @@ static void ast2400_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,AST2400_I2C_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 ,qdev_get_gpio_in (DEVICE (&s->vic),12 )); + +/* SMC */ +object_property_set_int (OBJECT (&s->smc),1 ,"num-cs" , &err); +object_property_set_bool (OBJECT (&s->smc), true,"realized" , &local_err); +error_propagate (&err, local_err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->smc),0 ,AST2400_FMC_BASE ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->smc),0 , +qdev_get_gpio_in (DEVICE (&s->vic),19 )); + +/* SPI */ +object_property_set_int (OBJECT (&s->spi),1 ,"num-cs" , &err); +object_property_set_bool (OBJECT (&s->spi), true,"realized" , &local_err); +error_propagate (&err, local_err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi),0 ,AST2400_SPI_BASE ); }static void ast2400_class_init (ObjectClass *oc,void *data)
hw/ssi/Makefile.objs +1 -0
@@ -2,6 +2,7 @@ common-obj-$(CONFIG_PL022) += pl022.o common-obj-$(CONFIG_SSI) += ssi.o common-obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o common-obj-$(CONFIG_XILINX_SPIPS) += xilinx_spips.o +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_smc.o obj-$(CONFIG_OMAP) += omap_spi.o obj-$(CONFIG_IMX) += imx_spi.o
hw/ssi/aspeed_smc.c new file +326 -0
326 lines not on this page · raw message
include/hw/arm/ast2400.h +3 -0
@@ -17,6 +17,7 @@#include "hw/misc/aspeed_scu.h" #include "hw/timer/aspeed_timer.h" #include "hw/i2c/aspeed_i2c.h" +#include "hw/ssi/aspeed_smc.h" typedef struct AST2400State { /*< private >*/
@@ -29,6 +30,8 @@ typedef struct AST2400State {AspeedTimerCtrlState timerctrl;AspeedI2CState i2c;AspeedSCUState scu; +AspeedSMCState smc; +AspeedSMCState spi; } AST2400State;#define TYPE_AST2400 "ast2400"
include/hw/ssi/aspeed_smc.h new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 17/23] m25p80: do not put iovec on the stack
In reply to Peter MaydellFrom: Paolo Bonzini <[email protected]>
When doing a read-modify-write cycle, QEMU uses the iovec after returning from blk_aio_pwritev. m25p80 puts the iovec on the stack of blk_aio_pwritev's caller, which causes trouble in this case. This has been a problem since commit 243e6f6 ("m25p80: Switch to byte-based block access", 2016-05-12) started doing writes at a smaller granularity than 512 bytes. In principle however it could have broken before when using -drive if=mtd,cache=none on a disk with 4K native sectors.
Message-id: [email protected]
--- hw/block/m25p80.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
hw/block/m25p80.c +14 -9
@@ -447,6 +447,11 @@ static inline Manufacturer get_man(Flash *s)static void blk_sync_complete (void *opaque,int ret) { +QEMUIOVector *iov = opaque; + +qemu_iovec_destroy (iov); +g_free (iov); +/* do nothing. Masters do not directly interact with the backing store, * only the working copy so no mutexing required. */
@@ -454,31 +459,31 @@ static void blk_sync_complete(void *opaque, int ret)static void flash_sync_page (Flash *s,int page) { -QEMUIOVector iov; +QEMUIOVector *iov =g_new (QEMUIOVector,1 );if (!s->blk ||blk_is_read_only (s->blk)) {return ; } -qemu_iovec_init (&iov,1 ); -qemu_iovec_add (&iov, s->storage + page * s->pi->page_size, +qemu_iovec_init (iov,1 ); +qemu_iovec_add (iov, s->storage + page * s->pi->page_size, s->pi->page_size); -blk_aio_pwritev (s->blk, page * s->pi->page_size, &iov,0 , - blk_sync_complete,NULL ); +blk_aio_pwritev (s->blk, page * s->pi->page_size, iov,0 , + blk_sync_complete, iov); }static inline void flash_sync_area (Flash *s,int64_t off,int64_t len) { -QEMUIOVector iov; +QEMUIOVector *iov =g_new (QEMUIOVector,1 );if (!s->blk ||blk_is_read_only (s->blk)) {return ; }assert (!(len %BDRV_SECTOR_SIZE )); -qemu_iovec_init (&iov,1 ); -qemu_iovec_add (&iov, s->storage + off, len); -blk_aio_pwritev (s->blk, off, &iov,0 , blk_sync_complete,NULL ); +qemu_iovec_init (iov,1 ); +qemu_iovec_add (iov, s->storage + off, len); +blk_aio_pwritev (s->blk, off, iov,0 , blk_sync_complete, iov); }static void flash_erase (Flash *s,int offset,FlashCMD cmd)
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 15/23] xilinx_zynq: Connect devcfg to the Zynq machine model
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
Message-id: 85f39c9a13569b1113dacac3b952b0af54fc1260.1467053537.git.alistair.francis@xilinx.com
--- hw/arm/xilinx_zynq.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/arm/xilinx_zynq.c +6 -0
@@ -294,6 +294,12 @@ static void zynq_init(MachineState *machine)sysbus_connect_irq (busdev, n +1 , pic[dma_irqs[n] -IRQ_OFFSET ]); } + dev =qdev_create (NULL ,"xlnx.ps7-dev-cfg" ); +qdev_init_nofail (dev); + busdev =SYS_BUS_DEVICE (dev); +sysbus_connect_irq (busdev,0 , pic[40 -IRQ_OFFSET ]); +sysbus_mmio_map (busdev,0 ,0xF8007000 ); + zynq_binfo.ram_size = ram_size; zynq_binfo.kernel_filename = kernel_filename; zynq_binfo.kernel_cmdline = kernel_cmdline;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 04/23] imx: Use memory_region_init_rom() for ROMs
In reply to Peter MaydellThe imx boards were all incorrectly creating ROMs using memory_region_init_rom_device() with a NULL ops pointer. This will cause QEMU to abort if the guest tries to write to the ROM. Switch to the new memory_region_init_rom() instead.
Message-id: [email protected]
--- hw/arm/fsl-imx25.c | 8 ++++---- hw/arm/fsl-imx31.c | 9 ++++----- hw/arm/fsl-imx6.c | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-)
hw/arm/fsl-imx25.c +4 -4
@@ -249,16 +249,16 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) }/* initialize 2 x 16 KB ROM */ -memory_region_init_rom_device (&s->rom[0 ],NULL ,NULL ,NULL , -"imx25.rom0" ,FSL_IMX25_ROM0_SIZE , &err); +memory_region_init_rom (&s->rom[0 ],NULL , +"imx25.rom0" ,FSL_IMX25_ROM0_SIZE , &err);if (err) {error_propagate (errp, err);return ; }memory_region_add_subregion (get_system_memory (),FSL_IMX25_ROM0_ADDR , &s->rom[0 ]); -memory_region_init_rom_device (&s->rom[1 ],NULL ,NULL ,NULL , -"imx25.rom1" ,FSL_IMX25_ROM1_SIZE , &err); +memory_region_init_rom (&s->rom[1 ],NULL , +"imx25.rom1" ,FSL_IMX25_ROM1_SIZE , &err);if (err) {error_propagate (errp, err);return ;
hw/arm/fsl-imx31.c +4 -5
@@ -219,9 +219,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) }/* On a real system, the first 16k is a `secure boot rom' */ -memory_region_init_rom_device (&s->secure_rom,NULL ,NULL ,NULL , -"imx31.secure_rom" , -FSL_IMX31_SECURE_ROM_SIZE , &err); +memory_region_init_rom (&s->secure_rom,NULL ,"imx31.secure_rom" , +FSL_IMX31_SECURE_ROM_SIZE , &err);if (err) {error_propagate (errp, err);return ;
@@ -230,8 +229,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) &s->secure_rom);/* There is also a 16k ROM */ -memory_region_init_rom_device (&s->rom,NULL ,NULL ,NULL ,"imx31.rom" , -FSL_IMX31_ROM_SIZE , &err); +memory_region_init_rom (&s->rom,NULL ,"imx31.rom" , +FSL_IMX31_ROM_SIZE , &err);if (err) {error_propagate (errp, err);return ;
hw/arm/fsl-imx6.c +4 -4
@@ -399,8 +399,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) FSL_IMX6_ENET_MAC_1588_IRQ));/* ROM memory */ -memory_region_init_rom_device (&s->rom,NULL ,NULL ,NULL ,"imx6.rom" , -FSL_IMX6_ROM_SIZE , &err); +memory_region_init_rom (&s->rom,NULL ,"imx6.rom" , +FSL_IMX6_ROM_SIZE , &err);if (err) {error_propagate (errp, err);return ;
@@ -409,8 +409,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) &s->rom);/* CAAM memory */ -memory_region_init_rom_device (&s->caam,NULL ,NULL ,NULL ,"imx6.caam" , -FSL_IMX6_CAAM_MEM_SIZE , &err); +memory_region_init_rom (&s->caam,NULL ,"imx6.caam" , +FSL_IMX6_CAAM_MEM_SIZE , &err);if (err) {error_propagate (errp, err);return ;
Signature · 1 line
1.9.1
Peter Maydell
AppliedQuoted 32 lines · Peter Maydell
target-arm queue: the data driven register API patchset, plus the AST2400 SMC/SPIU patchset, and a pile of bugfixes. I have some more stuff in my to-review queue but I wanted to get this lot out first.
thanks
-- PMMThe following changes since commit
e2c8f9e44e07d8210049abaa6042ec3c956f1dd4:Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2016-07-04 10:49:17 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20160704for you to fetch changes up to
e1ad9bc405afbd7581831ca1705f39e73c94c5ff:ast2400: create SPI flash slaves (2016-07-04 13:15:22 +0100)
----------------------------------------------------------------
target-arm queue:
* fix semihostingSYS_HEAPINFOcall for A64 guests
* fix crash if guest tries to write to ROM on imx boards
*armv7m_nvic: fix crash for debugger reads from some registers
* virt: mark PCIe host controller as dma-coherent in the DT
* add data-driven register API
* Xilinx Zynq: add devcfg device model
* m25p80: fix various bugs
* ast2400: add SMC controllers and SPI flash slaves
Quoted 1 line
----------------------------------------------------------------
Applied, thanks.
-- PMM