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

« back to all changes in this revision

Viewing changes to hw/input/pl050.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:
10
10
#include "hw/sysbus.h"
11
11
#include "hw/input/ps2.h"
12
12
 
13
 
typedef struct {
14
 
    SysBusDevice busdev;
 
13
#define TYPE_PL050 "pl050"
 
14
#define PL050(obj) OBJECT_CHECK(PL050State, (obj), TYPE_PL050)
 
15
 
 
16
typedef struct PL050State {
 
17
    SysBusDevice parent_obj;
 
18
 
15
19
    MemoryRegion iomem;
16
20
    void *dev;
17
21
    uint32_t cr;
19
23
    uint32_t last;
20
24
    int pending;
21
25
    qemu_irq irq;
22
 
    int is_mouse;
23
 
} pl050_state;
 
26
    bool is_mouse;
 
27
} PL050State;
24
28
 
25
29
static const VMStateDescription vmstate_pl050 = {
26
30
    .name = "pl050",
27
31
    .version_id = 2,
28
32
    .minimum_version_id = 2,
29
33
    .fields = (VMStateField[]) {
30
 
        VMSTATE_UINT32(cr, pl050_state),
31
 
        VMSTATE_UINT32(clk, pl050_state),
32
 
        VMSTATE_UINT32(last, pl050_state),
33
 
        VMSTATE_INT32(pending, pl050_state),
 
34
        VMSTATE_UINT32(cr, PL050State),
 
35
        VMSTATE_UINT32(clk, PL050State),
 
36
        VMSTATE_UINT32(last, PL050State),
 
37
        VMSTATE_INT32(pending, PL050State),
34
38
        VMSTATE_END_OF_LIST()
35
39
    }
36
40
};
48
52
 
49
53
static void pl050_update(void *opaque, int level)
50
54
{
51
 
    pl050_state *s = (pl050_state *)opaque;
 
55
    PL050State *s = (PL050State *)opaque;
52
56
    int raise;
53
57
 
54
58
    s->pending = level;
60
64
static uint64_t pl050_read(void *opaque, hwaddr offset,
61
65
                           unsigned size)
62
66
{
63
 
    pl050_state *s = (pl050_state *)opaque;
 
67
    PL050State *s = (PL050State *)opaque;
64
68
    if (offset >= 0xfe0 && offset < 0x1000)
65
69
        return pl050_id[(offset - 0xfe0) >> 2];
66
70
 
103
107
static void pl050_write(void *opaque, hwaddr offset,
104
108
                        uint64_t value, unsigned size)
105
109
{
106
 
    pl050_state *s = (pl050_state *)opaque;
 
110
    PL050State *s = (PL050State *)opaque;
107
111
    switch (offset >> 2) {
108
112
    case 0: /* KMICR */
109
113
        s->cr = value;
133
137
    .endianness = DEVICE_NATIVE_ENDIAN,
134
138
};
135
139
 
136
 
static int pl050_init(SysBusDevice *dev, int is_mouse)
 
140
static int pl050_initfn(SysBusDevice *dev)
137
141
{
138
 
    pl050_state *s = FROM_SYSBUS(pl050_state, dev);
 
142
    PL050State *s = PL050(dev);
139
143
 
140
 
    memory_region_init_io(&s->iomem, &pl050_ops, s, "pl050", 0x1000);
 
144
    memory_region_init_io(&s->iomem, OBJECT(s), &pl050_ops, s, "pl050", 0x1000);
141
145
    sysbus_init_mmio(dev, &s->iomem);
142
146
    sysbus_init_irq(dev, &s->irq);
143
 
    s->is_mouse = is_mouse;
144
 
    if (s->is_mouse)
 
147
    if (s->is_mouse) {
145
148
        s->dev = ps2_mouse_init(pl050_update, s);
146
 
    else
 
149
    } else {
147
150
        s->dev = ps2_kbd_init(pl050_update, s);
 
151
    }
148
152
    return 0;
149
153
}
150
154
 
151
 
static int pl050_init_keyboard(SysBusDevice *dev)
152
 
{
153
 
    return pl050_init(dev, 0);
154
 
}
155
 
 
156
 
static int pl050_init_mouse(SysBusDevice *dev)
157
 
{
158
 
    return pl050_init(dev, 1);
159
 
}
160
 
 
161
 
static void pl050_kbd_class_init(ObjectClass *klass, void *data)
162
 
{
163
 
    DeviceClass *dc = DEVICE_CLASS(klass);
164
 
    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
165
 
 
166
 
    k->init = pl050_init_keyboard;
167
 
    dc->vmsd = &vmstate_pl050;
 
155
static void pl050_keyboard_init(Object *obj)
 
156
{
 
157
    PL050State *s = PL050(obj);
 
158
 
 
159
    s->is_mouse = false;
 
160
}
 
161
 
 
162
static void pl050_mouse_init(Object *obj)
 
163
{
 
164
    PL050State *s = PL050(obj);
 
165
 
 
166
    s->is_mouse = true;
168
167
}
169
168
 
170
169
static const TypeInfo pl050_kbd_info = {
171
170
    .name          = "pl050_keyboard",
172
 
    .parent        = TYPE_SYS_BUS_DEVICE,
173
 
    .instance_size = sizeof(pl050_state),
174
 
    .class_init    = pl050_kbd_class_init,
 
171
    .parent        = TYPE_PL050,
 
172
    .instance_init = pl050_keyboard_init,
175
173
};
176
174
 
177
 
static void pl050_mouse_class_init(ObjectClass *klass, void *data)
178
 
{
179
 
    DeviceClass *dc = DEVICE_CLASS(klass);
180
 
    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
181
 
 
182
 
    k->init = pl050_init_mouse;
183
 
    dc->vmsd = &vmstate_pl050;
184
 
}
185
 
 
186
175
static const TypeInfo pl050_mouse_info = {
187
176
    .name          = "pl050_mouse",
 
177
    .parent        = TYPE_PL050,
 
178
    .instance_init = pl050_mouse_init,
 
179
};
 
180
 
 
181
static void pl050_class_init(ObjectClass *oc, void *data)
 
182
{
 
183
    DeviceClass *dc = DEVICE_CLASS(oc);
 
184
    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
 
185
 
 
186
    sdc->init = pl050_initfn;
 
187
    dc->vmsd = &vmstate_pl050;
 
188
}
 
189
 
 
190
static const TypeInfo pl050_type_info = {
 
191
    .name          = TYPE_PL050,
188
192
    .parent        = TYPE_SYS_BUS_DEVICE,
189
 
    .instance_size = sizeof(pl050_state),
190
 
    .class_init    = pl050_mouse_class_init,
 
193
    .instance_size = sizeof(PL050State),
 
194
    .abstract      = true,
 
195
    .class_init    = pl050_class_init,
191
196
};
192
197
 
193
198
static void pl050_register_types(void)
194
199
{
 
200
    type_register_static(&pl050_type_info);
195
201
    type_register_static(&pl050_kbd_info);
196
202
    type_register_static(&pl050_mouse_info);
197
203
}