VirtualBox

Changeset 82174 in vbox for trunk/src/VBox/Devices/PC/BIOS


Ignore:
Timestamp:
Nov 25, 2019 1:13:14 PM (5 years ago)
Author:
vboxsync
Message:

PC/BIOS/virtio.c: Fixes, seems to work now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/virtio.c

    r82164 r82174  
    6767{
    6868    /** Flags. */
    69     uint16_t        fFlags;
     69    volatile uint16_t        fFlags;
    7070    /** Next index to write an available buffer by the driver. */
    71     uint16_t        idxNextFree;
     71    volatile uint16_t        idxNextFree;
    7272    /** The ring - we only provide one entry. */
    73     uint16_t        au16Ring[VIRTIO_SCSI_RING_ELEM];
     73    volatile uint16_t        au16Ring[VIRTIO_SCSI_RING_ELEM];
    7474    /** Used event index. */
    75     uint16_t        u16EvtUsed;
     75    volatile uint16_t        u16EvtUsed;
    7676} virtio_q_avail_t;
    7777
     
    437437{
    438438    uint16_t idxUsedOld = virtio->Queue.UsedRing.idxNextUsed;
    439     uint64_t idxNext = virtio->Queue.AvailRing.idxNextFree;
    440439
    441440    _fmemset(&virtio->ScsiReqHdr, 0, sizeof(virtio->ScsiReqHdr));
     
    459458    virtio->Queue.aDescTbl[1].cbBuf         = length;
    460459    virtio->Queue.aDescTbl[1].fFlags        = VIRTIO_Q_DESC_F_NEXT;
    461     virtio->Queue.aDescTbl[1].idxNext       = 1;
    462 
    463     virtio->Queue.aDescTbl[1].GCPhysBufLow  = virtio_addr_to_phys(&virtio->ScsiReqSts);
    464     virtio->Queue.aDescTbl[1].GCPhysBufHigh = 0;
    465     virtio->Queue.aDescTbl[1].cbBuf         = sizeof(virtio->ScsiReqSts);
    466     virtio->Queue.aDescTbl[1].fFlags        = VIRTIO_Q_DESC_F_WRITE; /* End of chain. */
    467     virtio->Queue.aDescTbl[1].idxNext       = 0;
     460    virtio->Queue.aDescTbl[1].idxNext       = 2;
     461
     462    virtio->Queue.aDescTbl[2].GCPhysBufLow  = virtio_addr_to_phys(&virtio->ScsiReqSts);
     463    virtio->Queue.aDescTbl[2].GCPhysBufHigh = 0;
     464    virtio->Queue.aDescTbl[2].cbBuf         = sizeof(virtio->ScsiReqSts);
     465    virtio->Queue.aDescTbl[2].fFlags        = VIRTIO_Q_DESC_F_WRITE; /* End of chain. */
     466    virtio->Queue.aDescTbl[2].idxNext       = 0;
    468467
    469468    /* Put it into the queue. */
     
    474473    /* Notify the device about the new command. */
    475474    DBG_VIRTIO("VirtIO: Submitting new request, Queue.offNotify=0x%x\n", virtio->Queue.offNotify);
    476     virtio_reg_notify_write_u16(virtio, virtio->Queue.offNotify, idxNext);
     475    virtio_reg_notify_write_u16(virtio, virtio->Queue.offNotify, VIRTIO_SCSI_Q_REQUEST);
    477476
    478477    /* Wait for it to complete. */
     
    481480    DBG_VIRTIO("VirtIO: Request complete u8Response=%u\n", virtio->ScsiReqSts.u8Response);
    482481
    483     /* Read ISR register to de-assert the interrupt, don't need to do anything with out. */
     482    /* Read ISR register to de-assert the interrupt, don't need to do anything with it. */
    484483    virtio_reg_isr_read_u8(virtio);
    485484
     
    494493{
    495494    uint16_t idxUsedOld = virtio->Queue.UsedRing.idxNextUsed;
    496     uint64_t idxNext = virtio->Queue.AvailRing.idxNextFree;
    497495
    498496    _fmemset(&virtio->ScsiReqHdr, 0, sizeof(virtio->ScsiReqHdr));
     
    532530    /* Notify the device about the new command. */
    533531    DBG_VIRTIO("VirtIO: Submitting new request, Queue.offNotify=0x%x\n", virtio->Queue.offNotify);
    534     virtio_reg_notify_write_u16(virtio, virtio->Queue.offNotify, idxNext);
     532    virtio_reg_notify_write_u16(virtio, virtio->Queue.offNotify, VIRTIO_SCSI_Q_REQUEST);
    535533
    536534    /* Wait for it to complete. */
     
    539537    DBG_VIRTIO("VirtIO: Request complete u8Response=%u\n", virtio->ScsiReqSts.u8Response);
    540538
    541     /* Read ISR register to de-assert the interrupt, don't need to do anything with out. */
     539    /* Read ISR register to de-assert the interrupt, don't need to do anything with it. */
    542540    virtio_reg_isr_read_u8(virtio);
    543541
     
    10391037                default:
    10401038                    DBG_VIRTIO("VirtIO SCSI HBA with unknown PCI capability type 0x%x\n", u8PciVirtioCfg);
     1039                    break;
    10411040            }
    10421041        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette