Patchwork target-or32: replace NE2000 with OpenCores 10/100 ethernet adapter

login
register
mail settings
Submitter Max Filippov
Date June 20, 2012, 8:10 p.m.
Message ID <1340223059-17445-1-git-send-email-jcmvbkbc@gmail.com>
Download mbox | patch
Permalink /patch/166142/
State New
Headers show

Comments

Max Filippov - June 20, 2012, 8:10 p.m.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 default-configs/or32-softmmu.mak |    2 +-
 hw/openrisc_sim.c                |   24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)
Jia Liu - June 21, 2012, 1:54 a.m.
Hi Max,

On Thu, Jun 21, 2012 at 4:10 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  default-configs/or32-softmmu.mak |    2 +-
>  hw/openrisc_sim.c                |   24 +++++++++++++++++++++++-
>  2 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/default-configs/or32-softmmu.mak b/default-configs/or32-softmmu.mak
> index 7590eed..d85b82b 100644
> --- a/default-configs/or32-softmmu.mak
> +++ b/default-configs/or32-softmmu.mak
> @@ -2,5 +2,5 @@
>
>  include pci.mak
>  CONFIG_SERIAL=y
> -CONFIG_NE2000_ISA=y
> +CONFIG_OPENCORES_ETH=y
>  CONFIG_I8259=y
> diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c
> index 2fe27f5..7e4cbac 100644
> --- a/hw/openrisc_sim.c
> +++ b/hw/openrisc_sim.c
> @@ -28,6 +28,7 @@
>  #include "sysemu.h"
>  #include "isa.h"
>  #include "qtest.h"
> +#include "sysbus.h"
>
>  #define KERNEL_LOAD_ADDR 0x100
>
> @@ -80,6 +81,26 @@ static uint64_t openrisc_load_kernel(void)
>     return entry;
>  }
>
> +static void openrisc_sim_net_init(MemoryRegion *address_space,
> +        target_phys_addr_t base,
> +        target_phys_addr_t descriptors,
> +        qemu_irq irq, NICInfo *nd)
> +{
> +    DeviceState *dev;
> +    SysBusDevice *s;
> +
> +    dev = qdev_create(NULL, "open_eth");
> +    qdev_set_nic_properties(dev, nd);
> +    qdev_init_nofail(dev);
> +
> +    s = sysbus_from_qdev(dev);
> +    sysbus_connect_irq(s, 0, irq);
> +    memory_region_add_subregion(address_space, base,
> +            sysbus_mmio_get_region(s, 0));
> +    memory_region_add_subregion(address_space, descriptors,
> +            sysbus_mmio_get_region(s, 1));
> +}
> +
>  static void openrisc_sim_init(ram_addr_t ram_size,
>                               const char *boot_device,
>                               const char *kernel_filename,
> @@ -125,7 +146,8 @@ static void openrisc_sim_init(ram_addr_t ram_size,
>                    env->irq[2], 115200, serial_hds[0], DEVICE_NATIVE_ENDIAN);
>
>     if (nd_table[0].vlan) {
> -        isa_ne2000_init(isa_bus, 0x92000000, 4, &nd_table[0]);
> +        openrisc_sim_net_init(get_system_memory(), 0x92000000,
> +                0x92000400, env->irq[4], nd_table);
>     }
>  }
>

Thank you very much!
I've combine it into v6 patches.

> --
> 1.7.7.6
>

Regards,
Jia.

Patch

diff --git a/default-configs/or32-softmmu.mak b/default-configs/or32-softmmu.mak
index 7590eed..d85b82b 100644
--- a/default-configs/or32-softmmu.mak
+++ b/default-configs/or32-softmmu.mak
@@ -2,5 +2,5 @@ 
 
 include pci.mak
 CONFIG_SERIAL=y
-CONFIG_NE2000_ISA=y
+CONFIG_OPENCORES_ETH=y
 CONFIG_I8259=y
diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c
index 2fe27f5..7e4cbac 100644
--- a/hw/openrisc_sim.c
+++ b/hw/openrisc_sim.c
@@ -28,6 +28,7 @@ 
 #include "sysemu.h"
 #include "isa.h"
 #include "qtest.h"
+#include "sysbus.h"
 
 #define KERNEL_LOAD_ADDR 0x100
 
@@ -80,6 +81,26 @@  static uint64_t openrisc_load_kernel(void)
     return entry;
 }
 
+static void openrisc_sim_net_init(MemoryRegion *address_space,
+        target_phys_addr_t base,
+        target_phys_addr_t descriptors,
+        qemu_irq irq, NICInfo *nd)
+{
+    DeviceState *dev;
+    SysBusDevice *s;
+
+    dev = qdev_create(NULL, "open_eth");
+    qdev_set_nic_properties(dev, nd);
+    qdev_init_nofail(dev);
+
+    s = sysbus_from_qdev(dev);
+    sysbus_connect_irq(s, 0, irq);
+    memory_region_add_subregion(address_space, base,
+            sysbus_mmio_get_region(s, 0));
+    memory_region_add_subregion(address_space, descriptors,
+            sysbus_mmio_get_region(s, 1));
+}
+
 static void openrisc_sim_init(ram_addr_t ram_size,
                               const char *boot_device,
                               const char *kernel_filename,
@@ -125,7 +146,8 @@  static void openrisc_sim_init(ram_addr_t ram_size,
                    env->irq[2], 115200, serial_hds[0], DEVICE_NATIVE_ENDIAN);
 
     if (nd_table[0].vlan) {
-        isa_ne2000_init(isa_bus, 0x92000000, 4, &nd_table[0]);
+        openrisc_sim_net_init(get_system_memory(), 0x92000000,
+                0x92000400, env->irq[4], nd_table);
     }
 }