All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>,
	"Leon Alrae" <leon.alrae@imgtec.com>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 7/8] net/dp8393x: add PROM to store MAC address
Date: Thu,  5 Mar 2015 23:13:25 +0100	[thread overview]
Message-ID: <1425593606-5909-8-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <1425593606-5909-1-git-send-email-hpoussin@reactos.org>

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/mips/mips_jazz.c |    1 +
 hw/net/dp8393x.c    |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 16a8368..cb33c9c 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -280,6 +280,7 @@ static void mips_jazz_init(MachineState *machine,
             qdev_init_nofail(dev);
             sysbus = SYS_BUS_DEVICE(dev);
             sysbus_mmio_map(sysbus, 0, 0x80001000);
+            sysbus_mmio_map(sysbus, 1, 0x8000b000);
             sysbus_connect_irq(sysbus, 0, rc4030[4]);
             break;
         } else if (is_help_option(nd->model)) {
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 53c0cdc..7b658d9 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -25,6 +25,7 @@
 
 //#define DEBUG_SONIC
 
+#define SONIC_PROM_SIZE 0x1000
 
 #ifdef DEBUG_SONIC
 #define DPRINTF(fmt, ...) \
@@ -156,6 +157,7 @@ typedef struct dp8393xState {
     NICConf conf;
     NICState *nic;
     MemoryRegion mmio;
+    MemoryRegion prom;
 
     /* Registers */
     uint8_t cam[16][6];
@@ -813,12 +815,15 @@ static void dp8393x_instance_init(Object *obj)
     dp8393xState *s = DP8393X(obj);
 
     sysbus_init_mmio(sbd, &s->mmio);
+    sysbus_init_mmio(sbd, &s->prom);
     sysbus_init_irq(sbd, &s->irq);
 }
 
 static void dp8393x_realize(DeviceState *dev, Error **errp)
 {
     dp8393xState *s = DP8393X(dev);
+    int i, checksum;
+    uint8_t *prom;
 
     address_space_init(&s->as, s->dma_mr, "dp8393x");
     memory_region_init_io(&s->mmio, NULL, &dp8393x_ops, s,
@@ -830,6 +835,19 @@ static void dp8393x_realize(DeviceState *dev, Error **errp)
 
     s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
     s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
+
+    memory_region_init_rom_device(&s->prom, NULL, NULL, NULL,
+                                  "dp8393x-prom", SONIC_PROM_SIZE, NULL);
+    prom = memory_region_get_ram_ptr(&s->prom);
+    checksum = 0;
+    for (i = 0; i < 6; i++) {
+        prom[i] = s->conf.macaddr.a[i];
+        checksum += prom[i];
+        if (checksum > 0xff) {
+            checksum = (checksum + 1) & 0xff;
+        }
+    }
+    prom[7] = 0xff - checksum;
 }
 
 static Property dp8393x_properties[] = {
-- 
1.7.10.4

  parent reply	other threads:[~2015-03-05 22:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 22:13 [Qemu-devel] [PATCH 0/8] net/dp8393x improvements Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 1/8] rc4030: create custom DMA address space Hervé Poussineau
2015-03-25 14:45   ` Paolo Bonzini
2015-03-25 19:10     ` Hervé Poussineau
2015-03-26 14:15       ` Paolo Bonzini
2015-03-26 14:27   ` Paolo Bonzini
2015-03-05 22:13 ` [Qemu-devel] [PATCH 2/8] rc4030: use AddressSpace and address_space_rw in users Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 3/8] net/dp8393x: always calculate proper checksums Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 4/8] net/dp8393x: do not use old_mmio accesses Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 5/8] net/dp8393x: use dp8393x_ prefix for all functions Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 6/8] net/dp8393x: QOM'ify Hervé Poussineau
2015-03-05 22:13 ` Hervé Poussineau [this message]
2015-03-05 22:13 ` [Qemu-devel] [PATCH 8/8] net/dp8393x: add load/save support Hervé Poussineau
2015-03-25 14:13 ` [Qemu-devel] [PATCH 0/8] net/dp8393x improvements Leon Alrae
2015-04-29 14:56   ` Leon Alrae
2015-05-14 21:11     ` Hervé Poussineau

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=1425593606-5909-8-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=aurelien@aurel32.net \
    --cc=laurent@vivier.eu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.