[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 29/45] hw/arm/stellaris: use qemu_find_nic_info()
From: |
David Woodhouse |
Subject: |
[PATCH 29/45] hw/arm/stellaris: use qemu_find_nic_info() |
Date: |
Sun, 22 Oct 2023 16:51:44 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
Rather than just using qemu_configure_nic_device(), populate the MAC
address in the system-registers device by peeking at the NICInfo before
it's assigned to the device.
Generate the MAC address early, if there is no matching -nic option.
Otherwise the MAC address wouldn't be generated until net_client_init1()
runs.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/arm/stellaris.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index aa5b0ddfaa..9385ccaafb 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -1025,7 +1025,8 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
DeviceState *ssys_dev;
int i;
int j;
- const uint8_t *macaddr;
+ NICInfo *nd;
+ MACAddr mac;
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
@@ -1048,12 +1049,22 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
* need its sysclk output.
*/
ssys_dev = qdev_new(TYPE_STELLARIS_SYS);
- /* Most devices come preprogrammed with a MAC address in the user data. */
- macaddr = nd_table[0].macaddr.a;
+
+ /*
+ * Most devices come preprogrammed with a MAC address in the user data.
+ * Generate a MAC address now, if there isn't a matching -nic for it.
+ */
+ nd = qemu_find_nic_info("stellaris_enet", true, "stellaris");
+ if (nd) {
+ memcpy(mac.a, nd->macaddr.a, sizeof(mac.a));
+ } else {
+ qemu_macaddr_default_if_unset(&mac);
+ }
+
qdev_prop_set_uint32(ssys_dev, "user0",
- macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16));
+ mac.a[0] | (mac.a[1] << 8) | (mac.a[2] << 16));
qdev_prop_set_uint32(ssys_dev, "user1",
- macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16));
+ mac.a[3] | (mac.a[4] << 8) | (mac.a[5] << 16));
qdev_prop_set_uint32(ssys_dev, "did0", board->did0);
qdev_prop_set_uint32(ssys_dev, "did1", board->did1);
qdev_prop_set_uint32(ssys_dev, "dc0", board->dc0);
@@ -1265,10 +1276,13 @@ static void stellaris_init(MachineState *ms,
stellaris_board_info *board)
if (board->dc4 & (1 << 28)) {
DeviceState *enet;
- qemu_check_nic_model(&nd_table[0], "stellaris");
-
enet = qdev_new("stellaris_enet");
- qdev_set_nic_properties(enet, &nd_table[0]);
+ if (nd) {
+ qdev_set_nic_properties(enet, nd);
+ } else {
+ qdev_prop_set_macaddr(enet, "mac", mac.a);
+ }
+
sysbus_realize_and_unref(SYS_BUS_DEVICE(enet), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(enet), 0, 0x40048000);
sysbus_connect_irq(SYS_BUS_DEVICE(enet), 0, qdev_get_gpio_in(nvic,
42));
--
2.40.1
- [PATCH 38/45] hw/riscv: use qemu_configure_nic_device(), (continued)
- [PATCH 38/45] hw/riscv: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 20/45] hw/xtensa/virt: use pci_init_nic_devices(), David Woodhouse, 2023/10/22
- [PATCH 30/45] hw/arm: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 04/45] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot(), David Woodhouse, 2023/10/22
- [PATCH 22/45] hw/arm/aspeed: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 19/45] hw/sparc64/sun4u: use pci_init_nic_devices(), David Woodhouse, 2023/10/22
- [PATCH 34/45] hw/microblaze: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 28/45] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases, David Woodhouse, 2023/10/22
- [PATCH 29/45] hw/arm/stellaris: use qemu_find_nic_info(),
David Woodhouse <=
- [PATCH 05/45] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2023/10/22
- [PATCH 25/45] hw/net/smc91c111: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 39/45] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 36/45] hw/net/lasi_i82596: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 14/45] hw/mips/loongson3_virt: use pci_init_nic_devices(), David Woodhouse, 2023/10/22
- [PATCH 01/45] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info(), David Woodhouse, 2023/10/22
- [PATCH 44/45] net: remove qemu_show_nic_models(), qemu_find_nic_model(), David Woodhouse, 2023/10/22
- [PATCH 21/45] hw/arm/allwinner: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22
- [PATCH 13/45] hw/mips/malta: use pci_init_nic_devices(), David Woodhouse, 2023/10/22
- [PATCH 31/45] hw/net/etraxfs-eth: use qemu_configure_nic_device(), David Woodhouse, 2023/10/22