qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Leon Alrae" <leon.alrae@imgtec.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 2/3] dp8393x: add PROM to store MAC address
Date: Mon, 29 Dec 2014 01:39:09 +0100	[thread overview]
Message-ID: <1419813550-26182-3-git-send-email-laurent@vivier.eu> (raw)
In-Reply-To: <1419813550-26182-1-git-send-email-laurent@vivier.eu>

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 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

  parent reply	other threads:[~2014-12-29  0:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-29  0:39 [Qemu-devel] [PATCH 0/3] dp8393x update Laurent Vivier
2014-12-29  0:39 ` [Qemu-devel] [PATCH 1/3] dp8393x: add registers offset Laurent Vivier
2014-12-29  0:39 ` Laurent Vivier [this message]
2014-12-29  0:39 ` [Qemu-devel] [PATCH 3/3] qdev'ify dp8393x Laurent Vivier
2015-01-01 16:15   ` Andreas Färber
2015-01-01 17:32     ` Laurent Vivier
2015-01-01 21:01 ` [Qemu-devel] [PATCH 0/3] dp8393x update Hervé Poussineau
2015-01-02  1:34   ` Laurent Vivier
2015-01-02  9:25     ` Laurent Vivier
2015-01-02 10:19       ` Peter Maydell
2015-01-02 11:33         ` Laurent Vivier
2015-01-02 12:31           ` Peter Maydell

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=1419813550-26182-3-git-send-email-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=aurelien@aurel32.net \
    --cc=hpoussin@reactos.org \
    --cc=leon.alrae@imgtec.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).