提交 50132156 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

smc91c111: use qdev properties for configuration.

Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 508ef936
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
typedef struct { typedef struct {
SysBusDevice busdev; SysBusDevice busdev;
VLANClientState *vc; VLANClientState *vc;
NICConf conf;
uint16_t tcr; uint16_t tcr;
uint16_t rcr; uint16_t rcr;
uint16_t cr; uint16_t cr;
...@@ -42,7 +43,6 @@ typedef struct { ...@@ -42,7 +43,6 @@ typedef struct {
uint8_t data[NUM_PACKETS][2048]; uint8_t data[NUM_PACKETS][2048];
uint8_t int_level; uint8_t int_level;
uint8_t int_mask; uint8_t int_mask;
uint8_t macaddr[6];
int mmio_index; int mmio_index;
} smc91c111_state; } smc91c111_state;
...@@ -474,7 +474,7 @@ static uint32_t smc91c111_readb(void *opaque, target_phys_addr_t offset) ...@@ -474,7 +474,7 @@ static uint32_t smc91c111_readb(void *opaque, target_phys_addr_t offset)
/* Not implemented. */ /* Not implemented. */
return 0; return 0;
case 4: case 5: case 6: case 7: case 8: case 9: /* IA */ case 4: case 5: case 6: case 7: case 8: case 9: /* IA */
return s->macaddr[offset - 4]; return s->conf.macaddr.a[offset - 4];
case 10: /* General Purpose */ case 10: /* General Purpose */
return s->gpr & 0xff; return s->gpr & 0xff;
case 11: case 11:
...@@ -696,8 +696,7 @@ static void smc91c111_cleanup(VLANClientState *vc) ...@@ -696,8 +696,7 @@ static void smc91c111_cleanup(VLANClientState *vc)
{ {
smc91c111_state *s = vc->opaque; smc91c111_state *s = vc->opaque;
cpu_unregister_io_memory(s->mmio_index); s->vc = NULL;
qemu_free(s);
} }
static int smc91c111_init1(SysBusDevice *dev) static int smc91c111_init1(SysBusDevice *dev)
...@@ -708,21 +707,33 @@ static int smc91c111_init1(SysBusDevice *dev) ...@@ -708,21 +707,33 @@ static int smc91c111_init1(SysBusDevice *dev)
smc91c111_writefn, s); smc91c111_writefn, s);
sysbus_init_mmio(dev, 16, s->mmio_index); sysbus_init_mmio(dev, 16, s->mmio_index);
sysbus_init_irq(dev, &s->irq); sysbus_init_irq(dev, &s->irq);
qdev_get_macaddr(&dev->qdev, s->macaddr); qemu_macaddr_default_if_unset(&s->conf.macaddr);
smc91c111_reset(s); smc91c111_reset(s);
s->vc = qdev_get_vlan_client(&dev->qdev, s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC,
s->conf.vlan, s->conf.peer,
dev->qdev.info->name, dev->qdev.id,
smc91c111_can_receive, smc91c111_receive, NULL, smc91c111_can_receive, smc91c111_receive, NULL,
smc91c111_cleanup, s); NULL, smc91c111_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr); qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
/* ??? Save/restore. */ /* ??? Save/restore. */
return 0; return 0;
} }
static SysBusDeviceInfo smc91c111_info = {
.init = smc91c111_init1,
.qdev.name = "smc91c111",
.qdev.size = sizeof(smc91c111_state),
.qdev.props = (Property[]) {
DEFINE_NIC_PROPERTIES(smc91c111_state, conf),
DEFINE_PROP_END_OF_LIST(),
}
};
static void smc91c111_register_devices(void) static void smc91c111_register_devices(void)
{ {
sysbus_register_dev("smc91c111", sizeof(smc91c111_state), smc91c111_init1); sysbus_register_withprop(&smc91c111_info);
} }
/* Legacy helper function. Should go away when machine config files are /* Legacy helper function. Should go away when machine config files are
...@@ -734,7 +745,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) ...@@ -734,7 +745,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
qemu_check_nic_model(nd, "smc91c111"); qemu_check_nic_model(nd, "smc91c111");
dev = qdev_create(NULL, "smc91c111"); dev = qdev_create(NULL, "smc91c111");
dev->nd = nd; qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev); qdev_init_nofail(dev);
s = sysbus_from_qdev(dev); s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, base); sysbus_mmio_map(s, 0, base);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册