|
@@ -15,6 +15,8 @@
|
|
#include "hw.h"
|
|
#include "hw.h"
|
|
#include "pci.h"
|
|
#include "pci.h"
|
|
#include "scsi.h"
|
|
#include "scsi.h"
|
|
|
|
+#include "block_int.h"
|
|
|
|
+#include "dma.h"
|
|
|
|
|
|
//#define DEBUG_LSI
|
|
//#define DEBUG_LSI
|
|
//#define DEBUG_LSI_REG
|
|
//#define DEBUG_LSI_REG
|
|
@@ -390,10 +392,7 @@ static inline uint32_t read_dword(LSIState *s, uint32_t addr)
|
|
{
|
|
{
|
|
uint32_t buf;
|
|
uint32_t buf;
|
|
|
|
|
|
- /* XXX: an optimization here used to fast-path the read from scripts
|
|
|
|
- * memory. But that bypasses any iommu.
|
|
|
|
- */
|
|
|
|
- cpu_physical_memory_read(addr, (uint8_t *)&buf, 4);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, addr, (uint8_t *)&buf, 4);
|
|
return cpu_to_le32(buf);
|
|
return cpu_to_le32(buf);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -532,7 +531,7 @@ static void lsi_bad_selection(LSIState *s, uint32_t id)
|
|
static void lsi_do_dma(LSIState *s, int out)
|
|
static void lsi_do_dma(LSIState *s, int out)
|
|
{
|
|
{
|
|
uint32_t count;
|
|
uint32_t count;
|
|
- target_phys_addr_t addr;
|
|
|
|
|
|
+ dma_addr_t addr;
|
|
SCSIDevice *dev;
|
|
SCSIDevice *dev;
|
|
|
|
|
|
assert(s->current);
|
|
assert(s->current);
|
|
@@ -558,7 +557,7 @@ static void lsi_do_dma(LSIState *s, int out)
|
|
else if (s->sbms)
|
|
else if (s->sbms)
|
|
addr |= ((uint64_t)s->sbms << 32);
|
|
addr |= ((uint64_t)s->sbms << 32);
|
|
|
|
|
|
- DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count);
|
|
|
|
|
|
+ DPRINTF("DMA addr=0x" DMA_ADDR_FMT " len=%d\n", addr, count);
|
|
s->csbc += count;
|
|
s->csbc += count;
|
|
s->dnad += count;
|
|
s->dnad += count;
|
|
s->dbc -= count;
|
|
s->dbc -= count;
|
|
@@ -567,9 +566,9 @@ static void lsi_do_dma(LSIState *s, int out)
|
|
}
|
|
}
|
|
/* ??? Set SFBR to first data byte. */
|
|
/* ??? Set SFBR to first data byte. */
|
|
if (out) {
|
|
if (out) {
|
|
- cpu_physical_memory_read(addr, s->current->dma_buf, count);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, addr, s->current->dma_buf, count);
|
|
} else {
|
|
} else {
|
|
- cpu_physical_memory_write(addr, s->current->dma_buf, count);
|
|
|
|
|
|
+ pci_dma_write(&s->dev, addr, s->current->dma_buf, count);
|
|
}
|
|
}
|
|
s->current->dma_len -= count;
|
|
s->current->dma_len -= count;
|
|
if (s->current->dma_len == 0) {
|
|
if (s->current->dma_len == 0) {
|
|
@@ -762,7 +761,7 @@ static void lsi_do_command(LSIState *s)
|
|
DPRINTF("Send command len=%d\n", s->dbc);
|
|
DPRINTF("Send command len=%d\n", s->dbc);
|
|
if (s->dbc > 16)
|
|
if (s->dbc > 16)
|
|
s->dbc = 16;
|
|
s->dbc = 16;
|
|
- cpu_physical_memory_read(s->dnad, buf, s->dbc);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, s->dnad, buf, s->dbc);
|
|
s->sfbr = buf[0];
|
|
s->sfbr = buf[0];
|
|
s->command_complete = 0;
|
|
s->command_complete = 0;
|
|
|
|
|
|
@@ -813,7 +812,7 @@ static void lsi_do_status(LSIState *s)
|
|
s->dbc = 1;
|
|
s->dbc = 1;
|
|
status = s->status;
|
|
status = s->status;
|
|
s->sfbr = status;
|
|
s->sfbr = status;
|
|
- cpu_physical_memory_write(s->dnad, &status, 1);
|
|
|
|
|
|
+ pci_dma_write(&s->dev, s->dnad, &status, 1);
|
|
lsi_set_phase(s, PHASE_MI);
|
|
lsi_set_phase(s, PHASE_MI);
|
|
s->msg_action = 1;
|
|
s->msg_action = 1;
|
|
lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */
|
|
lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */
|
|
@@ -827,7 +826,7 @@ static void lsi_do_msgin(LSIState *s)
|
|
len = s->msg_len;
|
|
len = s->msg_len;
|
|
if (len > s->dbc)
|
|
if (len > s->dbc)
|
|
len = s->dbc;
|
|
len = s->dbc;
|
|
- cpu_physical_memory_write(s->dnad, s->msg, len);
|
|
|
|
|
|
+ pci_dma_write(&s->dev, s->dnad, s->msg, len);
|
|
/* Linux drivers rely on the last byte being in the SIDL. */
|
|
/* Linux drivers rely on the last byte being in the SIDL. */
|
|
s->sidl = s->msg[len - 1];
|
|
s->sidl = s->msg[len - 1];
|
|
s->msg_len -= len;
|
|
s->msg_len -= len;
|
|
@@ -859,7 +858,7 @@ static void lsi_do_msgin(LSIState *s)
|
|
static uint8_t lsi_get_msgbyte(LSIState *s)
|
|
static uint8_t lsi_get_msgbyte(LSIState *s)
|
|
{
|
|
{
|
|
uint8_t data;
|
|
uint8_t data;
|
|
- cpu_physical_memory_read(s->dnad, &data, 1);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, s->dnad, &data, 1);
|
|
s->dnad++;
|
|
s->dnad++;
|
|
s->dbc--;
|
|
s->dbc--;
|
|
return data;
|
|
return data;
|
|
@@ -1011,8 +1010,8 @@ static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count)
|
|
DPRINTF("memcpy dest 0x%08x src 0x%08x count %d\n", dest, src, count);
|
|
DPRINTF("memcpy dest 0x%08x src 0x%08x count %d\n", dest, src, count);
|
|
while (count) {
|
|
while (count) {
|
|
n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count;
|
|
n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count;
|
|
- cpu_physical_memory_read(src, buf, n);
|
|
|
|
- cpu_physical_memory_write(dest, buf, n);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, src, buf, n);
|
|
|
|
+ pci_dma_write(&s->dev, dest, buf, n);
|
|
src += n;
|
|
src += n;
|
|
dest += n;
|
|
dest += n;
|
|
count -= n;
|
|
count -= n;
|
|
@@ -1080,7 +1079,7 @@ again:
|
|
|
|
|
|
/* 32-bit Table indirect */
|
|
/* 32-bit Table indirect */
|
|
offset = sxt24(addr);
|
|
offset = sxt24(addr);
|
|
- cpu_physical_memory_read(s->dsa + offset, (uint8_t *)buf, 8);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, s->dsa + offset, (uint8_t *)buf, 8);
|
|
/* byte count is stored in bits 0:23 only */
|
|
/* byte count is stored in bits 0:23 only */
|
|
s->dbc = cpu_to_le32(buf[0]) & 0xffffff;
|
|
s->dbc = cpu_to_le32(buf[0]) & 0xffffff;
|
|
s->rbc = s->dbc;
|
|
s->rbc = s->dbc;
|
|
@@ -1439,7 +1438,7 @@ again:
|
|
n = (insn & 7);
|
|
n = (insn & 7);
|
|
reg = (insn >> 16) & 0xff;
|
|
reg = (insn >> 16) & 0xff;
|
|
if (insn & (1 << 24)) {
|
|
if (insn & (1 << 24)) {
|
|
- cpu_physical_memory_read(addr, data, n);
|
|
|
|
|
|
+ pci_dma_read(&s->dev, addr, data, n);
|
|
DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", reg, n,
|
|
DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", reg, n,
|
|
addr, *(int *)data);
|
|
addr, *(int *)data);
|
|
for (i = 0; i < n; i++) {
|
|
for (i = 0; i < n; i++) {
|
|
@@ -1450,7 +1449,7 @@ again:
|
|
for (i = 0; i < n; i++) {
|
|
for (i = 0; i < n; i++) {
|
|
data[i] = lsi_reg_readb(s, reg + i);
|
|
data[i] = lsi_reg_readb(s, reg + i);
|
|
}
|
|
}
|
|
- cpu_physical_memory_write(addr, data, n);
|
|
|
|
|
|
+ pci_dma_write(&s->dev, addr, data, n);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|