@@ -44,6 +44,7 @@
#include "exec/address-spaces.h"
#include "sysemu/qtest.h"
#include "qemu/error-report.h"
+#include "hw/net/dp8393x.h"
enum jazz_model_e
{
@@ -267,7 +268,7 @@ 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, get_system_memory(), rc4030[4],
+ dp83932_init(nd, 0x80001000, 2, 0, get_system_memory(), rc4030[4],
rc4030_opaque, rc4030_dma_memory_rw);
break;
} else if (is_help_option(nd->model)) {
@@ -20,7 +20,7 @@
#include "hw/hw.h"
#include "qemu/timer.h"
#include "net/net.h"
-#include "hw/mips/mips.h"
+#include "hw/net/dp8393x.h"
//#define DEBUG_SONIC
@@ -148,6 +148,7 @@ do { printf("sonic ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0)
typedef struct dp8393xState {
/* Hardware */
int it_shift;
+ int regs_offset;
qemu_irq irq;
#ifdef DEBUG_SONIC
int irq_level;
@@ -609,6 +610,7 @@ static uint32_t dp8393x_readw(void *opaque, hwaddr addr)
dp8393xState *s = opaque;
int reg;
+ addr -= s->regs_offset;
if ((addr & ((1 << s->it_shift) - 1)) != 0) {
return 0;
}
@@ -636,6 +638,7 @@ static void dp8393x_writew(void *opaque, hwaddr addr, uint32_t val)
dp8393xState *s = opaque;
int reg;
+ addr -= s->regs_offset;
if ((addr & ((1 << s->it_shift) - 1)) != 0) {
return;
}
@@ -877,7 +880,7 @@ static NetClientInfo net_dp83932_info = {
.cleanup = nic_cleanup,
};
-void dp83932_init(NICInfo *nd, hwaddr base, int it_shift,
+void dp83932_init(NICInfo *nd, hwaddr base, 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))
@@ -892,6 +895,7 @@ void dp83932_init(NICInfo *nd, hwaddr base, int it_shift,
s->mem_opaque = mem_opaque;
s->memory_rw = memory_rw;
s->it_shift = it_shift;
+ s->regs_offset = regs_offset;
s->irq = irq;
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
@@ -23,10 +23,4 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
qemu_irq **irqs, rc4030_dma **dmas,
MemoryRegion *sysmem);
-/* dp8393x.c */
-void dp83932_init(NICInfo *nd, hwaddr base, int it_shift,
- MemoryRegion *address_space,
- qemu_irq irq, void* mem_opaque,
- void (*memory_rw)(void *opaque, hwaddr addr, uint8_t *buf, int len, int is_write));
-
#endif
new file mode 100644
@@ -0,0 +1,6 @@
+void dp83932_init(NICInfo *nd, hwaddr base, 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));
+
Signed-off-by: Laurent Vivier <laurent@vivier.eu> --- hw/mips/mips_jazz.c | 3 ++- hw/net/dp8393x.c | 8 ++++++-- include/hw/mips/mips.h | 6 ------ include/hw/net/dp8393x.h | 6 ++++++ 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 include/hw/net/dp8393x.h