pl022_init(0x40008000, pic[7], NULL, NULL);
}
}
- if (board->dc4 & (1 << 28))
- stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);
+ if (board->dc4 & (1 << 28)) {
+ DeviceState *enet;
+
+ qemu_check_nic_model(&nd_table[0], "stellaris");
+
+ enet = qdev_create(NULL, "stellaris_enet");
+ qdev_set_netdev(enet, &nd_table[0]);
+ qdev_init(enet);
+ sysbus_mmio_map(sysbus_from_qdev(enet), 0, 0x40048000);
+ sysbus_connect_irq(sysbus_from_qdev(enet), 0, pic[42]);
+ }
if (board->peripherals & BP_GAMEPAD) {
qemu_irq gpad_irq[5];
static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };
*
* This code is licenced under the GPL.
*/
-#include "hw.h"
-#include "arm-misc.h"
+#include "sysbus.h"
#include "net.h"
#include <zlib.h>
#define SE_TCTL_DUPLEX 0x08
typedef struct {
+ SysBusDevice busdev;
uint32_t ris;
uint32_t im;
uint32_t rctl;
qemu_free(s);
}
-void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)
+static void stellaris_enet_init(SysBusDevice *dev)
{
- stellaris_enet_state *s;
+ stellaris_enet_state *s = FROM_SYSBUS(stellaris_enet_state, dev);
- qemu_check_nic_model(nd, "stellaris");
-
- s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state));
s->mmio_index = cpu_register_io_memory(0, stellaris_enet_readfn,
stellaris_enet_writefn, s);
- cpu_register_physical_memory(base, 0x00001000, s->mmio_index);
- s->irq = irq;
- memcpy(s->macaddr, nd->macaddr, 6);
-
- if (nd->vlan) {
- s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
- stellaris_enet_receive,
- stellaris_enet_can_receive,
- stellaris_enet_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
- }
+ sysbus_init_mmio(dev, 0x1000, s->mmio_index);
+ sysbus_init_irq(dev, &s->irq);
+ qdev_get_macaddr(&dev->qdev, s->macaddr);
+
+ s->vc = qdev_get_vlan_client(&dev->qdev,
+ stellaris_enet_receive,
+ stellaris_enet_can_receive,
+ stellaris_enet_cleanup, s);
+ qemu_format_nic_info_str(s->vc, s->macaddr);
stellaris_enet_reset(s);
register_savevm("stellaris_enet", -1, 1,
stellaris_enet_save, stellaris_enet_load, s);
}
+
+static void stellaris_enet_register_devices(void)
+{
+ sysbus_register_dev("stellaris_enet", sizeof(stellaris_enet_state),
+ stellaris_enet_init);
+}
+
+device_init(stellaris_enet_register_devices)