~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/heathrow_pic.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn, Serge Hallyn, Adam Conrad
  • Date: 2013-01-04 08:50:24 UTC
  • mfrom: (1.6.6) (10.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20130104085024-k4mr3z3zzjxemww2
Tags: 1.2.0.dfsg-1~exp1-0ubuntu1
[ Serge Hallyn ]
* debian/control:
  - update maintainer
  - remove vde2 recommends
  - build-deps: remove libusbredir, libvdeplug2-dev,
    libspice-server-dev, libspice-protocol-dev, libiscsi-dev,
    and libxen-dev.
  - qemu-keymaps: break/replace qemu-common
  - qemu-system:
    - break/replace qemu-common
    - depend on udev
    - remove openbios-ppc, openbios-sparc, and openhackware from
      Depends.  (Intend to add them back once we can build them.)
    - provides: qemu-kvm
  - qemu-utils: break/replace qemu-kvm
  - set up transitional packages for qemu-kvm, qemu-common, and kvm.
* debian/rules:
  - install kvm-ifup and kvm-ifdown
  - dh_installinit the qemu-kvm upstart job
* install a 30-qemu-kvm.conf into /etc/sysctl.c for nr_hugepages.
* qemu-kvm.upstart:
  - add qemu-system.qemu-kvm.upstart
  - add mv_confile to qemu-system.preinst, postinst, and .postrm to rename
    /etc/init/qemu-kvm.conf to qemu-system.conf
  - debian/rules: add dh_installinit to get qemu-system.upstart installed.
  - take the defaults from the old qemu-kvm.defaults, and move them into
    the upstart job
* debian/patches:
  - apply gridcentric patches from lp:~amscanne/+junk/gridcentric-qemu-patches
  - apply arm patches from git://git.linaro.org/qemu/qemu-linaro.git
  - apply nbd-fixes-to-read-only-handling.patch from upstream to
    make read-write mount after read-only mount work.  (LP: #1077838)
* ifup/down:
  - copy Ubuntu qemu-kvm's kvm-ifup/down into debian/
  - fix dh_install for kvm-ifup/down in debian/rules
  - add links for qemu-ifup/down in qemu-system.links
  - remove (debian's original) qemu-ifup from qemu-system.install
* debian/qemu-system.postinst
  - udevadm trigger to fix up /dev/kvm perms
  - make the 'qemu' symlink point to qemu-system-x86_64, not -i386.
* debian/qemu-system.links:
  - point 'kvm' to qemu-system-x86_64
  - remove pxe-virtio, pxe-e1000 and pxe-rtl8139 links (which conflict
    with ones from kvm-ipxe).  We may want to move the links from kvm-ipxe
    back to qemu-system at some point.
  - add qemu-ifdown and qemu-ifup links
* debian/qemu-system.install:
  - remove /etc/qemu-ifup link
  - add /etc/sysctl.d/30-qemu-kvm.conf

[ Adam Conrad ]
* Appease apt-get's dist-upgrade resolver by creating a qemu-common
  transitional package to upgrade more gracefully to qemu-keymaps.
* Move all the empty transitional packages to the oldlibs section. 
* Restore the versioned dep from qemu-kvm (and kvm) to qemu-system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
//#define DEBUG_PIC
30
30
 
31
31
#ifdef DEBUG_PIC
32
 
#define PIC_DPRINTF(fmt, args...) \
33
 
do { printf("PIC: " fmt , ##args); } while (0)
 
32
#define PIC_DPRINTF(fmt, ...)                                   \
 
33
    do { printf("PIC: " fmt , ## __VA_ARGS__); } while (0)
34
34
#else
35
 
#define PIC_DPRINTF(fmt, args...)
 
35
#define PIC_DPRINTF(fmt, ...)
36
36
#endif
37
37
 
38
38
typedef struct HeathrowPIC {
43
43
} HeathrowPIC;
44
44
 
45
45
typedef struct HeathrowPICS {
 
46
    MemoryRegion mem;
46
47
    HeathrowPIC pics[2];
47
48
    qemu_irq *irqs;
48
49
} HeathrowPICS;
62
63
    }
63
64
}
64
65
 
65
 
static void pic_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
 
66
static void pic_write(void *opaque, target_phys_addr_t addr,
 
67
                      uint64_t value, unsigned size)
66
68
{
67
69
    HeathrowPICS *s = opaque;
68
70
    HeathrowPIC *pic;
69
71
    unsigned int n;
70
72
 
71
 
#ifdef TARGET_WORDS_BIGENDIAN
72
 
    value = bswap32(value);
73
 
#endif
74
73
    n = ((addr & 0xfff) - 0x10) >> 4;
75
74
    PIC_DPRINTF("writel: " TARGET_FMT_plx " %u: %08x\n", addr, n, value);
76
75
    if (n >= 2)
92
91
    }
93
92
}
94
93
 
95
 
static uint32_t pic_readl (void *opaque, target_phys_addr_t addr)
 
94
static uint64_t pic_read(void *opaque, target_phys_addr_t addr,
 
95
                         unsigned size)
96
96
{
97
97
    HeathrowPICS *s = opaque;
98
98
    HeathrowPIC *pic;
120
120
        }
121
121
    }
122
122
    PIC_DPRINTF("readl: " TARGET_FMT_plx " %u: %08x\n", addr, n, value);
123
 
#ifdef TARGET_WORDS_BIGENDIAN
124
 
    value = bswap32(value);
125
 
#endif
126
123
    return value;
127
124
}
128
125
 
129
 
static CPUWriteMemoryFunc *pic_write[] = {
130
 
    &pic_writel,
131
 
    &pic_writel,
132
 
    &pic_writel,
133
 
};
134
 
 
135
 
static CPUReadMemoryFunc *pic_read[] = {
136
 
    &pic_readl,
137
 
    &pic_readl,
138
 
    &pic_readl,
139
 
};
140
 
 
 
126
static const MemoryRegionOps heathrow_pic_ops = {
 
127
    .read = pic_read,
 
128
    .write = pic_write,
 
129
    .endianness = DEVICE_LITTLE_ENDIAN,
 
130
};
141
131
 
142
132
static void heathrow_pic_set_irq(void *opaque, int num, int level)
143
133
{
165
155
    heathrow_pic_update(s);
166
156
}
167
157
 
168
 
static void heathrow_pic_save_one(QEMUFile *f, HeathrowPIC *s)
169
 
{
170
 
    qemu_put_be32s(f, &s->events);
171
 
    qemu_put_be32s(f, &s->mask);
172
 
    qemu_put_be32s(f, &s->levels);
173
 
    qemu_put_be32s(f, &s->level_triggered);
174
 
}
175
 
 
176
 
static void heathrow_pic_save(QEMUFile *f, void *opaque)
177
 
{
178
 
    HeathrowPICS *s = (HeathrowPICS *)opaque;
179
 
 
180
 
    heathrow_pic_save_one(f, &s->pics[0]);
181
 
    heathrow_pic_save_one(f, &s->pics[1]);
182
 
}
183
 
 
184
 
static void heathrow_pic_load_one(QEMUFile *f, HeathrowPIC *s)
185
 
{
186
 
    qemu_get_be32s(f, &s->events);
187
 
    qemu_get_be32s(f, &s->mask);
188
 
    qemu_get_be32s(f, &s->levels);
189
 
    qemu_get_be32s(f, &s->level_triggered);
190
 
}
191
 
 
192
 
static int heathrow_pic_load(QEMUFile *f, void *opaque, int version_id)
193
 
{
194
 
    HeathrowPICS *s = (HeathrowPICS *)opaque;
195
 
 
196
 
    if (version_id != 1)
197
 
        return -EINVAL;
198
 
 
199
 
    heathrow_pic_load_one(f, &s->pics[0]);
200
 
    heathrow_pic_load_one(f, &s->pics[1]);
201
 
 
202
 
    return 0;
203
 
}
 
158
static const VMStateDescription vmstate_heathrow_pic_one = {
 
159
    .name = "heathrow_pic_one",
 
160
    .version_id = 0,
 
161
    .minimum_version_id = 0,
 
162
    .minimum_version_id_old = 0,
 
163
    .fields      = (VMStateField[]) {
 
164
        VMSTATE_UINT32(events, HeathrowPIC),
 
165
        VMSTATE_UINT32(mask, HeathrowPIC),
 
166
        VMSTATE_UINT32(levels, HeathrowPIC),
 
167
        VMSTATE_UINT32(level_triggered, HeathrowPIC),
 
168
        VMSTATE_END_OF_LIST()
 
169
    }
 
170
};
 
171
 
 
172
static const VMStateDescription vmstate_heathrow_pic = {
 
173
    .name = "heathrow_pic",
 
174
    .version_id = 1,
 
175
    .minimum_version_id = 1,
 
176
    .minimum_version_id_old = 1,
 
177
    .fields      = (VMStateField[]) {
 
178
        VMSTATE_STRUCT_ARRAY(pics, HeathrowPICS, 2, 1,
 
179
                             vmstate_heathrow_pic_one, HeathrowPIC),
 
180
        VMSTATE_END_OF_LIST()
 
181
    }
 
182
};
204
183
 
205
184
static void heathrow_pic_reset_one(HeathrowPIC *s)
206
185
{
218
197
    s->pics[1].level_triggered = 0x1ff00000;
219
198
}
220
199
 
221
 
qemu_irq *heathrow_pic_init(int *pmem_index,
 
200
qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
222
201
                            int nb_cpus, qemu_irq **irqs)
223
202
{
224
203
    HeathrowPICS *s;
225
204
 
226
 
    s = qemu_mallocz(sizeof(HeathrowPICS));
 
205
    s = g_malloc0(sizeof(HeathrowPICS));
227
206
    /* only 1 CPU */
228
207
    s->irqs = irqs[0];
229
 
    *pmem_index = cpu_register_io_memory(0, pic_read, pic_write, s);
 
208
    memory_region_init_io(&s->mem, &heathrow_pic_ops, s,
 
209
                          "heathrow-pic", 0x1000);
 
210
    *pmem = &s->mem;
230
211
 
231
 
    register_savevm("heathrow_pic", -1, 1, heathrow_pic_save,
232
 
                    heathrow_pic_load, s);
 
212
    vmstate_register(NULL, -1, &vmstate_heathrow_pic, s);
233
213
    qemu_register_reset(heathrow_pic_reset, s);
234
 
    heathrow_pic_reset(s);
235
214
    return qemu_allocate_irqs(heathrow_pic_set_irq, s, 64);
236
215
}