~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/timer/arm_timer.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
 * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html
180
180
*/
181
181
 
182
 
typedef struct {
183
 
    SysBusDevice busdev;
 
182
#define TYPE_SP804 "sp804"
 
183
#define SP804(obj) OBJECT_CHECK(SP804State, (obj), TYPE_SP804)
 
184
 
 
185
typedef struct SP804State {
 
186
    SysBusDevice parent_obj;
 
187
 
184
188
    MemoryRegion iomem;
185
189
    arm_timer_state *timer[2];
186
190
    uint32_t freq0, freq1;
187
191
    int level[2];
188
192
    qemu_irq irq;
189
 
} sp804_state;
 
193
} SP804State;
190
194
 
191
195
static const uint8_t sp804_ids[] = {
192
196
    /* Timer ID */
198
202
/* Merge the IRQs from the two component devices.  */
199
203
static void sp804_set_irq(void *opaque, int irq, int level)
200
204
{
201
 
    sp804_state *s = (sp804_state *)opaque;
 
205
    SP804State *s = (SP804State *)opaque;
202
206
 
203
207
    s->level[irq] = level;
204
208
    qemu_set_irq(s->irq, s->level[0] || s->level[1]);
207
211
static uint64_t sp804_read(void *opaque, hwaddr offset,
208
212
                           unsigned size)
209
213
{
210
 
    sp804_state *s = (sp804_state *)opaque;
 
214
    SP804State *s = (SP804State *)opaque;
211
215
 
212
216
    if (offset < 0x20) {
213
217
        return arm_timer_read(s->timer[0], offset);
239
243
static void sp804_write(void *opaque, hwaddr offset,
240
244
                        uint64_t value, unsigned size)
241
245
{
242
 
    sp804_state *s = (sp804_state *)opaque;
 
246
    SP804State *s = (SP804State *)opaque;
243
247
 
244
248
    if (offset < 0x20) {
245
249
        arm_timer_write(s->timer[0], offset, value);
268
272
    .minimum_version_id = 1,
269
273
    .minimum_version_id_old = 1,
270
274
    .fields      = (VMStateField[]) {
271
 
        VMSTATE_INT32_ARRAY(level, sp804_state, 2),
 
275
        VMSTATE_INT32_ARRAY(level, SP804State, 2),
272
276
        VMSTATE_END_OF_LIST()
273
277
    }
274
278
};
275
279
 
276
 
static int sp804_init(SysBusDevice *dev)
 
280
static int sp804_init(SysBusDevice *sbd)
277
281
{
278
 
    sp804_state *s = FROM_SYSBUS(sp804_state, dev);
 
282
    DeviceState *dev = DEVICE(sbd);
 
283
    SP804State *s = SP804(dev);
279
284
    qemu_irq *qi;
280
285
 
281
286
    qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
282
 
    sysbus_init_irq(dev, &s->irq);
 
287
    sysbus_init_irq(sbd, &s->irq);
283
288
    s->timer[0] = arm_timer_init(s->freq0);
284
289
    s->timer[1] = arm_timer_init(s->freq1);
285
290
    s->timer[0]->irq = qi[0];
286
291
    s->timer[1]->irq = qi[1];
287
 
    memory_region_init_io(&s->iomem, &sp804_ops, s, "sp804", 0x1000);
288
 
    sysbus_init_mmio(dev, &s->iomem);
289
 
    vmstate_register(&dev->qdev, -1, &vmstate_sp804, s);
 
292
    memory_region_init_io(&s->iomem, OBJECT(s), &sp804_ops, s,
 
293
                          "sp804", 0x1000);
 
294
    sysbus_init_mmio(sbd, &s->iomem);
 
295
    vmstate_register(dev, -1, &vmstate_sp804, s);
290
296
    return 0;
291
297
}
292
298
 
293
299
/* Integrator/CP timer module.  */
294
300
 
 
301
#define TYPE_INTEGRATOR_PIT "integrator_pit"
 
302
#define INTEGRATOR_PIT(obj) \
 
303
    OBJECT_CHECK(icp_pit_state, (obj), TYPE_INTEGRATOR_PIT)
 
304
 
295
305
typedef struct {
296
 
    SysBusDevice busdev;
 
306
    SysBusDevice parent_obj;
 
307
 
297
308
    MemoryRegion iomem;
298
309
    arm_timer_state *timer[3];
299
310
} icp_pit_state;
335
346
 
336
347
static int icp_pit_init(SysBusDevice *dev)
337
348
{
338
 
    icp_pit_state *s = FROM_SYSBUS(icp_pit_state, dev);
 
349
    icp_pit_state *s = INTEGRATOR_PIT(dev);
339
350
 
340
351
    /* Timer 0 runs at the system clock speed (40MHz).  */
341
352
    s->timer[0] = arm_timer_init(40000000);
347
358
    sysbus_init_irq(dev, &s->timer[1]->irq);
348
359
    sysbus_init_irq(dev, &s->timer[2]->irq);
349
360
 
350
 
    memory_region_init_io(&s->iomem, &icp_pit_ops, s, "icp_pit", 0x1000);
 
361
    memory_region_init_io(&s->iomem, OBJECT(s), &icp_pit_ops, s,
 
362
                          "icp_pit", 0x1000);
351
363
    sysbus_init_mmio(dev, &s->iomem);
352
364
    /* This device has no state to save/restore.  The component timers will
353
365
       save themselves.  */
362
374
}
363
375
 
364
376
static const TypeInfo icp_pit_info = {
365
 
    .name          = "integrator_pit",
 
377
    .name          = TYPE_INTEGRATOR_PIT,
366
378
    .parent        = TYPE_SYS_BUS_DEVICE,
367
379
    .instance_size = sizeof(icp_pit_state),
368
380
    .class_init    = icp_pit_class_init,
369
381
};
370
382
 
371
383
static Property sp804_properties[] = {
372
 
    DEFINE_PROP_UINT32("freq0", sp804_state, freq0, 1000000),
373
 
    DEFINE_PROP_UINT32("freq1", sp804_state, freq1, 1000000),
 
384
    DEFINE_PROP_UINT32("freq0", SP804State, freq0, 1000000),
 
385
    DEFINE_PROP_UINT32("freq1", SP804State, freq1, 1000000),
374
386
    DEFINE_PROP_END_OF_LIST(),
375
387
};
376
388
 
384
396
}
385
397
 
386
398
static const TypeInfo sp804_info = {
387
 
    .name          = "sp804",
 
399
    .name          = TYPE_SP804,
388
400
    .parent        = TYPE_SYS_BUS_DEVICE,
389
 
    .instance_size = sizeof(sp804_state),
 
401
    .instance_size = sizeof(SP804State),
390
402
    .class_init    = sp804_class_init,
391
403
};
392
404