From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5OMn-0006Lx-Q6 for qemu-devel@nongnu.org; Sun, 28 Dec 2014 19:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y5OMj-000499-W9 for qemu-devel@nongnu.org; Sun, 28 Dec 2014 19:39:25 -0500 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:59809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5OMj-00048e-QV for qemu-devel@nongnu.org; Sun, 28 Dec 2014 19:39:21 -0500 From: Laurent Vivier Date: Mon, 29 Dec 2014 01:39:09 +0100 Message-Id: <1419813550-26182-3-git-send-email-laurent@vivier.eu> In-Reply-To: <1419813550-26182-1-git-send-email-laurent@vivier.eu> References: <1419813550-26182-1-git-send-email-laurent@vivier.eu> Subject: [Qemu-devel] [PATCH 2/3] dp8393x: add PROM to store MAC address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Leon Alrae , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Laurent Vivier , Aurelien Jarno Signed-off-by: Laurent Vivier --- hw/mips/mips_jazz.c | 4 ++-- hw/net/dp8393x.c | 18 +++++++++++++++++- include/hw/net/dp8393x.h | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index ecfaacb..4d556ab 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -268,8 +268,8 @@ static void mips_jazz_init(MemoryRegion *address_space, if (!nd->model) nd->model = g_strdup("dp83932"); if (strcmp(nd->model, "dp83932") == 0) { - dp83932_init(nd, 0x80001000, 2, 0, get_system_memory(), rc4030[4], - rc4030_opaque, rc4030_dma_memory_rw); + dp83932_init(nd, 0x80001000, 0, 2, 0, get_system_memory(), + rc4030[4], rc4030_opaque, rc4030_dma_memory_rw); break; } else if (is_help_option(nd->model)) { fprintf(stderr, "qemu: Supported NICs: dp83932\n"); diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 343191f..bd97851 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -24,6 +24,8 @@ //#define DEBUG_SONIC +#define SONIC_PROM_SIZE 8192 + /* Calculate CRCs properly on Rx packets */ #define SONIC_CALCULATE_RXCRC @@ -159,6 +161,7 @@ typedef struct dp8393xState { NICState *nic; MemoryRegion *address_space; MemoryRegion mmio; + MemoryRegion prom; /* Registers */ uint8_t cam[16][6]; @@ -880,12 +883,15 @@ static NetClientInfo net_dp83932_info = { .cleanup = nic_cleanup, }; -void dp83932_init(NICInfo *nd, hwaddr base, int it_shift, int regs_offset, +void dp83932_init(NICInfo *nd, hwaddr base, hwaddr prombase, + int it_shift, int regs_offset, MemoryRegion *address_space, qemu_irq irq, void* mem_opaque, void (*memory_rw)(void *opaque, hwaddr addr, uint8_t *buf, int len, int is_write)) { dp8393xState *s; + int i; + uint8_t *prom; qemu_check_nic_model(nd, "dp83932"); @@ -912,4 +918,14 @@ void dp83932_init(NICInfo *nd, hwaddr base, int it_shift, int regs_offset, memory_region_init_io(&s->mmio, NULL, &dp8393x_ops, s, "dp8393x", 0x40 << it_shift); memory_region_add_subregion(address_space, base, &s->mmio); + + if (prombase) { + memory_region_init_rom_device(&s->prom, NULL, NULL, NULL, + "dp8393x-prom", SONIC_PROM_SIZE, NULL); + prom = memory_region_get_ram_ptr(&s->prom); + for (i = 0; i < 6; i++) { + prom[i] = s->conf.macaddr.a[i]; + } + memory_region_add_subregion(address_space, prombase, &s->prom); + } } diff --git a/include/hw/net/dp8393x.h b/include/hw/net/dp8393x.h index 21aa0f7..47eb187 100644 --- a/include/hw/net/dp8393x.h +++ b/include/hw/net/dp8393x.h @@ -1,4 +1,5 @@ -void dp83932_init(NICInfo *nd, hwaddr base, int it_shift, int regs_offset, +void dp83932_init(NICInfo *nd, hwaddr base, hwaddr rombase, + int it_shift, int regs_offset, MemoryRegion *address_space, qemu_irq irq, void *mem_opaque, void (*memory_rw)(void *opaque, hwaddr addr, uint8_t *buf, -- 1.9.1