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
{
30 static uint32_t empty_slot_readl(void *opaque
, target_phys_addr_t addr
)
32 DPRINTF("read from " TARGET_FMT_plx
"\n", addr
);
36 static void empty_slot_writel(void *opaque
, target_phys_addr_t addr
,
39 DPRINTF("write 0x%x to " TARGET_FMT_plx
"\n", val
, addr
);
42 CPUReadMemoryFunc
* const empty_slot_read
[3] = {
48 static CPUWriteMemoryFunc
* const empty_slot_write
[3] = {
54 void empty_slot_init(target_phys_addr_t addr
, uint64_t slot_size
)
60 dev
= qdev_create(NULL
, "empty_slot");
61 s
= sysbus_from_qdev(dev
);
62 e
= FROM_SYSBUS(EmptySlot
, s
);
65 qdev_init_nofail(dev
);
67 sysbus_mmio_map(s
, 0, addr
);
70 static int empty_slot_init1(SysBusDevice
*dev
)
72 EmptySlot
*s
= FROM_SYSBUS(EmptySlot
, dev
);
73 ram_addr_t empty_slot_offset
;
75 empty_slot_offset
= cpu_register_io_memory(empty_slot_read
,
77 sysbus_init_mmio(dev
, s
->size
, empty_slot_offset
| IO_MEM_RAM
);
81 static SysBusDeviceInfo empty_slot_info
= {
82 .init
= empty_slot_init1
,
83 .qdev
.name
= "empty_slot",
84 .qdev
.size
= sizeof(EmptySlot
),
87 static void empty_slot_register_devices(void)
89 sysbus_register_withprop(&empty_slot_info
);
92 device_init(empty_slot_register_devices
);