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

« back to all changes in this revision

Viewing changes to hw/timer/pl031.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:
33
33
#define RTC_MIS     0x18    /* Masked interrupt status register */
34
34
#define RTC_ICR     0x1c    /* Interrupt clear register */
35
35
 
36
 
typedef struct {
37
 
    SysBusDevice busdev;
 
36
#define TYPE_PL031 "pl031"
 
37
#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031)
 
38
 
 
39
typedef struct PL031State {
 
40
    SysBusDevice parent_obj;
 
41
 
38
42
    MemoryRegion iomem;
39
43
    QEMUTimer *timer;
40
44
    qemu_irq irq;
51
55
    uint32_t cr;
52
56
    uint32_t im;
53
57
    uint32_t is;
54
 
} pl031_state;
 
58
} PL031State;
55
59
 
56
60
static const unsigned char pl031_id[] = {
57
61
    0x31, 0x10, 0x14, 0x00,         /* Device ID        */
58
62
    0x0d, 0xf0, 0x05, 0xb1          /* Cell ID      */
59
63
};
60
64
 
61
 
static void pl031_update(pl031_state *s)
 
65
static void pl031_update(PL031State *s)
62
66
{
63
67
    qemu_set_irq(s->irq, s->is & s->im);
64
68
}
65
69
 
66
70
static void pl031_interrupt(void * opaque)
67
71
{
68
 
    pl031_state *s = (pl031_state *)opaque;
 
72
    PL031State *s = (PL031State *)opaque;
69
73
 
70
74
    s->is = 1;
71
75
    DPRINTF("Alarm raised\n");
72
76
    pl031_update(s);
73
77
}
74
78
 
75
 
static uint32_t pl031_get_count(pl031_state *s)
 
79
static uint32_t pl031_get_count(PL031State *s)
76
80
{
77
81
    int64_t now = qemu_get_clock_ns(rtc_clock);
78
82
    return s->tick_offset + now / get_ticks_per_sec();
79
83
}
80
84
 
81
 
static void pl031_set_alarm(pl031_state *s)
 
85
static void pl031_set_alarm(PL031State *s)
82
86
{
83
87
    uint32_t ticks;
84
88
 
98
102
static uint64_t pl031_read(void *opaque, hwaddr offset,
99
103
                           unsigned size)
100
104
{
101
 
    pl031_state *s = (pl031_state *)opaque;
 
105
    PL031State *s = (PL031State *)opaque;
102
106
 
103
107
    if (offset >= 0xfe0  &&  offset < 0x1000)
104
108
        return pl031_id[(offset - 0xfe0) >> 2];
136
140
static void pl031_write(void * opaque, hwaddr offset,
137
141
                        uint64_t value, unsigned size)
138
142
{
139
 
    pl031_state *s = (pl031_state *)opaque;
 
143
    PL031State *s = (PL031State *)opaque;
140
144
 
141
145
 
142
146
    switch (offset) {
189
193
 
190
194
static int pl031_init(SysBusDevice *dev)
191
195
{
192
 
    pl031_state *s = FROM_SYSBUS(pl031_state, dev);
 
196
    PL031State *s = PL031(dev);
193
197
    struct tm tm;
194
198
 
195
 
    memory_region_init_io(&s->iomem, &pl031_ops, s, "pl031", 0x1000);
 
199
    memory_region_init_io(&s->iomem, OBJECT(s), &pl031_ops, s, "pl031", 0x1000);
196
200
    sysbus_init_mmio(dev, &s->iomem);
197
201
 
198
202
    sysbus_init_irq(dev, &s->irq);
205
209
 
206
210
static void pl031_pre_save(void *opaque)
207
211
{
208
 
    pl031_state *s = opaque;
 
212
    PL031State *s = opaque;
209
213
 
210
214
    /* tick_offset is base_time - rtc_clock base time.  Instead, we want to
211
215
     * store the base time relative to the vm_clock for backwards-compatibility.  */
215
219
 
216
220
static int pl031_post_load(void *opaque, int version_id)
217
221
{
218
 
    pl031_state *s = opaque;
 
222
    PL031State *s = opaque;
219
223
 
220
224
    int64_t delta = qemu_get_clock_ns(rtc_clock) - qemu_get_clock_ns(vm_clock);
221
225
    s->tick_offset = s->tick_offset_vmstate - delta / get_ticks_per_sec();
230
234
    .pre_save = pl031_pre_save,
231
235
    .post_load = pl031_post_load,
232
236
    .fields = (VMStateField[]) {
233
 
        VMSTATE_UINT32(tick_offset_vmstate, pl031_state),
234
 
        VMSTATE_UINT32(mr, pl031_state),
235
 
        VMSTATE_UINT32(lr, pl031_state),
236
 
        VMSTATE_UINT32(cr, pl031_state),
237
 
        VMSTATE_UINT32(im, pl031_state),
238
 
        VMSTATE_UINT32(is, pl031_state),
 
237
        VMSTATE_UINT32(tick_offset_vmstate, PL031State),
 
238
        VMSTATE_UINT32(mr, PL031State),
 
239
        VMSTATE_UINT32(lr, PL031State),
 
240
        VMSTATE_UINT32(cr, PL031State),
 
241
        VMSTATE_UINT32(im, PL031State),
 
242
        VMSTATE_UINT32(is, PL031State),
239
243
        VMSTATE_END_OF_LIST()
240
244
    }
241
245
};
251
255
}
252
256
 
253
257
static const TypeInfo pl031_info = {
254
 
    .name          = "pl031",
 
258
    .name          = TYPE_PL031,
255
259
    .parent        = TYPE_SYS_BUS_DEVICE,
256
 
    .instance_size = sizeof(pl031_state),
 
260
    .instance_size = sizeof(PL031State),
257
261
    .class_init    = pl031_class_init,
258
262
};
259
263