arm-devs queue
This is a smallish pullreq for a few arm-devs patches which have been on the list for a while. The two patches from Mark were in the highbank patchset, but I'd like to get them committed now because they're needed for other patchsets (vexpress-a15, exynos). Please pull.
thanks
-- PMM
The following changes since commit 8c4ec5c0269bda18bb777a64b2008088d1c632dc:
pxa2xx_keypad: fix unbalanced parenthesis. (2012-01-17 02:14:42 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git arm-devs.for-upstream
Mark Langsdorf (2):
arm: Remove incorrect comment in arm_timer
arm: make the number of GIC interrupts configurable
Peter Maydell (2):
vexpress, realview: Add (dummy) L2 cache controller hw/lan9118: Add save/load support
hw/a9mpcore.c | 13 ++++- hw/arm11mpcore.c | 17 +++++--- hw/arm_gic.c | 68 ++++++++++++++++------------- hw/arm_timer.c | 3 - hw/armv7m_nvic.c | 31 ++++++++++--- hw/lan9118.c | 126 +++++++++++++++++++++++++++++++++++++++++++---------- hw/realview.c | 2 + hw/realview_gic.c | 7 ++- hw/vexpress.c | 1 + 9 files changed, 193 insertions(+), 75 deletions(-)
PATCH 1/4 vexpress, realview: Add (dummy) L2 cache controller
Instantiate the L2 cache controller on the ARM devboards which have one, since we have a dummy model of it now. Note that the only non-MP board with an L2x0 is the PB1176, which we don't model.
--- hw/realview.c | 2 ++ hw/vexpress.c | 1 + 2 files changed, 3 insertions(+), 0 deletions(-)
hw/realview.c +2 -0
@@ -227,6 +227,8 @@ static void realview_init(ram_addr_t ram_size,for (n =0 ; n < smp_cpus; n++) {sysbus_connect_irq (busdev, n, cpu_irq[n]); } +sysbus_create_varargs ("l2x0" , realview_binfo.smp_priv_base +0x2000 , +NULL ); }else {uint32_t gic_addr = is_pb ?0x1e000000 :0x10040000 ;/* For now just create the nIRQ GIC, and ignore the others. */
hw/vexpress.c +1 -0
@@ -182,6 +182,7 @@ static void vexpress_a9_init(ram_addr_t ram_size,/* 0x100ec000 TrustZone Address Space Controller */ /* 0x10200000 CoreSight debug APB */ /* 0x1e00a000 PL310 L2 Cache Controller */ +sysbus_create_varargs ("l2x0" ,0x1e00a000 ,NULL );/* CS0: NOR0 flash : 0x40000000 .. 0x44000000 */ /* CS4: NOR1 flash : 0x44000000 .. 0x48000000 */
Signature · 1 line
1.7.1
PATCH 2/4 arm: Remove incorrect comment in arm_timer
In reply to Peter MaydellFrom: Mark Langsdorf <[email protected]>
The current comment says that the arm_timers are restricted to between 32 KHz and 1 MHz, but sp804 TRM does not specify those limits.
--- hw/arm_timer.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
hw/arm_timer.c +0 -3
@@ -273,11 +273,8 @@ static int sp804_init(SysBusDevice *dev) qi =qemu_allocate_irqs (sp804_set_irq, s,2 );sysbus_init_irq (dev, &s->irq); -/* The timers are configurable between 32kHz and 1MHz -* defaulting to 1MHz but overrideable as individual properties */ s->timer[0 ] =arm_timer_init (s->freq0); s->timer[1 ] =arm_timer_init (s->freq1); - s->timer[0 ]->irq = qi[0 ]; s->timer[1 ]->irq = qi[1 ];memory_region_init_io (&s->iomem, &sp804_ops, s,"sp804" ,0x1000 );
Signature · 1 line
1.7.1
PATCH 3/4 hw/lan9118: Add save/load support
In reply to Peter MaydellImplement save/load for the LAN9118.
--- hw/lan9118.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 103 insertions(+), 23 deletions(-)
hw/lan9118.c +103 -23
@@ -140,17 +140,36 @@ enum tx_state { };typedef struct { -enum tx_state state; +/* state is a tx_state but we can't put enums in VMStateDescriptions. */ +uint32_t state;uint32_t cmd_a;uint32_t cmd_b; -int buffer_size; -int offset; -int pad; -int fifo_used; -int len; +int32_t buffer_size; +int32_t offset; +int32_t pad; +int32_t fifo_used; +int32_t len;uint8_t data[2048 ]; }LAN9118Packet ; +static const VMStateDescription vmstate_lan9118_packet = { + .name ="lan9118_packet" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (state, LAN9118Packet), +VMSTATE_UINT32 (cmd_a, LAN9118Packet), +VMSTATE_UINT32 (cmd_b, LAN9118Packet), +VMSTATE_INT32 (buffer_size, LAN9118Packet), +VMSTATE_INT32 (offset, LAN9118Packet), +VMSTATE_INT32 (pad, LAN9118Packet), +VMSTATE_INT32 (fifo_used, LAN9118Packet), +VMSTATE_INT32 (len, LAN9118Packet), +VMSTATE_UINT8_ARRAY (data, LAN9118Packet,2048 ), +VMSTATE_END_OF_LIST () + } +}; + typedef struct { SysBusDevice busdev; NICState *nic;
@@ -190,34 +209,95 @@ typedef struct {uint32_t phy_int;uint32_t phy_int_mask; -int eeprom_writable; +int32_t eeprom_writable;uint8_t eeprom[128 ]; -int tx_fifo_size; +int32_t tx_fifo_size;LAN9118Packet *txp;LAN9118Packet tx_packet; -int tx_status_fifo_used; -int tx_status_fifo_head; +int32_t tx_status_fifo_used; +int32_t tx_status_fifo_head;uint32_t tx_status_fifo[512 ]; -int rx_status_fifo_size; -int rx_status_fifo_used; -int rx_status_fifo_head; +int32_t rx_status_fifo_size; +int32_t rx_status_fifo_used; +int32_t rx_status_fifo_head;uint32_t rx_status_fifo[896 ]; -int rx_fifo_size; -int rx_fifo_used; -int rx_fifo_head; +int32_t rx_fifo_size; +int32_t rx_fifo_used; +int32_t rx_fifo_head;uint32_t rx_fifo[3360 ]; -int rx_packet_size_head; -int rx_packet_size_tail; -int rx_packet_size[1024 ]; +int32_t rx_packet_size_head; +int32_t rx_packet_size_tail; +int32_t rx_packet_size[1024 ]; -int rxp_offset; -int rxp_size; -int rxp_pad; +int32_t rxp_offset; +int32_t rxp_size; +int32_t rxp_pad; } lan9118_state; +static const VMStateDescription vmstate_lan9118 = { + .name ="lan9118" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_PTIMER (timer, lan9118_state), +VMSTATE_UINT32 (irq_cfg, lan9118_state), +VMSTATE_UINT32 (int_sts, lan9118_state), +VMSTATE_UINT32 (int_en, lan9118_state), +VMSTATE_UINT32 (fifo_int, lan9118_state), +VMSTATE_UINT32 (rx_cfg, lan9118_state), +VMSTATE_UINT32 (tx_cfg, lan9118_state), +VMSTATE_UINT32 (hw_cfg, lan9118_state), +VMSTATE_UINT32 (pmt_ctrl, lan9118_state), +VMSTATE_UINT32 (gpio_cfg, lan9118_state), +VMSTATE_UINT32 (gpt_cfg, lan9118_state), +VMSTATE_UINT32 (word_swap, lan9118_state), +VMSTATE_UINT32 (free_timer_start, lan9118_state), +VMSTATE_UINT32 (mac_cmd, lan9118_state), +VMSTATE_UINT32 (mac_data, lan9118_state), +VMSTATE_UINT32 (afc_cfg, lan9118_state), +VMSTATE_UINT32 (e2p_cmd, lan9118_state), +VMSTATE_UINT32 (e2p_data, lan9118_state), +VMSTATE_UINT32 (mac_cr, lan9118_state), +VMSTATE_UINT32 (mac_hashh, lan9118_state), +VMSTATE_UINT32 (mac_hashl, lan9118_state), +VMSTATE_UINT32 (mac_mii_acc, lan9118_state), +VMSTATE_UINT32 (mac_mii_data, lan9118_state), +VMSTATE_UINT32 (mac_flow, lan9118_state), +VMSTATE_UINT32 (phy_status, lan9118_state), +VMSTATE_UINT32 (phy_control, lan9118_state), +VMSTATE_UINT32 (phy_advertise, lan9118_state), +VMSTATE_UINT32 (phy_int, lan9118_state), +VMSTATE_UINT32 (phy_int_mask, lan9118_state), +VMSTATE_INT32 (eeprom_writable, lan9118_state), +VMSTATE_UINT8_ARRAY (eeprom, lan9118_state,128 ), +VMSTATE_INT32 (tx_fifo_size, lan9118_state), +/* txp always points at tx_packet so need not be saved */ +VMSTATE_STRUCT (tx_packet, lan9118_state,0 , + vmstate_lan9118_packet, LAN9118Packet), +VMSTATE_INT32 (tx_status_fifo_used, lan9118_state), +VMSTATE_INT32 (tx_status_fifo_head, lan9118_state), +VMSTATE_UINT32_ARRAY (tx_status_fifo, lan9118_state,512 ), +VMSTATE_INT32 (rx_status_fifo_size, lan9118_state), +VMSTATE_INT32 (rx_status_fifo_used, lan9118_state), +VMSTATE_INT32 (rx_status_fifo_head, lan9118_state), +VMSTATE_UINT32_ARRAY (rx_status_fifo, lan9118_state,896 ), +VMSTATE_INT32 (rx_fifo_size, lan9118_state), +VMSTATE_INT32 (rx_fifo_used, lan9118_state), +VMSTATE_INT32 (rx_fifo_head, lan9118_state), +VMSTATE_UINT32_ARRAY (rx_fifo, lan9118_state,3360 ), +VMSTATE_INT32 (rx_packet_size_head, lan9118_state), +VMSTATE_INT32 (rx_packet_size_tail, lan9118_state), +VMSTATE_INT32_ARRAY (rx_packet_size, lan9118_state,1024 ), +VMSTATE_INT32 (rxp_offset, lan9118_state), +VMSTATE_INT32 (rxp_size, lan9118_state), +VMSTATE_INT32 (rxp_pad, lan9118_state), +VMSTATE_END_OF_LIST () + } +}; +static void lan9118_update (lan9118_state *s) {int level;
@@ -1155,7 +1235,6 @@ static int lan9118_init1(SysBusDevice *dev)ptimer_set_freq (s->timer,10000 );ptimer_set_limit (s->timer,0xffff ,1 ); -/* ??? Save/restore. */ return 0 ; }
@@ -1164,6 +1243,7 @@ static SysBusDeviceInfo lan9118_info = { .qdev.name = "lan9118", .qdev.size = sizeof(lan9118_state), .qdev.reset = lan9118_reset, + .qdev.vmsd = &vmstate_lan9118, .qdev.props = (Property []) {DEFINE_NIC_PROPERTIES (lan9118_state, conf),DEFINE_PROP_END_OF_LIST (),
Signature · 1 line
1.7.1
PATCH 4/4 arm: make the number of GIC interrupts configurable
In reply to Peter MaydellFrom: Mark Langsdorf <[email protected]>
Increase the maximum number of GIC interrupts for a9mp and a11mp to 1020, and create a configurable property for each defaulting to 96 and 64 (respectively) so that device modelers can set the value appropriately for their SoC. Other ARM processors also set their maximum number of used IRQs appropriately.
Set the maximum theoretical number of GIC interrupts to 1020 and update the save/restore code to only use the appropriate number for each SoC.
--- hw/a9mpcore.c | 13 +++++++-- hw/arm11mpcore.c | 17 ++++++++---- hw/arm_gic.c | 68 +++++++++++++++++++++++++++++----------------------- hw/armv7m_nvic.c | 31 ++++++++++++++++++------ hw/realview_gic.c | 7 ++++- 5 files changed, 87 insertions(+), 49 deletions(-)
hw/a9mpcore.c +10 -3
@@ -11,9 +11,8 @@#include "sysbus.h" /* Configuration for arm_gic.c: -* number of external IRQ lines, max number of CPUs, how to ID current CPU +* max number of CPUs, how to ID current CPU */ -#define GIC_NIRQ 96#define NCPU 4 static inline int
@@ -37,6 +36,7 @@ typedef struct a9mp_priv_state {MemoryRegion ptimer_iomem;MemoryRegion container;DeviceState *mptimer; +uint32_t num_irq; } a9mp_priv_state; static uint64_t a9_scu_read(void *opaque, target_phys_addr_t offset,
@@ -153,7 +153,7 @@ static int a9mp_priv_init(SysBusDevice *dev)hw_error ("a9mp_priv_init: num-cpu may not be more than %d\n" ,NCPU ); } -gic_init (&s->gic, s->num_cpu); +gic_init (&s->gic, s->num_cpu, s->num_irq); s->mptimer =qdev_create (NULL ,"arm_mptimer" );qdev_prop_set_uint32 (s->mptimer,"num-cpu" , s->num_cpu);
@@ -216,6 +216,13 @@ static SysBusDeviceInfo a9mp_priv_info = { .qdev.reset = a9mp_priv_reset, .qdev.props = (Property []) {DEFINE_PROP_UINT32 ("num-cpu" , a9mp_priv_state, num_cpu,1 ), +/* The Cortex-A9MP may have anything from 0 to 224 external interrupt +* IRQ lines (with another 32 internal). We default to 64+32, which +* is the number provided by the Cortex-A9MP test chip in the +* Realview PBX-A9 and Versatile Express A9 development boards. +* Other boards may differ and should set this property appropriately. +*/ +DEFINE_PROP_UINT32 ("num-irq" , a9mp_priv_state, num_irq,96 ),DEFINE_PROP_END_OF_LIST (), } };
hw/arm11mpcore.c +11 -6
@@ -10,11 +10,6 @@#include "sysbus.h" #include "qemu-timer.h" -/* ??? The MPCore TRM says the on-chip controller has 224 external IRQ lines -(+ 32 internal). However my test chip only exposes/reports 32. -More importantly Linux falls over if more than 32 are present! */ -#define GIC_NIRQ 64 -#define NCPU 4 static inline int
@@ -37,6 +32,7 @@ typedef struct mpcore_priv_state {MemoryRegion iomem;MemoryRegion container;DeviceState *mptimer; +uint32_t num_irq; } mpcore_priv_state;/* Per-CPU private memory mapped IO. */
@@ -132,7 +128,7 @@ static int mpcore_priv_init(SysBusDevice *dev) {mpcore_priv_state *s =FROM_SYSBUSGIC (mpcore_priv_state, dev); -gic_init (&s->gic, s->num_cpu); +gic_init (&s->gic, s->num_cpu, s->num_irq); s->mptimer =qdev_create (NULL ,"arm_mptimer" );qdev_prop_set_uint32 (s->mptimer,"num-cpu" , s->num_cpu);qdev_init_nofail (s->mptimer);
@@ -221,6 +217,15 @@ static SysBusDeviceInfo mpcore_priv_info = { .qdev.size = sizeof(mpcore_priv_state), .qdev.props = (Property []) {DEFINE_PROP_UINT32 ("num-cpu" , mpcore_priv_state, num_cpu,1 ), +/* The ARM11 MPCORE TRM says the on-chip controller may have +* anything from 0 to 224 external interrupt IRQ lines (with another +* 32 internal). We default to 32+32, which is the number provided by +* the ARM11 MPCore test chip in the Realview Versatile Express +* coretile. Other boards may differ and should set this property +* appropriately. Some Linux kernels may not boot if the hardware +* has more IRQ lines than the kernel expects. +*/ +DEFINE_PROP_UINT32 ("num-irq" , mpcore_priv_state, num_irq,64 ),DEFINE_PROP_END_OF_LIST (), } };
hw/arm_gic.c +38 -30
232 lines not on this page · raw message
hw/armv7m_nvic.c +23 -8
@@ -15,9 +15,6 @@#include "arm-misc.h" #include "exec-memory.h" -/* 32 internal lines (16 used for system exceptions) plus 64 external -interrupt lines. */ -#define GIC_NIRQ 96#define NCPU 1#define NVIC 1
@@ -41,6 +38,7 @@ typedef struct {int64_t tick;QEMUTimer *timer; } systick; +uint32_t num_irq; } nvic_state;/* qemu timers run at 1GHz. We want something closer to 1MHz. */
@@ -125,7 +123,7 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)switch (offset) {case 4 :/* Interrupt Control Type. */ -return (GIC_NIRQ /32 ) -1 ; +return (s->num_irq /32 ) -1 ;case 0x10 :/* SysTick Control and Status. */ val = s->systick.control; s->systick.control &= ~SYSTICK_COUNTFLAG ;
@@ -169,7 +167,7 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)if (s->gic.current_pending[0 ] !=1023 ) val |= (s->gic.current_pending[0 ] <<12 );/* ISRPENDING */ -for (irq =32 ; irq <GIC_NIRQ ; irq++) { +for (irq =32 ; irq < s->num_irq; irq++) {if (s->gic.irq_state[irq].pending) { val |= (1 <<22 );break ;
@@ -384,16 +382,33 @@ static int armv7m_nvic_init(SysBusDevice *dev) {nvic_state *s=FROM_SYSBUSGIC (nvic_state, dev); -gic_init (&s->gic); +/* note that for the M profile gic_init() takes the number of external +* interrupt lines only. +*/ +gic_init (&s->gic, s->num_irq);memory_region_add_subregion (get_system_memory (),0xe000e000 , &s->gic.iomem); s->systick.timer =qemu_new_timer_ns (vm_clock, systick_timer_tick, s); -vmstate_register (&dev->qdev,-1 , &vmstate_nvic, s);return 0 ; } +static SysBusDeviceInfo armv7m_nvic_priv_info = { + .init = armv7m_nvic_init, + .qdev.name ="armv7m_nvic" , + .qdev.size =sizeof (nvic_state), + .qdev.vmsd = &vmstate_nvic, + .qdev.props = (Property []) { +/* The ARM v7m may have anything from 0 to 496 external interrupt +* IRQ lines. We default to 64. Other boards may differ and should +* set this property appropriately. +*/ +DEFINE_PROP_UINT32 ("num-irq" , nvic_state, num_irq,64 ), +DEFINE_PROP_END_OF_LIST (), + } +}; +static void armv7m_nvic_register_devices (void ) { -sysbus_register_dev ("armv7m_nvic" ,sizeof (nvic_state), armv7m_nvic_init); +sysbus_register_withprop (&armv7m_nvic_priv_info); }device_init (armv7m_nvic_register_devices)
hw/realview_gic.c +5 -2
@@ -9,7 +9,6 @@#include "sysbus.h" -#define GIC_NIRQ 96#define NCPU 1/* Only a single "CPU" interface is present. */
@@ -37,7 +36,11 @@ static int realview_gic_init(SysBusDevice *dev) {RealViewGICState *s =FROM_SYSBUSGIC (RealViewGICState, dev); -gic_init (&s->gic); +/* The GICs on the RealView boards have a fixed nonconfigurable +* number of interrupt lines, so we don't need to expose this as +* a qdev property. +*/ +gic_init (&s->gic,96 );realview_gic_map_setup (s);sysbus_init_mmio (dev, &s->container);return 0 ;
Signature · 1 line
1.7.1
Quoted 4 lines · Peter Maydell
This is a smallish pullreq for a few arm-devs patches which have been on the list for a while. The two patches from Mark were in the highbank patchset, but I'd like to get them committed now because they're needed for other patchsets (vexpress-a15, exynos). Please pull.
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 31 lines
thanks
-- PMMThe following changes since commit
8c4ec5c0269bda18bb777a64b2008088d1c632dc:pxa2xx_keypad: fix unbalanced parenthesis. (2012-01-17 02:14:42 +0100)are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gitarm-devs.for-upstreamMark Langsdorf (2):
arm: Remove incorrect comment inarm_timer
arm: make the number of GIC interrupts configurablePeter Maydell (2):
vexpress, realview: Add (dummy) L2 cache controller hw/lan9118: Add save/load supporthw/a9mpcore.c | 13 ++++- hw/arm11mpcore.c | 17 +++++--- hw/arm_gic.c | 68 ++++++++++++++++------------- hw/arm_timer.c | 3 - hw/armv7m_nvic.c | 31 ++++++++++--- hw/lan9118.c | 126 +++++++++++++++++++++++++++++++++++++++++++---------- hw/realview.c | 2 + hw/realview_gic.c | 7 ++- hw/vexpress.c | 1 + 9 files changed, 193 insertions(+), 75 deletions(-)