Improve log message for unaligned i/o
[qemu/ar7.git] / hw / vlynq.c
blob8c8b407718e4e0e1170457e49020df3e67f504d0
1 /*
2 * QEMU VLYNQ Serial Interface support.
4 * Copyright (C) 2009-2012 Stefan Weil
6 * Portions of the code are copies from ssi.c.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) version 3 or any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "vlynq.h"
25 #if 0 // TODO: Fix code for QOM API.
27 struct _VLYNQBus {
28 BusState qbus;
31 static struct BusInfo vlynq_bus_info = {
32 .name = "VLYNQ",
33 .size = sizeof(VLYNQBus),
36 static int vlynq_qdev_init(DeviceState *qdev, DeviceInfo *base)
38 VLYNQDevice *vlynq_dev = (VLYNQDevice *)qdev;
39 VLYNQDeviceInfo *info = container_of(base, VLYNQDeviceInfo, qdev);
40 //~ int devfn;
41 int rc;
43 //~ VLYNQBus *bus = FROM_QBUS(VLYNQBus, qdev_get_parent_bus(qdev));
44 //~ devfn = pci_dev->devfn;
45 //~ vlynq_dev = do_pci_register_device(pci_dev, bus, base->name, devfn,
46 //~ info->config_read, info->config_write,
47 //~ info->header_type);
48 //~ if (vlynq_dev == NULL) {
49 //~ return -1;
50 //~ }
51 rc = info->init(vlynq_dev);
52 if (rc != 0) {
53 //~ do_pci_unregister_device(pci_dev);
56 return rc;
59 static int vlynq_unregister_device(DeviceState *dev)
61 // TODO: missing implementation.
63 //~ VLYNQDevice *vlynq_dev = DO_UPCAST(VLYNQDevice, qdev, dev);
64 //~ VLYNQDeviceInfo *info = DO_UPCAST(VLYNQDeviceInfo, qdev, dev->info);
65 int ret = 0;
67 //~ if (info->exit) {
68 //~ ret = info->exit(vlynq_dev);
69 //~ }
70 if (ret) {
71 return ret;
74 //~ pci_unregister_io_regions(pci_dev);
75 //~ do_pci_unregister_device(pci_dev);
76 return 0;
79 void vlynq_qdev_register(VLYNQDeviceInfo *info)
81 info->qdev.init = vlynq_qdev_init;
82 //~ info->qdev.unplug = vlynq_unplug_device;
83 info->qdev.exit = vlynq_unregister_device;
84 info->qdev.bus_info = &vlynq_bus_info;
85 qdev_register(&info->qdev);
88 #if 0
89 static int vlynq_slave_init(DeviceState *dev, DeviceInfo *base_info)
91 VLYNQSlaveInfo *info = container_of(base_info, VLYNQSlaveInfo, qdev);
92 VLYNQSlave *s = VLYNQ_SLAVE_FROM_QDEV(dev);
93 VLYNQBus *bus;
95 bus = FROM_QBUS(VLYNQBus, qdev_get_parent_bus(dev));
96 if (QLIST_FIRST(&bus->qbus.children) != dev
97 || QLIST_NEXT(dev, sibling) != NULL) {
98 hw_error("Too many devices on VLYNQ bus");
101 s->info = info;
102 return info->init(s);
105 void vlynq_register_slave(VLYNQSlaveInfo *info)
107 assert(info->qdev.size >= sizeof(VLYNQSlave));
108 info->qdev.init = vlynq_slave_init;
109 info->qdev.bus_info = &vlynq_bus_info;
110 qdev_register(&info->qdev);
113 #endif
115 DeviceState *vlynq_create_slave(VLYNQBus *bus, const char *name)
117 DeviceState *dev;
118 dev = qdev_create(&bus->qbus, name);
119 qdev_init_nofail(dev);
120 return dev;
123 VLYNQBus *vlynq_create_bus(DeviceState *parent, const char *name)
125 BusState *bus;
126 bus = qbus_create(&vlynq_bus_info, parent, name);
127 return FROM_QBUS(VLYNQBus, bus);
130 #if 0
131 uint32_t vlynq_transfer(VLYNQBus *bus, uint32_t val)
133 DeviceState *dev;
134 VLYNQSlave *slave;
135 dev = QLIST_FIRST(&bus->qbus.children);
136 if (!dev) {
137 return 0;
139 slave = VLYNQ_SLAVE_FROM_QDEV(dev);
140 return slave->info->transfer(slave, val);
142 #endif
143 #endif // Fix code for QOM API.