4 * The empty_slot device emulates known to a bus but not connected devices.
6 * Copyright (c) 2010 Artyom Tarasenko
8 * This code is licensed under the GNU GPL v2 or (at your option) any later
14 #include "empty_slot.h"
16 //#define DEBUG_EMPTY_SLOT
18 #ifdef DEBUG_EMPTY_SLOT
19 #define DPRINTF(fmt, ...) \
20 do { printf("empty_slot: " fmt , ## __VA_ARGS__); } while (0)
22 #define DPRINTF(fmt, ...) do {} while (0)
25 typedef struct EmptySlot
{
31 static uint64_t empty_slot_read(void *opaque
, hwaddr addr
,
34 DPRINTF("read from " TARGET_FMT_plx
"\n", addr
);
38 static void empty_slot_write(void *opaque
, hwaddr addr
,
39 uint64_t val
, unsigned size
)
41 DPRINTF("write 0x%x to " TARGET_FMT_plx
"\n", (unsigned)val
, addr
);
44 static const MemoryRegionOps empty_slot_ops
= {
45 .read
= empty_slot_read
,
46 .write
= empty_slot_write
,
47 .endianness
= DEVICE_NATIVE_ENDIAN
,
50 void empty_slot_init(hwaddr addr
, uint64_t slot_size
)
53 /* Only empty slots larger than 0 byte need handling. */
58 dev
= qdev_create(NULL
, "empty_slot");
59 s
= sysbus_from_qdev(dev
);
60 e
= FROM_SYSBUS(EmptySlot
, s
);
63 qdev_init_nofail(dev
);
65 sysbus_mmio_map(s
, 0, addr
);
69 static int empty_slot_init1(SysBusDevice
*dev
)
71 EmptySlot
*s
= FROM_SYSBUS(EmptySlot
, dev
);
73 memory_region_init_io(&s
->iomem
, &empty_slot_ops
, s
,
74 "empty-slot", s
->size
);
75 sysbus_init_mmio(dev
, &s
->iomem
);
79 static void empty_slot_class_init(ObjectClass
*klass
, void *data
)
81 SysBusDeviceClass
*k
= SYS_BUS_DEVICE_CLASS(klass
);
83 k
->init
= empty_slot_init1
;
86 static const TypeInfo empty_slot_info
= {
88 .parent
= TYPE_SYS_BUS_DEVICE
,
89 .instance_size
= sizeof(EmptySlot
),
90 .class_init
= empty_slot_class_init
,
93 static void empty_slot_register_types(void)
95 type_register_static(&empty_slot_info
);
98 type_init(empty_slot_register_types
)