]> git.proxmox.com Git - qemu.git/blame - hw/empty_slot.c
tcg-s390: Fix merge error in tgen_brcond
[qemu.git] / hw / empty_slot.c
CommitLineData
da9fcfa5
AT
1/*
2 * QEMU Empty Slot
3 *
4 * The empty_slot device emulates known to a bus but not connected devices.
5 *
6 * Copyright (c) 2010 Artyom Tarasenko
7 *
8 * This code is licensed under the GNU GPL v2 or (at your option) any later
9 * version.
10 */
11
83c9f4ca
PB
12#include "hw/hw.h"
13#include "hw/sysbus.h"
14#include "hw/empty_slot.h"
da9fcfa5
AT
15
16//#define DEBUG_EMPTY_SLOT
17
18#ifdef DEBUG_EMPTY_SLOT
19#define DPRINTF(fmt, ...) \
20 do { printf("empty_slot: " fmt , ## __VA_ARGS__); } while (0)
21#else
22#define DPRINTF(fmt, ...) do {} while (0)
23#endif
24
25typedef struct EmptySlot {
26 SysBusDevice busdev;
b0a941b0 27 MemoryRegion iomem;
da9fcfa5
AT
28 uint64_t size;
29} EmptySlot;
30
a8170e5e 31static uint64_t empty_slot_read(void *opaque, hwaddr addr,
b0a941b0 32 unsigned size)
da9fcfa5
AT
33{
34 DPRINTF("read from " TARGET_FMT_plx "\n", addr);
35 return 0;
36}
37
a8170e5e 38static void empty_slot_write(void *opaque, hwaddr addr,
b0a941b0 39 uint64_t val, unsigned size)
da9fcfa5 40{
b0a941b0 41 DPRINTF("write 0x%x to " TARGET_FMT_plx "\n", (unsigned)val, addr);
da9fcfa5
AT
42}
43
b0a941b0
AK
44static const MemoryRegionOps empty_slot_ops = {
45 .read = empty_slot_read,
46 .write = empty_slot_write,
47 .endianness = DEVICE_NATIVE_ENDIAN,
da9fcfa5
AT
48};
49
a8170e5e 50void empty_slot_init(hwaddr addr, uint64_t slot_size)
da9fcfa5 51{
1a00282a
SW
52 if (slot_size > 0) {
53 /* Only empty slots larger than 0 byte need handling. */
54 DeviceState *dev;
55 SysBusDevice *s;
56 EmptySlot *e;
da9fcfa5 57
1a00282a 58 dev = qdev_create(NULL, "empty_slot");
1356b98d 59 s = SYS_BUS_DEVICE(dev);
1a00282a
SW
60 e = FROM_SYSBUS(EmptySlot, s);
61 e->size = slot_size;
da9fcfa5 62
1a00282a 63 qdev_init_nofail(dev);
da9fcfa5 64
1a00282a
SW
65 sysbus_mmio_map(s, 0, addr);
66 }
da9fcfa5
AT
67}
68
69static int empty_slot_init1(SysBusDevice *dev)
70{
71 EmptySlot *s = FROM_SYSBUS(EmptySlot, dev);
da9fcfa5 72
b0a941b0
AK
73 memory_region_init_io(&s->iomem, &empty_slot_ops, s,
74 "empty-slot", s->size);
750ecd44 75 sysbus_init_mmio(dev, &s->iomem);
da9fcfa5
AT
76 return 0;
77}
78
999e12bb
AL
79static void empty_slot_class_init(ObjectClass *klass, void *data)
80{
81 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
82
83 k->init = empty_slot_init1;
84}
85
8c43a6f0 86static const TypeInfo empty_slot_info = {
39bffca2
AL
87 .name = "empty_slot",
88 .parent = TYPE_SYS_BUS_DEVICE,
89 .instance_size = sizeof(EmptySlot),
90 .class_init = empty_slot_class_init,
da9fcfa5
AT
91};
92
83f7d43a 93static void empty_slot_register_types(void)
da9fcfa5 94{
39bffca2 95 type_register_static(&empty_slot_info);
da9fcfa5
AT
96}
97
83f7d43a 98type_init(empty_slot_register_types)