src/dev/arm/ufs_device.cc
/**
 * Request handler. Determines where the request comes from and initiates the
 * appropriate actions accordingly.
 */
Request handler. Determines where the request comes from and initiates the
appropriate actions accordingly.
Request handler . Determines where the request comes from and initiates the appropriate actions accordingly .
void
UFSHostDevice::requestHandler()
{
    Addr address = 0x00;
    int mask = 0x01;
    int size;
    int count = 0;
    struct taskStart task_info;
    struct transferStart transferstart_info;
    transferstart_info.done = 0;
    while (((UFSHCIMem.CMDUICCMDR > 0x00) |
            ((UFSHCIMem.TMUTMRLDBR ^ taskCommandTrack) > 0x00) |
            ((UFSHCIMem.TRUTRLDBR ^ transferTrack) > 0x00)) ) {
        if (UFSHCIMem.CMDUICCMDR > 0x00) {
            commandHandler();
            UFSHCIMem.ORInterruptStatus |= UICCommandCOMPL;
            generateInterrupt();
            UFSHCIMem.CMDUICCMDR = 0x00;
            return; 
        } else if ((UFSHCIMem.TMUTMRLDBR ^ taskCommandTrack) > 0x00) {
            size = sizeof(UTPUPIUTaskReq);
            count = findLsbSet((UFSHCIMem.TMUTMRLDBR ^ taskCommandTrack));
            address = UFSHCIMem.TMUTMRLBAU;
            address = (count * size) + (address << 32) +
                UFSHCIMem.TMUTMRLBA;
            taskCommandTrack |= mask << count;
            inform("UFSmodel received a task from the system; this might"
                   " lead to untested behaviour.\n");
            task_info.mask = mask << count;
            task_info.address = address;
            task_info.size = size;
            task_info.done = UFSHCIMem.TMUTMRLDBR;
            taskInfo.push_back(task_info);
            taskEventQueue.push_back(
                EventFunctionWrapper([this]{ taskStart(); }, name()));
            writeDevice(&taskEventQueue.back(), false, address, size,
                        reinterpret_cast<uint8_t*>
                        (&taskInfo.back().destination), 0, 0);
        } else if ((UFSHCIMem.TRUTRLDBR ^ transferTrack) > 0x00) {
            size = sizeof(UTPTransferReqDesc);
            count = findLsbSet((UFSHCIMem.TRUTRLDBR ^ transferTrack));
            address = UFSHCIMem.TRUTRLBAU;
            address = (count * size) + (address << 32) + UFSHCIMem.TRUTRLBA;
            transferTrack |= mask << count;
            DPRINTF(UFSHostDevice, "Doorbell register: 0x%8x select #:"
                    " 0x%8x completion info: 0x%8x\n", UFSHCIMem.TRUTRLDBR,
                    count, transferstart_info.done);
            transferstart_info.done = UFSHCIMem.TRUTRLDBR;
            transactionStart[count] = curTick(); 
            ++activeDoorbells;
            stats.maxDoorbell = (stats.maxDoorbell.value() < activeDoorbells)
                ? activeDoorbells : stats.maxDoorbell.value();
            stats.averageDoorbell = stats.maxDoorbell.value();
            transferstart_info.mask = mask << count;
            transferstart_info.address = address;
            transferstart_info.size = size;
            transferstart_info.done = UFSHCIMem.TRUTRLDBR;
            transferStartInfo.push_back(transferstart_info);
            transferStartInfo.back().destination = new struct
                UTPTransferReqDesc;
            DPRINTF(UFSHostDevice, "Initial transfer start: 0x%8x\n",
                    transferstart_info.done);
            transferEventQueue.push_back(
                EventFunctionWrapper([this]{ transferStart(); }, name()));
            if (transferEventQueue.size() < 2) {
                writeDevice(&transferEventQueue.front(), false,
                            address, size, reinterpret_cast<uint8_t*>
                            (transferStartInfo.front().destination),0, 0);
                DPRINTF(UFSHostDevice, "Transfer scheduled\n");
            }
        }
    }
}
void UFSHostDevice :: requestHandler ( ) { Addr address = 0x00 ; int mask = 0x01 ; int size ; int count = 0 ; struct taskStart task_info ; struct transferStart transferstart_info ; transferstart_info . done = 0 ; while ( ( ( UFSHCIMem . CMDUICCMDR > 0x00 ) | ( ( UFSHCIMem . TMUTMRLDBR ^ taskCommandTrack ) > 0x00 ) | ( ( UFSHCIMem . TRUTRLDBR ^ transferTrack ) > 0x00 ) ) ) { if ( UFSHCIMem . CMDUICCMDR > 0x00 ) { commandHandler ( ) ; UFSHCIMem . ORInterruptStatus |= UICCommandCOMPL ; generateInterrupt ( ) ; UFSHCIMem . CMDUICCMDR = 0x00 ; return ; } else if ( ( UFSHCIMem . TMUTMRLDBR ^ taskCommandTrack ) > 0x00 ) { size = sizeof ( UTPUPIUTaskReq ) ; count = findLsbSet ( ( UFSHCIMem . TMUTMRLDBR ^ taskCommandTrack ) ) ; address = UFSHCIMem . TMUTMRLBAU ; address = ( count * size ) + ( address << 32 ) + UFSHCIMem . TMUTMRLBA ; taskCommandTrack |= mask << count ; inform ( " " " \n " ) ; task_info . mask = mask << count ; task_info . address = address ; task_info . size = size ; task_info . done = UFSHCIMem . TMUTMRLDBR ; taskInfo . push_back ( task_info ) ; taskEventQueue . push_back ( EventFunctionWrapper ( [ this ] { taskStart ( ) ; } , name ( ) ) ) ; writeDevice ( & taskEventQueue . back ( ) , false , address , size , reinterpret_cast < uint8_t * > ( & taskInfo . back ( ) . destination ) , 0 , 0 ) ; } else if ( ( UFSHCIMem . TRUTRLDBR ^ transferTrack ) > 0x00 ) { size = sizeof ( UTPTransferReqDesc ) ; count = findLsbSet ( ( UFSHCIMem . TRUTRLDBR ^ transferTrack ) ) ; address = UFSHCIMem . TRUTRLBAU ; address = ( count * size ) + ( address << 32 ) + UFSHCIMem . TRUTRLBA ; transferTrack |= mask << count ; DPRINTF ( UFSHostDevice , " " " \n " , UFSHCIMem . TRUTRLDBR , count , transferstart_info . done ) ; transferstart_info . done = UFSHCIMem . TRUTRLDBR ; transactionStart [ count ] = curTick ( ) ; ++ activeDoorbells ; stats . maxDoorbell = ( stats . maxDoorbell . value ( ) < activeDoorbells ) ? activeDoorbells : stats . maxDoorbell . value ( ) ; stats . averageDoorbell = stats . maxDoorbell . value ( ) ; transferstart_info . mask = mask << count ; transferstart_info . address = address ; transferstart_info . size = size ; transferstart_info . done = UFSHCIMem . TRUTRLDBR ; transferStartInfo . push_back ( transferstart_info ) ; transferStartInfo . back ( ) . destination = new struct UTPTransferReqDesc ; DPRINTF ( UFSHostDevice , " \n " , transferstart_info . done ) ; transferEventQueue . push_back ( EventFunctionWrapper ( [ this ] { transferStart ( ) ; } , name ( ) ) ) ; if ( transferEventQueue . size ( ) < 2 ) { writeDevice ( & transferEventQueue . front ( ) , false , address , size , reinterpret_cast < uint8_t * > ( transferStartInfo . front ( ) . destination ) , 0 , 0 ) ; DPRINTF ( UFSHostDevice , " \n " ) ; } } } }
Request handler.
Request handler .
/**
     * step1 determine what called us
     * step2 determine where to get it
     * Look for any request of which we where not yet aware
     */ /**
             * Command; general control of the Host controller.
             * no DMA transfer needed
             */ //command, nothing more we can do /**
             * Task; flow control, meant for the device/Logic unit
             * DMA transfer is needed, flash will not be approached
             */ /**Find the position that is not handled yet*/ //<-64 bit /**
             * Transfer; Data transfer from or to the disk. There will be DMA
             * transfers, and the flash might be approached. Further
             * commands, are needed to specify the exact command.
             */ /**Find the position that is not handled yet*/ //<-64 bit /**stats**/ //note the start time /**
             * step3 start transfer
             * step4 register information; allowing the host to respond in
             * the end
             */ /**Deleted in readDone, queued in finalUTP*/