Now that pvscsi runs entirely in 32bit mode, there is no need to use the memory segment access macros.
This also fixes up an incorrect memcpy and memset call.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/pvscsi.c | 74 +++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 41 deletions(-)
diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c index 8b4b10f..601a551 100644 --- a/src/hw/pvscsi.c +++ b/src/hw/pvscsi.c @@ -7,7 +7,6 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "biosvar.h" // GET_GLOBALFLAT #include "block.h" // struct drive_s #include "blockcmd.h" // scsi_drive_setup #include "config.h" // CONFIG_* @@ -16,11 +15,12 @@ #include "pci.h" // foreachpci #include "pci_ids.h" // PCI_DEVICE_ID_VMWARE_PVSCSI #include "pci_regs.h" // PCI_VENDOR_ID +#include "pvscsi.h" // pvscsi_setup #include "std/disk.h" // DISK_RET_SUCCESS #include "string.h" // memset #include "util.h" // usleep -#include "pvscsi.h" #include "virtio-ring.h" // PAGE_SHIFT, virt_to_phys +#include "x86.h" // writel
#define MASK(n) ((1 << (n)) - 1)
@@ -159,7 +159,6 @@ pvscsi_wait_intr_cmpl(void *iobase) while (!(readl(iobase + PVSCSI_REG_OFFSET_INTR_STATUS) & PVSCSI_INTR_CMPL_MASK)) usleep(5); writel(iobase + PVSCSI_REG_OFFSET_INTR_STATUS, PVSCSI_INTR_CMPL_MASK); - }
static void @@ -203,60 +202,58 @@ static void pvscsi_fill_req(struct PVSCSIRingsState *s, u16 target, u16 lun, void *cdbcmd, u16 blocksize, struct disk_op_s *op) { - SET_LOWFLAT(req->bus, 0); - SET_LOWFLAT(req->target, target); - memset(LOWFLAT2LOW(&req->lun[0]), 0, sizeof(req->lun)); - SET_LOWFLAT(req->lun[1], lun); - SET_LOWFLAT(req->senseLen, 0); - SET_LOWFLAT(req->senseAddr, 0); - SET_LOWFLAT(req->cdbLen, 16); - SET_LOWFLAT(req->vcpuHint, 0); - memcpy(LOWFLAT2LOW(&req->cdb[0]), cdbcmd, 16); - SET_LOWFLAT(req->tag, SIMPLE_QUEUE_TAG); - SET_LOWFLAT(req->flags, - cdb_is_read(cdbcmd, blocksize) ? - PVSCSI_FLAG_CMD_DIR_TOHOST : PVSCSI_FLAG_CMD_DIR_TODEVICE); - - SET_LOWFLAT(req->dataLen, op->count * blocksize); - SET_LOWFLAT(req->dataAddr, (u32)op->buf_fl); - SET_LOWFLAT(s->reqProdIdx, GET_LOWFLAT(s->reqProdIdx) + 1); - + req->bus = 0; + req->target = target; + memset(req->lun, 0, sizeof(req->lun)); + req->lun[1] = lun; + req->senseLen = 0; + req->senseAddr = 0; + req->cdbLen = 16; + req->vcpuHint = 0; + memcpy(req->cdb, cdbcmd, 16); + req->tag = SIMPLE_QUEUE_TAG; + req->flags = cdb_is_read(cdbcmd, blocksize) ? + PVSCSI_FLAG_CMD_DIR_TOHOST : PVSCSI_FLAG_CMD_DIR_TODEVICE; + + req->dataLen = op->count * blocksize; + req->dataAddr = (u32)op->buf_fl; + s->reqProdIdx = s->reqProdIdx + 1; }
static u32 pvscsi_get_rsp(struct PVSCSIRingsState *s, struct PVSCSIRingCmpDesc *rsp) { - u32 status = GET_LOWFLAT(rsp->hostStatus); - SET_LOWFLAT(s->cmpConsIdx, GET_LOWFLAT(s->cmpConsIdx)+1); + u32 status = rsp->hostStatus; + s->cmpConsIdx = s->cmpConsIdx + 1; return status; }
static int -pvscsi_cmd(struct pvscsi_lun_s *plun_gf, struct disk_op_s *op, +pvscsi_cmd(struct pvscsi_lun_s *plun, struct disk_op_s *op, void *cdbcmd, u16 target, u16 lun, u16 blocksize) { - struct pvscsi_ring_dsc_s *ring_dsc = GET_GLOBALFLAT(plun_gf->ring_dsc); - struct PVSCSIRingsState *s = GET_LOWFLAT(ring_dsc->ring_state); - u32 req_entries = GET_LOWFLAT(s->reqNumEntriesLog2); - u32 cmp_entries = GET_LOWFLAT(s->cmpNumEntriesLog2); + struct pvscsi_ring_dsc_s *ring_dsc = plun->ring_dsc; + struct PVSCSIRingsState *s = ring_dsc->ring_state; + u32 req_entries = s->reqNumEntriesLog2; + u32 cmp_entries = s->cmpNumEntriesLog2; struct PVSCSIRingReqDesc *req; struct PVSCSIRingCmpDesc *rsp; u32 status;
- if (GET_LOWFLAT(s->reqProdIdx) - GET_LOWFLAT(s->cmpConsIdx) >= 1 << req_entries) { + if (s->reqProdIdx - s->cmpConsIdx >= 1 << req_entries) { dprintf(1, "pvscsi: ring full: reqProdIdx=%d cmpConsIdx=%d\n", - GET_LOWFLAT(s->reqProdIdx), GET_LOWFLAT(s->cmpConsIdx)); + s->reqProdIdx, s->cmpConsIdx); return DISK_RET_EBADTRACK; }
- req = GET_LOWFLAT(ring_dsc->ring_reqs) + (GET_LOWFLAT(s->reqProdIdx) & MASK(req_entries)); + req = ring_dsc->ring_reqs + (s->reqProdIdx & MASK(req_entries)); pvscsi_fill_req(s, req, target, lun, cdbcmd, blocksize, op);
- pvscsi_kick_rw_io(GET_GLOBALFLAT(plun_gf->iobase)); - pvscsi_wait_intr_cmpl(GET_GLOBALFLAT(plun_gf->iobase)); + pvscsi_kick_rw_io(plun->iobase); + pvscsi_wait_intr_cmpl(plun->iobase);
- rsp = GET_LOWFLAT(ring_dsc->ring_cmps) + (GET_LOWFLAT(s->cmpConsIdx) & MASK(cmp_entries)); + rsp = ring_dsc->ring_cmps + (s->cmpConsIdx & MASK(cmp_entries)); status = pvscsi_get_rsp(s, rsp);
return status == 0 ? DISK_RET_SUCCESS : DISK_RET_EBADTRACK; @@ -268,14 +265,10 @@ pvscsi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) if (!CONFIG_PVSCSI) return DISK_RET_EBADTRACK;
- struct pvscsi_lun_s *plun_gf = + struct pvscsi_lun_s *plun = container_of(op->drive_gf, struct pvscsi_lun_s, drive);
- return pvscsi_cmd(plun_gf, op, cdbcmd, - GET_GLOBALFLAT(plun_gf->target), - GET_GLOBALFLAT(plun_gf->lun), - blocksize); - + return pvscsi_cmd(plun, op, cdbcmd, plun->target, plun->lun, blocksize); }
static int @@ -340,7 +333,6 @@ init_pvscsi(struct pci_device *pci) pvscsi_scan_target(pci, iobase, ring_dsc, i);
return; - }
void