src/dev/arm/ufs_device.cc
/**
 * Dma transaction function: write device. Note that the dma action is
 * from a device perspective, while this function is from an initiator
 * perspective
 */
Dma transaction function: write device. Note that the dma action is
from a device perspective, while this function is from an initiator
perspective
Dma transaction function : write device . Note that the dma action is from a device perspective while this function is from an initiator perspective
void
UFSHostDevice::writeDevice(Event* additional_action, bool toDisk, Addr
                           start, int size, uint8_t* destination, uint64_t
                           SCSIDiskOffset, uint32_t lun_id)
{
    DPRINTF(UFSHostDevice, "Write transaction Start: 0x%8x; Size: %d\n",
            start, size);
    if (toDisk) {
        ++writePendingNum;
        while (!writeDoneEvent.empty() && (writeDoneEvent.front().when()
                                          < curTick()))
            writeDoneEvent.pop_front();
        writeDoneEvent.push_back(
            EventFunctionWrapper([this]{ writeDone(); },
                                 name()));
        assert(!writeDoneEvent.back().scheduled());
        struct transferInfo new_transfer;
        new_transfer.offset = SCSIDiskOffset;
        new_transfer.size = size;
        new_transfer.lunID = lun_id;
        new_transfer.filePointer = 0;
        SSDWriteinfo.push_back(new_transfer);
        SSDWriteinfo.back().buffer.resize(size);
        dmaPort.dmaAction(MemCmd::ReadReq, start, size,
                          &writeDoneEvent.back(),
                          &SSDWriteinfo.back().buffer[0], 0);
        DPRINTF(UFSHostDevice, "Write to disk scheduled\n");
    } else {
        assert(!additional_action->scheduled());
        dmaPort.dmaAction(MemCmd::ReadReq, start, size,
                          additional_action, destination, 0);
        DPRINTF(UFSHostDevice, "Write scheduled\n");
    }
}
void UFSHostDevice :: writeDevice ( Event * additional_action , bool toDisk , Addr start , int size , uint8_t * destination , uint64_t SCSIDiskOffset , uint32_t lun_id ) { DPRINTF ( UFSHostDevice , " \n " , start , size ) ; if ( toDisk ) { ++ writePendingNum ; while ( ! writeDoneEvent . empty ( ) && ( writeDoneEvent . front ( ) . when ( ) < curTick ( ) ) ) writeDoneEvent . pop_front ( ) ; writeDoneEvent . push_back ( EventFunctionWrapper ( [ this ] { writeDone ( ) ; } , name ( ) ) ) ; assert ( ! writeDoneEvent . back ( ) . scheduled ( ) ) ; struct transferInfo new_transfer ; new_transfer . offset = SCSIDiskOffset ; new_transfer . size = size ; new_transfer . lunID = lun_id ; new_transfer . filePointer = 0 ; SSDWriteinfo . push_back ( new_transfer ) ; SSDWriteinfo . back ( ) . buffer . resize ( size ) ; dmaPort . dmaAction ( MemCmd :: ReadReq , start , size , & writeDoneEvent . back ( ) , & SSDWriteinfo . back ( ) . buffer [ 0 ] , 0 ) ; DPRINTF ( UFSHostDevice , " \n " ) ; } else { assert ( ! additional_action -> scheduled ( ) ) ; dmaPort . dmaAction ( MemCmd :: ReadReq , start , size , additional_action , destination , 0 ) ; DPRINTF ( UFSHostDevice , " \n " ) ; } }
Dma transaction function: write device.
Dma transaction function : write device .
/**check whether transfer is all the way to the flash*/ /**destination is an offset here since we are writing to a disk*/ /**allocate appropriate buffer*/ /**transaction*/ //yes, a readreq at a write device function is correct.