#include "vl.h"
/* debug LANCE card */
-#define DEBUG_LANCE
-
-#define PHYS_JJ_IOMMU 0x10000000 /* First page of sun4m IOMMU */
-#define PHYS_JJ_LEDMA 0x78400010 /* ledma, off by 10 from unused SCSI */
-#define PHYS_JJ_LE 0x78C00000 /* LANCE, typical sun4m */
+//#define DEBUG_LANCE
#ifndef LANCE_LOG_TX_BUFFERS
#define LANCE_LOG_TX_BUFFERS 4
#endif
typedef struct LEDMAState {
+ uint32_t addr;
uint32_t regs[LEDMA_REGS];
} LEDMAState;
typedef struct LANCEState {
+ uint32_t paddr;
NetDriverState *nd;
uint32_t leptr;
uint16_t addr;
LEDMAState *ledma;
} LANCEState;
-static int lance_io_memory;
-
static unsigned int rxptr, txptr;
static void lance_send(void *opaque);
LANCEState *s = opaque;
uint32_t saddr;
- saddr = addr - PHYS_JJ_LE;
+ saddr = addr - s->paddr;
switch (saddr >> 1) {
case LE_RDP:
return s->regs[s->addr];
{
LANCEState *s = opaque;
uint32_t saddr;
- uint16_t clear, reg;
+ uint16_t reg;
- saddr = addr - PHYS_JJ_LE;
+ saddr = addr - s->paddr;
switch (saddr >> 1) {
case LE_RDP:
switch(s->addr) {
}
}
-static int ledma_io_memory;
-
static uint32_t ledma_mem_readl(void *opaque, target_phys_addr_t addr)
{
LEDMAState *s = opaque;
uint32_t saddr;
- saddr = (addr - PHYS_JJ_LEDMA) >> 2;
+ saddr = (addr - s->addr) >> 2;
if (saddr < LEDMA_REGS)
return s->regs[saddr];
else
LEDMAState *s = opaque;
uint32_t saddr;
- saddr = (addr - PHYS_JJ_LEDMA) >> 2;
+ saddr = (addr - s->addr) >> 2;
if (saddr < LEDMA_REGS)
s->regs[saddr] = val;
}
ledma_mem_writel,
};
-void lance_init(NetDriverState *nd, int irq)
+void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr)
{
LANCEState *s;
LEDMAState *led;
+ int lance_io_memory, ledma_io_memory;
s = qemu_mallocz(sizeof(LANCEState));
if (!s)
return;
+ s->paddr = leaddr;
+ s->nd = nd;
+ s->irq = irq;
+
lance_io_memory = cpu_register_io_memory(0, lance_mem_read, lance_mem_write, s);
- cpu_register_physical_memory(PHYS_JJ_LE, 8,
- lance_io_memory);
+ cpu_register_physical_memory(leaddr, 8, lance_io_memory);
+
led = qemu_mallocz(sizeof(LEDMAState));
if (!led)
return;
- ledma_io_memory = cpu_register_io_memory(0, ledma_mem_read, ledma_mem_write, led);
- cpu_register_physical_memory(PHYS_JJ_LEDMA, 16,
- ledma_io_memory);
-
- s->nd = nd;
s->ledma = led;
- s->irq = irq;
+ led->addr = ledaddr;
+ ledma_io_memory = cpu_register_io_memory(0, ledma_mem_read, ledma_mem_write, led);
+ cpu_register_physical_memory(ledaddr, 16, ledma_io_memory);
lance_reset(s);
qemu_add_read_packet(nd, lance_can_receive, lance_receive, s);