From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 18/22] stellaris_enet: use qdev properties for configuration.
Date: Wed, 21 Oct 2009 15:25:39 +0200 [thread overview]
Message-ID: <1256131543-28416-19-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/stellaris.c | 2 +-
hw/stellaris_enet.c | 40 +++++++++++++++++++++++++---------------
2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 1628914..44c9eee 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1383,7 +1383,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
qemu_check_nic_model(&nd_table[0], "stellaris");
enet = qdev_create(NULL, "stellaris_enet");
- enet->nd = &nd_table[0];
+ qdev_set_nic_properties(enet, &nd_table[0]);
qdev_init_nofail(enet);
sysbus_mmio_map(sysbus_from_qdev(enet), 0, 0x40048000);
sysbus_connect_irq(sysbus_from_qdev(enet), 0, pic[42]);
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index 4596a69..fe2cffe 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -67,8 +67,8 @@ typedef struct {
int rx_fifo_len;
int next_packet;
VLANClientState *vc;
+ NICConf conf;
qemu_irq irq;
- uint8_t macaddr[6];
int mmio_index;
} stellaris_enet_state;
@@ -169,10 +169,10 @@ static uint32_t stellaris_enet_read(void *opaque, target_phys_addr_t offset)
}
return val;
case 0x14: /* IA0 */
- return s->macaddr[0] | (s->macaddr[1] << 8)
- | (s->macaddr[2] << 16) | (s->macaddr[3] << 24);
+ return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8)
+ | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24);
case 0x18: /* IA1 */
- return s->macaddr[4] | (s->macaddr[5] << 8);
+ return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8);
case 0x1c: /* THR */
return s->thr;
case 0x20: /* MCTL */
@@ -267,14 +267,14 @@ static void stellaris_enet_write(void *opaque, target_phys_addr_t offset,
}
break;
case 0x14: /* IA0 */
- s->macaddr[0] = value;
- s->macaddr[1] = value >> 8;
- s->macaddr[2] = value >> 16;
- s->macaddr[3] = value >> 24;
+ s->conf.macaddr.a[0] = value;
+ s->conf.macaddr.a[1] = value >> 8;
+ s->conf.macaddr.a[2] = value >> 16;
+ s->conf.macaddr.a[3] = value >> 24;
break;
case 0x18: /* IA1 */
- s->macaddr[4] = value;
- s->macaddr[5] = value >> 8;
+ s->conf.macaddr.a[4] = value;
+ s->conf.macaddr.a[5] = value >> 8;
break;
case 0x1c: /* THR */
s->thr = value;
@@ -404,13 +404,14 @@ static int stellaris_enet_init(SysBusDevice *dev)
stellaris_enet_writefn, s);
sysbus_init_mmio(dev, 0x1000, s->mmio_index);
sysbus_init_irq(dev, &s->irq);
- qdev_get_macaddr(&dev->qdev, s->macaddr);
+ qemu_macaddr_default_if_unset(&s->conf.macaddr);
- s->vc = qdev_get_vlan_client(&dev->qdev,
+ s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer,
+ dev->qdev.info->name, dev->qdev.id,
stellaris_enet_can_receive,
stellaris_enet_receive, NULL,
stellaris_enet_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
stellaris_enet_reset(s);
register_savevm("stellaris_enet", -1, 1,
@@ -418,10 +419,19 @@ static int stellaris_enet_init(SysBusDevice *dev)
return 0;
}
+static SysBusDeviceInfo stellaris_enet_info = {
+ .init = stellaris_enet_init,
+ .qdev.name = "stellaris_enet",
+ .qdev.size = sizeof(stellaris_enet_state),
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(stellaris_enet_state, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
static void stellaris_enet_register_devices(void)
{
- sysbus_register_dev("stellaris_enet", sizeof(stellaris_enet_state),
- stellaris_enet_init);
+ sysbus_register_withprop(&stellaris_enet_info);
}
device_init(stellaris_enet_register_devices)
--
1.6.2.5
next prev parent reply other threads:[~2009-10-21 13:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 01/22] net: add macaddr type Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 03/22] qdev: add netdev property Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 04/22] qdev: add vlan property Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists() Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 10/22] e1000: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 11/22] pcnet: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code) Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
2009-10-28 14:07 ` [Qemu-devel] [PATCH] virtio-net: fix macaddr config regression Mark McLoughlin
2009-10-21 13:25 ` [Qemu-devel] [PATCH 15/22] eepro100: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 16/22] smc91c111: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 17/22] xilinx_ethlite: " Gerd Hoffmann
2009-10-21 13:25 ` Gerd Hoffmann [this message]
2009-10-21 13:25 ` [Qemu-devel] [PATCH 19/22] musicpal: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 20/22] zap DeviceState->nd Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 21/22] kill dead nic unplug code Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 22/22] pc.c: only load e1000 rom Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1256131543-28416-19-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).