bootindex: add del_boot_device_path function
[qemu/ar7.git] / hw / core / empty_slot.c
blob612b1093aafbf6ce55868935fc3fdcc04113ffc2
1 /*
2 * QEMU Empty Slot
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
9 * version.
12 #include "hw/hw.h"
13 #include "hw/sysbus.h"
14 #include "hw/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)
21 #else
22 #define DPRINTF(fmt, ...) do {} while (0)
23 #endif
25 #define TYPE_EMPTY_SLOT "empty_slot"
26 #define EMPTY_SLOT(obj) OBJECT_CHECK(EmptySlot, (obj), TYPE_EMPTY_SLOT)
28 typedef struct EmptySlot {
29 SysBusDevice parent_obj;
31 MemoryRegion iomem;
32 uint64_t size;
33 } EmptySlot;
35 static uint64_t empty_slot_read(void *opaque, hwaddr addr,
36 unsigned size)
38 DPRINTF("read from " TARGET_FMT_plx "\n", addr);
39 return 0;
42 static void empty_slot_write(void *opaque, hwaddr addr,
43 uint64_t val, unsigned size)
45 DPRINTF("write 0x%x to " TARGET_FMT_plx "\n", (unsigned)val, addr);
48 static const MemoryRegionOps empty_slot_ops = {
49 .read = empty_slot_read,
50 .write = empty_slot_write,
51 .endianness = DEVICE_NATIVE_ENDIAN,
54 void empty_slot_init(hwaddr addr, uint64_t slot_size)
56 if (slot_size > 0) {
57 /* Only empty slots larger than 0 byte need handling. */
58 DeviceState *dev;
59 SysBusDevice *s;
60 EmptySlot *e;
62 dev = qdev_create(NULL, TYPE_EMPTY_SLOT);
63 s = SYS_BUS_DEVICE(dev);
64 e = EMPTY_SLOT(dev);
65 e->size = slot_size;
67 qdev_init_nofail(dev);
69 sysbus_mmio_map(s, 0, addr);
73 static int empty_slot_init1(SysBusDevice *dev)
75 EmptySlot *s = EMPTY_SLOT(dev);
77 memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
78 "empty-slot", s->size);
79 sysbus_init_mmio(dev, &s->iomem);
80 return 0;
83 static void empty_slot_class_init(ObjectClass *klass, void *data)
85 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
87 k->init = empty_slot_init1;
90 static const TypeInfo empty_slot_info = {
91 .name = TYPE_EMPTY_SLOT,
92 .parent = TYPE_SYS_BUS_DEVICE,
93 .instance_size = sizeof(EmptySlot),
94 .class_init = empty_slot_class_init,
97 static void empty_slot_register_types(void)
99 type_register_static(&empty_slot_info);
102 type_init(empty_slot_register_types)