~ubuntu-branches/ubuntu/precise/qemu-kvm/precise

« back to all changes in this revision

Viewing changes to hw/pxa2xx_pic.c

  • Committer: Serge Hallyn
  • Date: 2011-10-19 07:37:43 UTC
  • mfrom: (1.2.7)
  • Revision ID: serge.hallyn@ubuntu.com-20111019073743-7i7n9irsxlm38wic
Tags: 0.15.0+noroms-0ubuntu1
* New upstream release
* Remaining changes from upstream:
  - removed all binary roms and tests/pi_10.com
* Removed Detect-and-use-GCC-atomic-builtins-for-locking.patch - non-NPTL
  implementations were removed with commit
  02615337ef295443daa03233e492194e289a807e
* Drop spice-qxl-locking-fix-for-qemu-kvm.patch - should be unnecessary
  as of commit 196a778428989217b82de042725dc8eb29c8f8d8
* drop patches applied upstream:
  - CVE-2011-1751.diff
  - virtio-guard-against-negative-vq-notifies-CVE-2011-2512.diff
  - CVE-2011-2527.patch
  - fix-pa-configure.patch
* Refreshed the remaining patches:
  - larger_default_ram_size.patch
  - CVE-2011-2212-virtqueue-indirect-overflow.patch
  - qemuifup-fix-paths.patch
  - vpc.patch
* e1000-Dont-set-the-Capabilities-List-bit.patch - switched to the
  cherrypicked upstream patch (as the source file changed quite a bit,
  and the hand-ported patch backported to 0.14.1 does not apply).
* Drop qemu-kvm-spice (all changes from 0.14.1+noroms-0ubuntu7), it will
  need its own source package (LP: #878162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * Copyright (c) 2006 Thorsten Zitterell
6
6
 * Written by Andrzej Zaborowski <balrog@zabor.org>
7
7
 *
8
 
 * This code is licenced under the GPL.
 
8
 * This code is licensed under the GPL.
9
9
 */
10
10
 
11
11
#include "hw.h"
12
12
#include "pxa.h"
 
13
#include "sysbus.h"
13
14
 
14
15
#define ICIP    0x00    /* Interrupt Controller IRQ Pending register */
15
16
#define ICMR    0x04    /* Interrupt Controller Mask register */
31
32
#define PXA2XX_PIC_SRCS 40
32
33
 
33
34
typedef struct {
 
35
    SysBusDevice busdev;
34
36
    CPUState *cpu_env;
35
37
    uint32_t int_enabled[2];
36
38
    uint32_t int_pending[2];
241
243
    pxa2xx_pic_mem_write,
242
244
};
243
245
 
244
 
static void pxa2xx_pic_save(QEMUFile *f, void *opaque)
245
 
{
246
 
    PXA2xxPICState *s = (PXA2xxPICState *) opaque;
247
 
    int i;
248
 
 
249
 
    for (i = 0; i < 2; i ++)
250
 
        qemu_put_be32s(f, &s->int_enabled[i]);
251
 
    for (i = 0; i < 2; i ++)
252
 
        qemu_put_be32s(f, &s->int_pending[i]);
253
 
    for (i = 0; i < 2; i ++)
254
 
        qemu_put_be32s(f, &s->is_fiq[i]);
255
 
    qemu_put_be32s(f, &s->int_idle);
256
 
    for (i = 0; i < PXA2XX_PIC_SRCS; i ++)
257
 
        qemu_put_be32s(f, &s->priority[i]);
258
 
}
259
 
 
260
 
static int pxa2xx_pic_load(QEMUFile *f, void *opaque, int version_id)
261
 
{
262
 
    PXA2xxPICState *s = (PXA2xxPICState *) opaque;
263
 
    int i;
264
 
 
265
 
    for (i = 0; i < 2; i ++)
266
 
        qemu_get_be32s(f, &s->int_enabled[i]);
267
 
    for (i = 0; i < 2; i ++)
268
 
        qemu_get_be32s(f, &s->int_pending[i]);
269
 
    for (i = 0; i < 2; i ++)
270
 
        qemu_get_be32s(f, &s->is_fiq[i]);
271
 
    qemu_get_be32s(f, &s->int_idle);
272
 
    for (i = 0; i < PXA2XX_PIC_SRCS; i ++)
273
 
        qemu_get_be32s(f, &s->priority[i]);
274
 
 
 
246
static int pxa2xx_pic_post_load(void *opaque, int version_id)
 
247
{
275
248
    pxa2xx_pic_update(opaque);
276
249
    return 0;
277
250
}
278
251
 
279
 
qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
 
252
DeviceState *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
280
253
{
281
 
    PXA2xxPICState *s;
 
254
    DeviceState *dev = qdev_create(NULL, "pxa2xx_pic");
282
255
    int iomemtype;
283
 
    qemu_irq *qi;
284
 
 
285
 
    s = (PXA2xxPICState *)
286
 
            qemu_mallocz(sizeof(PXA2xxPICState));
287
 
    if (!s)
288
 
        return NULL;
 
256
    PXA2xxPICState *s = FROM_SYSBUS(PXA2xxPICState, sysbus_from_qdev(dev));
289
257
 
290
258
    s->cpu_env = env;
291
259
 
296
264
    s->is_fiq[0] = 0;
297
265
    s->is_fiq[1] = 0;
298
266
 
299
 
    qi = qemu_allocate_irqs(pxa2xx_pic_set_irq, s, PXA2XX_PIC_SRCS);
 
267
    qdev_init_nofail(dev);
 
268
 
 
269
    qdev_init_gpio_in(dev, pxa2xx_pic_set_irq, PXA2XX_PIC_SRCS);
300
270
 
301
271
    /* Enable IC memory-mapped registers access.  */
302
272
    iomemtype = cpu_register_io_memory(pxa2xx_pic_readfn,
303
273
                    pxa2xx_pic_writefn, s, DEVICE_NATIVE_ENDIAN);
304
 
    cpu_register_physical_memory(base, 0x00100000, iomemtype);
 
274
    sysbus_init_mmio(sysbus_from_qdev(dev), 0x00100000, iomemtype);
 
275
    sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
305
276
 
306
277
    /* Enable IC coprocessor access.  */
307
278
    cpu_arm_set_cp_io(env, 6, pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s);
308
279
 
309
 
    register_savevm(NULL, "pxa2xx_pic", 0, 0, pxa2xx_pic_save,
310
 
                    pxa2xx_pic_load, s);
311
 
 
312
 
    return qi;
313
 
}
 
280
    return dev;
 
281
}
 
282
 
 
283
static VMStateDescription vmstate_pxa2xx_pic_regs = {
 
284
    .name = "pxa2xx_pic",
 
285
    .version_id = 0,
 
286
    .minimum_version_id = 0,
 
287
    .minimum_version_id_old = 0,
 
288
    .post_load = pxa2xx_pic_post_load,
 
289
    .fields = (VMStateField[]) {
 
290
        VMSTATE_UINT32_ARRAY(int_enabled, PXA2xxPICState, 2),
 
291
        VMSTATE_UINT32_ARRAY(int_pending, PXA2xxPICState, 2),
 
292
        VMSTATE_UINT32_ARRAY(is_fiq, PXA2xxPICState, 2),
 
293
        VMSTATE_UINT32(int_idle, PXA2xxPICState),
 
294
        VMSTATE_UINT32_ARRAY(priority, PXA2xxPICState, PXA2XX_PIC_SRCS),
 
295
        VMSTATE_END_OF_LIST(),
 
296
    },
 
297
};
 
298
 
 
299
static int pxa2xx_pic_initfn(SysBusDevice *dev)
 
300
{
 
301
    return 0;
 
302
}
 
303
 
 
304
static SysBusDeviceInfo pxa2xx_pic_info = {
 
305
    .init       = pxa2xx_pic_initfn,
 
306
    .qdev.name  = "pxa2xx_pic",
 
307
    .qdev.desc  = "PXA2xx PIC",
 
308
    .qdev.size  = sizeof(PXA2xxPICState),
 
309
    .qdev.vmsd  = &vmstate_pxa2xx_pic_regs,
 
310
};
 
311
 
 
312
static void pxa2xx_pic_register(void)
 
313
{
 
314
    sysbus_register_withprop(&pxa2xx_pic_info);
 
315
}
 
316
device_init(pxa2xx_pic_register);