gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
UFSHostDevice Class Reference

UFS command flow state machine digraph CommandFlow{ node [fontsize=10]; IDLE -> transferHandler [ label=" transfer/task/command request " fontsize=6]; transferHandler -> command [ label=" It is a command " fontsize=6]; command -> IDLE [ label=" Command done, no further action " fontsize=6]; transferHandler -> taskStart [ label=" It is a task " fontsize=6]; taskStart -> finalUTP [ label=" Task handled, now acknowledge (UFS) " fontsize=6]; transferHandler -> transferStart [ label=" It is a transfer " fontsize=6]; transferStart -> SCSIResume [ label=" Transfer, obtain the specific command " fontsize=6]; SCSIResume -> DiskDataFlowPhase [ label=" Disk data transfer (see other graphs) " fontsize=6]; SCSIResume -> DeviceDataPhase [ label=" Device info transfer (handled in SCSIResume) " fontsize=6]; DiskDataFlowPhase -> transferDone [ label=" Transfer done, acknowledge SCSI command " fontsize=6]; DeviceDataPhase -> transferDone [ label=" Transfer done, acknowledge SCSI command " fontsize=6]; transferDone -> finalUTP [ label=" Transfer handled, now acknowledge (UFS) " fontsize=6]; finalUTP -> readDone [ label=" All handled, clear data structures " fontsize=6]; readDone -> IDLE [ label=" All handled, nothing outstanding " fontsize=6]; readDone -> transferHandler [ label=" All handled, handle next outstanding " fontsize=6]; }. More...

#include <ufs_device.hh>

Inheritance diagram for UFSHostDevice:
DmaDevice PioDevice MemObject ClockedObject SimObject Clocked EventManager Serializable Drainable

Classes

struct  HCIMem
 Host Controller Interface This is a set of registers that allow the driver to control the transactions to the flash devices. More...
 
struct  LUNInfo
 Logic unit information structure. More...
 
struct  SCSIReply
 SCSI reply structure. More...
 
struct  SCSIResumeInfo
 After a SCSI command has been identified, the SCSI resume function will handle it. More...
 
struct  taskStart
 Task start information. More...
 
struct  transferDoneInfo
 transfer completion info. More...
 
struct  transferInfo
 Different events, and scenarios require different types of information. More...
 
struct  transferStart
 Transfer start information. More...
 
struct  UFSHCDSGEntry
 struct UFSHCDSGEntry - UFSHCI PRD Entry baseAddr: Lower 32bit physical address DW-0 upperAddr: Upper 32bit physical address DW-1 reserved: Reserved for future use DW-2 size: size of physical segment DW-3 More...
 
struct  UFSHostDeviceStats
 Statistics. More...
 
class  UFSSCSIDevice
 device layer: This is your Logic unit This layer implements the SCSI functionality of the UFS Device One logic unit controls one or more disk partitions More...
 
struct  UPIUMessage
 UPIU tranfer message. More...
 
struct  UTPTransferCMDDesc
 struct UTPTransferCMDDesc - UFS Commad Descriptor structure commandUPIU: Command UPIU Frame address responseUPIU: Response UPIU Frame address PRDTable: Physcial Region Descriptor All lengths as defined by JEDEC220 More...
 
struct  UTPTransferReqDesc
 struct UTPTransferReqDesc - UTRD structure header: UTRD header DW-0 to DW-3 commandDescBaseAddrLo: UCD base address low DW-4 commandDescBaseAddrHi: UCD base address high DW-5 responseUPIULength: response UPIU length DW-6 responseUPIUOffset: response UPIU offset DW-6 PRDTableLength: Physical region descriptor length DW-7 PRDTableOffset: Physical region descriptor offset DW-7 More...
 
struct  UTPUPIUHeader
 All the data structures are defined in the UFS standard This standard be found at the JEDEC website free of charge (login required): http://www.jedec.org/standards-documents/results/jesd220. More...
 
struct  UTPUPIURSP
 struct UTPUPIURSP - Response UPIU structure header: UPIU header DW-0 to DW-2 residualTransferCount: Residual transfer count DW-3 reserved: Reserved DW-4 to DW-7 senseDataLen: Sense data length DW-8 U16 senseData: Sense data field DW-8 to DW-12 More...
 
struct  UTPUPIUTaskReq
 struct UTPUPIUTaskReq - Task request UPIU structure header - UPIU header structure DW0 to DW-2 inputParam1: Input param 1 DW-3 inputParam2: Input param 2 DW-4 inputParam3: Input param 3 DW-5 reserved: Reserver DW-6 to DW-7 More...
 
struct  writeToDiskBurst
 Disk transfer burst information. More...
 

Public Member Functions

 UFSHostDevice (const UFSHostDeviceParams *p)
 Constructor for the UFS Host device. More...
 
DrainState drain () override
 Drain; needed to enable checkpoints. More...
 
void checkDrain ()
 Checkdrain; needed to enable checkpoints. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize; needed to make checkpoints. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize; needed to restore from checkpoints. More...
 
- Public Member Functions inherited from DmaDevice
 DmaDevice (const Params *p)
 
virtual ~DmaDevice ()
 
void dmaWrite (Addr addr, int size, Event *event, uint8_t *data, Tick delay=0)
 
void dmaRead (Addr addr, int size, Event *event, uint8_t *data, Tick delay=0)
 
bool dmaPending () const
 
void init () override
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
unsigned int cacheBlockSize () const
 
BaseMasterPortgetMasterPort (const std::string &if_name, PortID idx=InvalidPortID) override
 Get a master port with a given name and index. More...
 
- Public Member Functions inherited from PioDevice
 PioDevice (const Params *p)
 
virtual ~PioDevice ()
 
const Paramsparams () const
 
virtual BaseSlavePortgetSlavePort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a slave port with a given name and index. More...
 
- Public Member Functions inherited from MemObject
const Paramsparams () const
 
 MemObject (const Params *params)
 
- Public Member Functions inherited from ClockedObject
 ClockedObject (const ClockedObjectParams *p)
 
const Paramsparams () const
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
Enums::PwrState pwrState () const
 
std::string pwrStateName () const
 
std::vector< double > pwrStateWeights () const
 Returns the percentage residency for each power state. More...
 
void computeStats ()
 Record stats values like state residency by computing the time difference from previous update. More...
 
void pwrState (Enums::PwrState)
 
void regStats () override
 Register statistics for this object. More...
 
- Public Member Functions inherited from SimObject
const Paramsparams () const
 
 SimObject (const Params *_params)
 
virtual ~SimObject ()
 
virtual const std::string name () const
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void resetStats ()
 Reset statistics associated with this object. More...
 
virtual void regProbePoints ()
 Register probe points for this object. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes. More...
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from EventManager
 EventManager (EventManager &em)
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick)-1)
 
void setCurTick (Tick newVal)
 
- Public Member Functions inherited from Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 
- Public Member Functions inherited from Clocked
void updateClockPeriod () const
 Update the tick to the current tick. More...
 
Tick clockEdge (Cycles cycles=Cycles(0)) const
 Determine the tick when a cycle begins, by default the current one, but the argument also enables the caller to determine a future cycle. More...
 
Cycles curCycle () const
 Determine the current cycle, corresponding to a tick aligned to a clock edge. More...
 
Tick nextCycle () const
 Based on the clock of the object, determine the start tick of the first cycle that is at least one cycle in the future. More...
 
uint64_t frequency () const
 
Tick clockPeriod () const
 
double voltage () const
 
Cycles ticksToCycles (Tick t) const
 
Tick cyclesToTicks (Cycles c) const
 

Private Types

enum  UFSHCIRegisters {
  regControllerCapabilities = 0x00, regUFSVersion = 0x08, regControllerDEVID = 0x10, regControllerPRODID = 0x14,
  regInterruptStatus = 0x20, regInterruptEnable = 0x24, regControllerStatus = 0x30, regControllerEnable = 0x34,
  regUICErrorCodePHYAdapterLayer = 0x38, regUICErrorCodeDataLinkLayer = 0x3C, regUICErrorCodeNetworkLayer = 0x40, regUICErrorCodeTransportLayer = 0x44,
  regUICErrorCodeDME = 0x48, regUTPTransferREQINTAGGControl = 0x4C, regUTPTransferREQListBaseL = 0x50, regUTPTransferREQListBaseH = 0x54,
  regUTPTransferREQDoorbell = 0x58, regUTPTransferREQListClear = 0x5C, regUTPTransferREQListRunStop = 0x60, regUTPTaskREQListBaseL = 0x70,
  regUTPTaskREQListBaseH = 0x74, regUTPTaskREQDoorbell = 0x78, regUTPTaskREQListClear = 0x7C, regUTPTaskREQListRunStop = 0x80,
  regUICCommand = 0x90, regUICCommandArg1 = 0x94, regUICCommandArg2 = 0x98, regUICCommandArg3 = 0x9C
}
 

Private Member Functions

AddrRangeList getAddrRanges () const override
 Address range functions. More...
 
Tick read (PacketPtr pkt) override
 register access functions More...
 
Tick write (PacketPtr pkt) override
 UFSHCD write function. More...
 
void setValues ()
 Initialization function. More...
 
void requestHandler ()
 Handler functions. More...
 
void commandHandler ()
 Command handler function. More...
 
void taskStart ()
 Task Start function. More...
 
void taskHandler (struct UTPUPIUTaskReq *request_in, uint32_t req_pos, Addr finaladdress, uint32_t finalsize)
 Task handler function. More...
 
void transferStart ()
 Transfer Start function. More...
 
void transferHandler (struct UTPTransferReqDesc *request_in, int req_pos, Addr finaladdress, uint32_t finalsize, uint32_t done)
 Transfer handler function. More...
 
void SCSIStart ()
 Transfer SCSI function. More...
 
void SCSIResume (uint32_t lun_id)
 Starts the scsi handling function in the apropriate Logic unit, prepares the right data transfer scheme and kicks it off. More...
 
void LUNSignal ()
 LU callback function to indicate that the action has completed. More...
 
void transferDone (Addr responseStartAddr, uint32_t req_pos, struct UTPUPIURSP request_out, uint32_t size, Addr address, uint8_t *destination, bool finished, uint32_t lun_id)
 transfer done, the beginning of the final stage of the transfer. More...
 
void finalUTP ()
 final UTP, sends the last acknowledge data structure to the system; prepares the clean up functions. More...
 
void clearInterrupt ()
 Interrupt control functions. More...
 
void generateInterrupt ()
 set interrupt and sort out the doorbell register. More...
 
void writeDevice (Event *additional_action, bool toDisk, Addr start, int size, uint8_t *destination, uint64_t SCSIDiskOffset, uint32_t lun_id)
 DMA transfer functions These allow the host to push/pull the data to the memory The provided event indicates what the next phase it that will handle the obtained data, or what the follow up action is once the data has been pushed to the memory. More...
 
void readDevice (bool lastTransfer, Addr SCSIStart, uint32_t SCSISize, uint8_t *SCSIDestination, bool no_cache, Event *additional_action)
 Dma transaction function: read device. More...
 
void manageWriteTransfer (uint8_t LUN, uint64_t offset, uint32_t sg_table_length, struct UFSHCDSGEntry *sglist)
 Disk transfer management functions these set up the queues, and initiated them, leading to the data transaction timing model based on the scatter gather list constructed in SCSIresume. More...
 
void manageReadTransfer (uint32_t size, uint32_t LUN, uint64_t offset, uint32_t sg_table_length, struct UFSHCDSGEntry *sglist)
 Manage read transfer. More...
 
void readDone ()
 Read done Started at the end of a transaction after the last read action. More...
 
void writeDone ()
 Write done After a DMA write with data intended for the disk, this function is called. More...
 
void readCallback ()
 Read callback Call back function for the logic units to indicate the completion of a read action. More...
 
void readGarbage ()
 Read garbage A read from disk data structure can vary in size and is therefor allocated on creation. More...
 
void regStats () override
 register statistics More...
 

Private Attributes

const Addr pioAddr
 Host controller information. More...
 
const Addr pioSize
 
const Tick pioDelay
 
const int intNum
 
BaseGicgic
 
const uint32_t lunAvail
 
const uint8_t UFSSlots
 
HCIMem UFSHCIMem
 Host controller memory. More...
 
int readPendingNum
 Track number of DMA transactions in progress. More...
 
int writePendingNum
 
uint8_t activeDoorbells
 Statistics helper variables Active doorbells indicates how many doorbells are in teh process of being handled. More...
 
uint8_t pendingDoorbells
 
uint32_t countInt
 interrupt verification This keeps track of the number of interrupts generated. More...
 
uint32_t transferTrack
 Track the transfer This is allows the driver to "group" certain transfers together by using a tag in the UPIU. More...
 
uint32_t taskCommandTrack
 
Tick transactionStart [32]
 Helper for latency stats These variables keep track of the latency for every doorbell. More...
 
Tick idlePhaseStart
 
std::vector< UFSSCSIDevice * > UFSDevice
 logic units connected to the UFS Host device Note again that the "device" as such is represented by one or multiple logic units. More...
 
struct SCSIReply request_out_datain
 SCSI reply structure, used for direct answering. More...
 
struct SCSIResumeInfo SCSIInfo
 SCSI resume info information structure for SCSI resume. More...
 
std::deque< struct transferStarttransferEnd
 To finish the transaction one needs information about the original message. More...
 
std::deque< struct taskStarttaskInfo
 When a task/transfer is started it needs information about the task/transfer it is about to perform. More...
 
std::deque< struct transferStarttransferStartInfo
 
std::deque< struct
writeToDiskBurst
dmaWriteInfo
 Information to get a DMA transaction. More...
 
std::deque< struct transferInfoSSDWriteinfo
 Information from DMA transaction to disk. More...
 
std::deque< struct transferInfoSSDReadPending
 Information from the Disk, waiting to be pushed to the DMA. More...
 
std::deque< struct
UTPTransferReqDesc * > 
garbage
 garbage queue, ensure clearing of the allocated memory More...
 
struct UFSHostDeviceStats stats
 RequestHandler stats. More...
 
std::deque< EventWrapper
< UFSHostDevice,&UFSHostDevice::readDone > > 
readDoneEvent
 Transfer flow events Basically these events form two queues, one from memory to UFS device (DMA) and one from device to flash (SSD). More...
 
std::deque< EventWrapper
< UFSHostDevice,&UFSHostDevice::writeDone > > 
writeDoneEvent
 
CallbacktransferDoneCallback
 Callbacks for the logic units. More...
 
CallbackmemReadCallback
 
EventWrapper< UFSHostDevice,&UFSHostDevice::SCSIStartSCSIResumeEvent
 The events that control the functionality. More...
 
EventWrapper< UFSHostDevice,&UFSHostDevice::finalUTPUTPEvent
 Wait for the moment where we can send the last frame. More...
 
std::deque< EventWrapper
< UFSHostDevice,&UFSHostDevice::readGarbage > > 
readGarbageEventQueue
 Event after a read to clean up the UTP data structures. More...
 
std::deque< EventWrapper
< UFSHostDevice,&UFSHostDevice::taskStart > > 
taskEventQueue
 Multiple tasks transfers can be scheduled at once for the device, the only thing we know for sure about them is that they will happen in a first come first serve order; hence we need to queue. More...
 
std::deque< EventWrapper
< UFSHostDevice,&UFSHostDevice::transferStart > > 
transferEventQueue
 

Static Private Attributes

static const unsigned int UTPTransferREQCOMPL = 0x01
 Bits of interest within UFS data packages. More...
 
static const unsigned int UTPTaskREQCOMPL = 0x200
 
static const unsigned int UICCommandCOMPL = 0x400
 
static const unsigned int UICCommandReady = 0x08
 

Additional Inherited Members

- Public Types inherited from DmaDevice
typedef DmaDeviceParams Params
 
- Public Types inherited from PioDevice
typedef PioDeviceParams Params
 
- Public Types inherited from MemObject
typedef MemObjectParams Params
 
- Public Types inherited from ClockedObject
typedef ClockedObjectParams Params
 Parameters of ClockedObject. More...
 
- Public Types inherited from SimObject
typedef SimObjectParams Params
 
- Static Public Member Functions inherited from SimObject
static void serializeAll (CheckpointOut &cp)
 Serialize all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
- Static Public Member Functions inherited from Serializable
static const std::string & currentSection ()
 Get the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 
static void unserializeGlobals (CheckpointIn &cp)
 
- Static Public Attributes inherited from Serializable
static int ckptCount = 0
 
static int ckptMaxCount = 0
 
static int ckptPrevCount = -1
 
- Protected Member Functions inherited from Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 
- Protected Member Functions inherited from Clocked
 Clocked (ClockDomain &clk_domain)
 Create a clocked object and set the clock domain based on the parameters. More...
 
 Clocked (Clocked &)=delete
 
Clockedoperator= (Clocked &)=delete
 
virtual ~Clocked ()
 Virtual destructor due to inheritance. More...
 
void resetClock () const
 Reset the object's clock using the current global tick value. More...
 
- Protected Attributes inherited from DmaDevice
DmaPort dmaPort
 
- Protected Attributes inherited from PioDevice
Systemsys
 
PioPort pioPort
 The pioPort that handles the requests for us and provides us requests that it sees. More...
 
- Protected Attributes inherited from ClockedObject
Enums::PwrState _currPwrState
 To keep track of the current power state. More...
 
Tick prvEvalTick
 
Stats::Scalar numPwrStateTransitions
 
Stats::Distribution pwrStateClkGateDist
 
Stats::Vector pwrStateResidencyTicks
 
- Protected Attributes inherited from SimObject
const SimObjectParams * _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Detailed Description

UFS command flow state machine digraph CommandFlow{ node [fontsize=10]; IDLE -> transferHandler [ label=" transfer/task/command request " fontsize=6]; transferHandler -> command [ label=" It is a command " fontsize=6]; command -> IDLE [ label=" Command done, no further action " fontsize=6]; transferHandler -> taskStart [ label=" It is a task " fontsize=6]; taskStart -> finalUTP [ label=" Task handled, now acknowledge (UFS) " fontsize=6]; transferHandler -> transferStart [ label=" It is a transfer " fontsize=6]; transferStart -> SCSIResume [ label=" Transfer, obtain the specific command " fontsize=6]; SCSIResume -> DiskDataFlowPhase [ label=" Disk data transfer (see other graphs) " fontsize=6]; SCSIResume -> DeviceDataPhase [ label=" Device info transfer (handled in SCSIResume) " fontsize=6]; DiskDataFlowPhase -> transferDone [ label=" Transfer done, acknowledge SCSI command " fontsize=6]; DeviceDataPhase -> transferDone [ label=" Transfer done, acknowledge SCSI command " fontsize=6]; transferDone -> finalUTP [ label=" Transfer handled, now acknowledge (UFS) " fontsize=6]; finalUTP -> readDone [ label=" All handled, clear data structures " fontsize=6]; readDone -> IDLE [ label=" All handled, nothing outstanding " fontsize=6]; readDone -> transferHandler [ label=" All handled, handle next outstanding " fontsize=6]; }.

UFS read transaction flow state machine digraph readFlow{ node [fontsize=10]; getScatterGather -> commitReadFromDisk [ label=" Put the information about the data transfer to the disk " fontsize=6]; commitReadFromDisk -> waitForReads [ label=" Push the reads to the flashmodel and wait for callbacks " fontsize=6]; waitForReads -> pushToDMA [ label=" Push to the DMA and wait for them to finish " fontsize=6]; pushToDMA -> waitForReads [ label=" Wait for the next disk event " fontsize=6]; pushToDMA -> waitForDMA [ label=" Wait for the last DMA transfer to finish " fontsize=6]; waitForDMA -> finishTransfer [ label=" Continue with the command flow " fontsize=6]; } UFS write transaction flow state machine digraph WriteFlow{ node [fontsize=10]; getScatterGather -> getFromDMA [ label=" Put the transfer information to the DMA " fontsize=6]; getFromDMA -> waitForDMA [ label=" Wait for dma actions to arrive " fontsize=6]; waitForDMA -> pushToDisk [ label=" Push arrived DMA to disk " fontsize=6]; pushToDisk -> waitForDMA [ label=" Wait for next DMA action " fontsize=6]; pushToDisk -> waitForDisk [ label=" All DMA actions are done, wait for disk " fontsize=6]; waitForDisk -> finishTransfer [ label=" All transactions are done , continue the command flow " fontsize=6]; } Host controller layer: This is your Host controller This layer handles the UFS functionality. It tracks all the different transaction stages and uses the device layer and the flash layer to determine the transaction flow.

Definition at line 170 of file ufs_device.hh.

Member Enumeration Documentation

Enumerator
regControllerCapabilities 
regUFSVersion 
regControllerDEVID 
regControllerPRODID 
regInterruptStatus 
regInterruptEnable 
regControllerStatus 
regControllerEnable 
regUICErrorCodePHYAdapterLayer 
regUICErrorCodeDataLinkLayer 
regUICErrorCodeNetworkLayer 
regUICErrorCodeTransportLayer 
regUICErrorCodeDME 
regUTPTransferREQINTAGGControl 
regUTPTransferREQListBaseL 
regUTPTransferREQListBaseH 
regUTPTransferREQDoorbell 
regUTPTransferREQListClear 
regUTPTransferREQListRunStop 
regUTPTaskREQListBaseL 
regUTPTaskREQListBaseH 
regUTPTaskREQDoorbell 
regUTPTaskREQListClear 
regUTPTaskREQListRunStop 
regUICCommand 
regUICCommandArg1 
regUICCommandArg2 
regUICCommandArg3 

Definition at line 1191 of file ufs_device.hh.

Constructor & Destructor Documentation

UFSHostDevice::UFSHostDevice ( const UFSHostDeviceParams *  p)

Constructor for the UFS Host device.

Definition at line 719 of file ufs_device.cc.

References X86ISA::count, DPRINTF, fatal, lunAvail, LUNSignal(), memReadCallback, readCallback(), setValues(), transferDoneCallback, UFSDevice, UFSSlots, and warn.

Member Function Documentation

void UFSHostDevice::checkDrain ( )

Checkdrain; needed to enable checkpoints.

Definition at line 2341 of file ufs_device.cc.

References activeDoorbells, DPRINTF, Draining, Drainable::drainState(), Drainable::signalDrainDone(), UFSHostDevice::HCIMem::TRUTRLDBR, and UFSHCIMem.

Referenced by clearInterrupt(), and generateInterrupt().

void UFSHostDevice::clearInterrupt ( )
private

Interrupt control functions.

Clear interrupt.

end of a transaction

Definition at line 1840 of file ufs_device.cc.

References checkDrain(), BaseGic::clearInt(), countInt, curTick(), DPRINTF, gic, idlePhaseStart, intNum, UFSHostDevice::HCIMem::TRUTRLDBR, and UFSHCIMem.

Referenced by read().

void UFSHostDevice::commandHandler ( )
private

Command handler function.

Handles the commands that are given.

Handles the command send to the Host controller

At this point in time, not many commands have been implemented in the driver.

Definition at line 1382 of file ufs_device.cc.

References UFSHostDevice::HCIMem::CMDUICCMDR, UFSHostDevice::HCIMem::ORHostControllerStatus, and UFSHCIMem.

Referenced by requestHandler().

DrainState UFSHostDevice::drain ( )
overridevirtual

Drain; needed to enable checkpoints.

Implements Drainable.

Definition at line 2325 of file ufs_device.cc.

References DPRINTF, Drained, Draining, UFSHostDevice::HCIMem::TRUTRLDBR, and UFSHCIMem.

void UFSHostDevice::finalUTP ( )
private

final UTP, sends the last acknowledge data structure to the system; prepares the clean up functions.

finalUTP.

Second part of the transfer done event. this sends the final response: the UTP response. After this transaction the doorbell shall be cleared, and the interupt shall be set.

stats

Last message that will be transfered

clean and ensure that the tracker is updated

stats

This is the moment that the device is available again

Definition at line 1743 of file ufs_device.cc.

References activeDoorbells, UFSHostDevice::UFSHostDeviceStats::averageDoorbell, X86ISA::count, curTick(), DPRINTF, garbage, UFSHostDevice::UFSHostDeviceStats::maxDoorbell, pendingDoorbells, readDevice(), Stats::DistBase< Derived, Stor >::sample(), SCSIResume(), stats, UFSHostDevice::UFSHostDeviceStats::transactionLatency, transactionStart, transferEnd, transferEventQueue, transferTrack, UFSHostDevice::HCIMem::TRUTRLDBR, UFSDevice, UFSHCIMem, and Stats::ScalarBase< Derived, Stor >::value().

void UFSHostDevice::generateInterrupt ( )
private

set interrupt and sort out the doorbell register.

just to keep track of the transactions

step5 clear doorbell

step6 raise interrupt

Definition at line 1817 of file ufs_device.cc.

References checkDrain(), countInt, DPRINTF, gic, intNum, pendingDoorbells, BaseGic::sendInt(), transferTrack, UFSHostDevice::HCIMem::TRUTRLDBR, and UFSHCIMem.

Referenced by readDone(), and requestHandler().

AddrRangeList UFSHostDevice::getAddrRanges ( ) const
overrideprivatevirtual

Address range functions.

Determine address ranges.

Implements PioDevice.

Definition at line 916 of file ufs_device.cc.

References pioAddr, pioSize, and RangeSize().

void UFSHostDevice::LUNSignal ( )
private

LU callback function to indicate that the action has completed.

Find finished transfer.

Callback function. One of the LUNs is done with the disk transfer and reports back to the controller. This function finds out who it was, and calls transferDone.

Definition at line 1672 of file ufs_device.cc.

References curTick(), lunAvail, panic, transferDone(), and UFSDevice.

Referenced by UFSHostDevice().

void UFSHostDevice::manageReadTransfer ( uint32_t  size,
uint32_t  LUN,
uint64_t  offset,
uint32_t  sg_table_length,
struct UFSHCDSGEntry sglist 
)
private

Manage read transfer.

Manages correct transfer flow and makes sure that the queues are filled on time

Break-up the transactions into actions defined by the scatter gather list.

The disk image is read here; but the action is simultated later You can see this as the preparation stage, whereas later is the simulation phase.

stats

stats

Definition at line 2115 of file ufs_device.cc.

References UFSHostDevice::UFSHostDeviceStats::averageReadSSDQueue, X86ISA::count, UFSHostDevice::UFSHostDeviceStats::currentReadSSDQueue, DPRINTF, UFSHostDevice::transferInfo::filePointer, UFSHostDevice::transferInfo::lunID, UFSHostDevice::transferInfo::offset, UFSHostDevice::UFSHCDSGEntry::size, UFSHostDevice::transferInfo::size, stats, UFSHostDevice::UFSHostDeviceStats::totalReadSSD, UFSHostDevice::UFSHostDeviceStats::totalReadUFSTransactions, UFSDevice, and UFSHostDevice::UFSHCDSGEntry::upperAddr.

Referenced by SCSIResume().

void UFSHostDevice::manageWriteTransfer ( uint8_t  LUN,
uint64_t  offset,
uint32_t  sg_table_length,
struct UFSHCDSGEntry sglist 
)
private

Disk transfer management functions these set up the queues, and initiated them, leading to the data transaction timing model based on the scatter gather list constructed in SCSIresume.

Manage write transfer.

Manages correct transfer flow and makes sure that the queues are filled on time

Break-up the transactions into actions defined by the scatter gather list.

If the queue is empty, the transaction should be initiated

stats

stats

Definition at line 1928 of file ufs_device.cc.

References X86ISA::count, dmaWriteInfo, DPRINTF, UFSHostDevice::writeToDiskBurst::LUN, ArmISA::offset, UFSHostDevice::writeToDiskBurst::SCSIDiskOffset, X86ISA::size(), UFSHostDevice::UFSHCDSGEntry::size, UFSHostDevice::writeToDiskBurst::size, UFSHostDevice::writeToDiskBurst::start, stats, UFSHostDevice::UFSHostDeviceStats::totalWriteUFSTransactions, UFSHostDevice::UFSHostDeviceStats::totalWrittenSSD, UFSDevice, UFSHostDevice::UFSHCDSGEntry::upperAddr, and writeDevice().

Referenced by SCSIResume().

Tick UFSHostDevice::read ( PacketPtr  pkt)
overrideprivatevirtual

register access functions

UFSHCD read register.

This function allows the system to read the register entries

Implements PioDevice.

Definition at line 929 of file ufs_device.cc.

References clearInterrupt(), UFSHostDevice::HCIMem::CMDUCMDARG1, UFSHostDevice::HCIMem::CMDUCMDARG2, UFSHostDevice::HCIMem::CMDUCMDARG3, UFSHostDevice::HCIMem::CMDUICCMDR, data, Packet::getAddr(), UFSHostDevice::HCIMem::HCCAP, UFSHostDevice::HCIMem::HCHCDDID, UFSHostDevice::HCIMem::HCHCPMID, UFSHostDevice::HCIMem::HCversion, Packet::makeResponse(), UFSHostDevice::HCIMem::ORHostControllerEnable, UFSHostDevice::HCIMem::ORHostControllerStatus, UFSHostDevice::HCIMem::ORInterruptEnable, UFSHostDevice::HCIMem::ORInterruptStatus, UFSHostDevice::HCIMem::ORUECDL, UFSHostDevice::HCIMem::ORUECDME, UFSHostDevice::HCIMem::ORUECN, UFSHostDevice::HCIMem::ORUECPA, UFSHostDevice::HCIMem::ORUECT, UFSHostDevice::HCIMem::ORUTRIACR, pioDelay, regControllerCapabilities, regControllerDEVID, regControllerEnable, regControllerPRODID, regControllerStatus, regInterruptEnable, regInterruptStatus, regUFSVersion, regUICCommand, regUICCommandArg1, regUICCommandArg2, regUICCommandArg3, regUICErrorCodeDataLinkLayer, regUICErrorCodeDME, regUICErrorCodeNetworkLayer, regUICErrorCodePHYAdapterLayer, regUICErrorCodeTransportLayer, regUTPTaskREQDoorbell, regUTPTaskREQListBaseH, regUTPTaskREQListBaseL, regUTPTaskREQListClear, regUTPTaskREQListRunStop, regUTPTransferREQDoorbell, regUTPTransferREQINTAGGControl, regUTPTransferREQListBaseH, regUTPTransferREQListBaseL, regUTPTransferREQListClear, regUTPTransferREQListRunStop, Packet::set(), UFSHostDevice::HCIMem::TMUTMRLBA, UFSHostDevice::HCIMem::TMUTMRLBAU, UFSHostDevice::HCIMem::TMUTMRLCLR, UFSHostDevice::HCIMem::TMUTMRLDBR, UFSHostDevice::HCIMem::TMUTMRLRSR, UFSHostDevice::HCIMem::TRUTRLBA, UFSHostDevice::HCIMem::TRUTRLBAU, UFSHostDevice::HCIMem::TRUTRLCLR, UFSHostDevice::HCIMem::TRUTRLDBR, UFSHostDevice::HCIMem::TRUTRLRSR, and UFSHCIMem.

void UFSHostDevice::readCallback ( )
private

Read callback Call back function for the logic units to indicate the completion of a read action.

Read callback, on the way from the disk to the DMA.

Note that this is needed because the read functionality needs to push data structures back to the memory.

Called by the UFSSCSI layer.

stats

Definition at line 2242 of file ufs_device.cc.

References curTick(), DPRINTF, lunAvail, panic, readDevice(), readGarbageEventQueue, SSDReadPending, stats, UFSHostDevice::UFSHostDeviceStats::totalReadDiskTransactions, and UFSDevice.

Referenced by UFSHostDevice().

void UFSHostDevice::readDevice ( bool  lastTransfer,
Addr  start,
uint32_t  size,
uint8_t *  destination,
bool  no_cache,
Event additional_action 
)
private

Dma transaction function: read device.

Notice that the dma action is from a device perspective, while this function is from an initiator perspective

check wether interrupt is needed

Definition at line 2082 of file ufs_device.cc.

References X86ISA::destination, DmaPort::dmaAction(), DmaDevice::dmaPort, DPRINTF, readDoneEvent, readPendingNum, Event::scheduled(), and MemCmd::WriteReq.

Referenced by finalUTP(), readCallback(), SCSIResume(), taskHandler(), and transferDone().

void UFSHostDevice::readDone ( )
private

Read done Started at the end of a transaction after the last read action.

Read done handling function, is only initiated at the end of a transaction.

Cleans up UTP descriptor and other remaining data structures. It also raises the interrupt.

Garbage collection; sort out the allocated UTP descriptor

done, generate interrupt if we havent got one already

Definition at line 1789 of file ufs_device.cc.

References DPRINTF, garbage, generateInterrupt(), UFSHostDevice::HCIMem::ORInterruptStatus, readDoneEvent, readPendingNum, UFSHCIMem, and UTPTransferREQCOMPL.

void UFSHostDevice::readGarbage ( )
private

Read garbage A read from disk data structure can vary in size and is therefor allocated on creation.

After a disk read DMA transfer, the structure needs to be freed.

It can only be destroyed once that particular read action has completed. This function is called on completion of a read from disk action to handle this.

This is done in this function.

Definition at line 2279 of file ufs_device.cc.

References DPRINTF, readGarbageEventQueue, and SSDReadPending.

void UFSHostDevice::regStats ( )
overrideprivatevirtual

register statistics

Queue lengths

Amount of data read/written

Average bandwidth for reads and writes

Number of doorbells rung

Latency

Reimplemented from SimObject.

Definition at line 775 of file ufs_device.cc.

References activeDoorbells, UFSHostDevice::UFSHostDeviceStats::averageDoorbell, UFSHostDevice::UFSHostDeviceStats::averageReadSSDBW, UFSHostDevice::UFSHostDeviceStats::averageReadSSDQueue, UFSHostDevice::UFSHostDeviceStats::averageSCSIQueue, UFSHostDevice::UFSHostDeviceStats::averageWriteSSDBW, UFSHostDevice::UFSHostDeviceStats::averageWriteSSDQueue, UFSHostDevice::UFSHostDeviceStats::curDoorbell, UFSHostDevice::UFSHostDeviceStats::currentReadSSDQueue, UFSHostDevice::UFSHostDeviceStats::currentSCSIQueue, UFSHostDevice::UFSHostDeviceStats::currentWriteSSDQueue, Stats::DataWrap< Derived, InfoProxyType >::desc(), Stats::DataWrap< Derived, InfoProxyType >::flags(), UFSHostDevice::UFSHostDeviceStats::idleTimes, Stats::Histogram::init(), UFSHostDevice::UFSHostDeviceStats::maxDoorbell, SimObject::name(), Stats::DataWrap< Derived, InfoProxyType >::name(), Stats::none, Stats::nozero, Stats::pdf, ClockedObject::regStats(), simSeconds, stats, UFSHostDevice::UFSHostDeviceStats::totalReadDiskTransactions, UFSHostDevice::UFSHostDeviceStats::totalReadSSD, UFSHostDevice::UFSHostDeviceStats::totalReadUFSTransactions, UFSHostDevice::UFSHostDeviceStats::totalWriteDiskTransactions, UFSHostDevice::UFSHostDeviceStats::totalWriteUFSTransactions, UFSHostDevice::UFSHostDeviceStats::totalWrittenSSD, and UFSHostDevice::UFSHostDeviceStats::transactionLatency.

void UFSHostDevice::requestHandler ( )
private

Handler functions.

Request handler.

Each function handles a different stage of the transfer. Note that the UFS protocol specifies three types of messages to the host (and devices): 1: Command (to Host specifically) 2: Task (to device; to control flow, not for data) 3: Transfer (to device; to transfer data) request handler. This function finds the cause of the request and triggers the right follow-up action (command handler, task handler, or transferhandler)

Determines where the request comes from and initiates the appropriate actions accordingly.

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

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

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

stats

step3 start transfer step4 register information; allowing the host to respond in the end

Deleted in readDone, queued in finalUTP

Definition at line 1231 of file ufs_device.cc.

References activeDoorbells, UFSHostDevice::transferStart::address, UFSHostDevice::taskStart::address, UFSHostDevice::UFSHostDeviceStats::averageDoorbell, UFSHostDevice::HCIMem::CMDUICCMDR, commandHandler(), X86ISA::count, curTick(), UFSHostDevice::transferStart::done, UFSHostDevice::taskStart::done, DPRINTF, findLsbSet(), generateInterrupt(), inform, ArmISA::mask, UFSHostDevice::transferStart::mask, UFSHostDevice::taskStart::mask, UFSHostDevice::UFSHostDeviceStats::maxDoorbell, UFSHostDevice::HCIMem::ORInterruptStatus, X86ISA::size(), UFSHostDevice::transferStart::size, UFSHostDevice::taskStart::size, stats, taskCommandTrack, taskEventQueue, taskInfo, UFSHostDevice::HCIMem::TMUTMRLBA, UFSHostDevice::HCIMem::TMUTMRLBAU, UFSHostDevice::HCIMem::TMUTMRLDBR, transactionStart, transferEventQueue, transferStartInfo, transferTrack, UFSHostDevice::HCIMem::TRUTRLBA, UFSHostDevice::HCIMem::TRUTRLBAU, UFSHostDevice::HCIMem::TRUTRLDBR, UFSHCIMem, UICCommandCOMPL, Stats::ScalarBase< Derived, Stor >::value(), and writeDevice().

Referenced by write().

void UFSHostDevice::SCSIResume ( uint32_t  lun_id)
private

Starts the scsi handling function in the apropriate Logic unit, prepares the right data transfer scheme and kicks it off.

Handles the transfer requests that are given.

There can be three types of transfer. SCSI specific, Reads and writes apart from the data transfer, this also generates its own reply (UPIU response). Information for this reply is stored in transferInfo and will be used in transferDone

old info, lets form it such that we can understand it

call logic unit to handle SCSI command

build response stating that it was succesful command completion, Logic unit number, and Task tag

SCSI status reply

segment size + EHS length (see UFS standard ch7)

amount of data that will follow

transferdone information packet filling

In this part the data that needs to be transfered will be initiated and the chain of DMA (and potentially) disk transactions will be started.

write transfer

read transfer

not disk related transfer, SCSI maintanance

Transport the SCSI reponse data according to the SG list

safetynet; it has been shown that sg list may be optimistic in the amount of data allocated, which can potentially lead to some garbage data being send over. Hence this construction that finds the least amount of data that needs to be transfered.

Go to the next stage of the answering process

Definition at line 1520 of file ufs_device.cc.

References UFSHostDevice::UTPTransferReqDesc::commandDescBaseAddrHi, UFSHostDevice::UTPTransferReqDesc::commandDescBaseAddrLo, X86ISA::count, UFSHostDevice::UPIUMessage::dataMsg, DPRINTF, UFSHostDevice::UTPTransferReqDesc::RequestDescHeader::dWord0, UFSHostDevice::SCSIReply::expectMore, UFSHostDevice::UTPTransferReqDesc::header, length, UFSHostDevice::SCSIReply::LUN, manageReadTransfer(), manageWriteTransfer(), UFSHostDevice::SCSIReply::message, UFSHostDevice::SCSIReply::msgSize, UFSHostDevice::SCSIReply::offset, panic, UFSHostDevice::UTPTransferReqDesc::PRDTableLength, UFSHostDevice::UTPTransferReqDesc::PRDTableOffset, readDevice(), request_out_datain, UFSHostDevice::UTPTransferReqDesc::responseUPIULength, UFSHostDevice::SCSIReply::senseCode, UFSHostDevice::SCSIReply::senseSize, X86ISA::size(), UFSHostDevice::UFSHCDSGEntry::size, UFSHostDevice::SCSIReply::status, transferDone(), UFSHostDevice::HCIMem::TRUTRLDBR, UFSDevice, UFSHCIMem, and UFSHostDevice::UFSHCDSGEntry::upperAddr.

Referenced by finalUTP(), and SCSIStart().

void UFSHostDevice::SCSIStart ( )
private

Transfer SCSI function.

Obtain LUN and put it in the right LUN queue.

Determines which Logic unit to address and starts the SCSI resume function

Each LUN has its own queue of commands that need to be executed. This is the first instance where it can be determined which Logic unit should handle the transfer. Then check wether it should wait and queue or if it can continue.

There are 32 doorbells, so at max there can be 32 transactions

First transfer is done, fetch the next; At this point, the device is busy, not the HC

loading next data packet in case Another LUN is approached in the mean time

Definition at line 1475 of file ufs_device.cc.

References UFSHostDevice::SCSIResumeInfo::destination, DPRINTF, panic, SCSIInfo, SCSIResume(), transferEventQueue, transferStartInfo, UFSDevice, and writeDevice().

void UFSHostDevice::serialize ( CheckpointOut cp) const
overridevirtual

Serialize; needed to make checkpoints.

Implements Serializable.

Definition at line 2291 of file ufs_device.cc.

References lunAvail, ClockedObject::serialize(), SERIALIZE_ARRAY, SERIALIZE_SCALAR, and UFSHCIMem.

void UFSHostDevice::setValues ( )
private

Initialization function.

Register init.

Sets the sefault HCI register values

The capability register is built up as follows: 31-29 RES; Testmode support; O3 delivery; 64 bit addr; 23-19 RES; 18-16 #TM Req slots; 15-5 RES;4-0 # TR slots

Definition at line 889 of file ufs_device.cc.

References UFSHostDevice::HCIMem::CMDUICCMDR, UFSHostDevice::HCIMem::HCCAP, UFSHostDevice::HCIMem::HCHCDDID, UFSHostDevice::HCIMem::HCHCPMID, UFSHostDevice::HCIMem::HCversion, UFSHostDevice::HCIMem::ORHostControllerStatus, UFSHostDevice::HCIMem::TMUTMRLBA, UFSHostDevice::HCIMem::TMUTMRLBAU, UFSHostDevice::HCIMem::TMUTMRLDBR, UFSHostDevice::HCIMem::TRUTRLBA, UFSHostDevice::HCIMem::TRUTRLBAU, UFSHostDevice::HCIMem::TRUTRLDBR, UFSHCIMem, and UFSSlots.

Referenced by UFSHostDevice().

void UFSHostDevice::taskHandler ( struct UTPUPIUTaskReq request_in,
uint32_t  req_pos,
Addr  finaladdress,
uint32_t  finalsize 
)
private

Task handler function.

Handles the tasks that are given.

Handles the tasks send to the devices because there are not many tasks implemented yet this is kept in the Host controller layer

At this point in time, not many tasks have been implemented in the driver.

For now, just unpack and acknowledge the task without doing anything. TODO Implement UFS tasks.

Definition at line 1396 of file ufs_device.cc.

References UFSHostDevice::UTPUPIUHeader::dWord0, UFSHostDevice::UTPUPIUHeader::dWord1, UFSHostDevice::UTPUPIUHeader::dWord2, UFSHostDevice::UTPUPIUTaskReq::header, inform, UFSHostDevice::HCIMem::ORInterruptStatus, readDevice(), taskCommandTrack, UFSHostDevice::HCIMem::TMUTMRLDBR, UFSHCIMem, and UTPTaskREQCOMPL.

Referenced by taskStart().

void UFSHostDevice::taskStart ( )
private

Task Start function.

Task start event.

Starts the task handler once the task data structure has arrived

Definition at line 1348 of file ufs_device.cc.

References DPRINTF, taskEventQueue, taskHandler(), and taskInfo.

void UFSHostDevice::transferDone ( Addr  responseStartAddr,
uint32_t  req_pos,
struct UTPUPIURSP  request_out,
uint32_t  size,
Addr  address,
uint8_t *  destination,
bool  finished,
uint32_t  lun_id 
)
private

transfer done, the beginning of the final stage of the transfer.

Transfer done.

Acknowledges UPIU frame and prepares the UTP response frame

When the data transfer is done, this function ensures that the application is notified.

Test whether SCSI queue hasn't popped prematurely

Definition at line 1704 of file ufs_device.cc.

References UFSHostDevice::transferStart::address, X86ISA::destination, UFSHostDevice::transferStart::destination, UFSHostDevice::transferStart::done, DPRINTF, UFSHostDevice::transferStart::lun_id, UFSHostDevice::transferStart::mask, panic, readDevice(), X86ISA::size(), UFSHostDevice::transferStart::size, transferEnd, UFSHostDevice::HCIMem::TRUTRLDBR, UFSDevice, UFSHCIMem, and UTPEvent.

Referenced by LUNSignal(), and SCSIResume().

void UFSHostDevice::transferHandler ( struct UTPTransferReqDesc request_in,
int  req_pos,
Addr  finaladdress,
uint32_t  finalsize,
uint32_t  done 
)
private

Transfer handler function.

Obtains the SCSI command (if any) Two possibilities: if it contains a SCSI command, then it is a usable message; if it doesnt contain a SCSI message, then it can't be handeld by this code.

Handles the transfers send to the devices Important to understand here is that a Logic unit is not a device (a device can contain multiple logic units). This function analyses the first data structure that has been transfered. Which will tell the host to expect SCSI frames for the rest of the transaction. Note that the host has no indication whatsoever which LU to address. That will follow in the next transaction.

This is the second stage of the transfer. We have the information about where the next command can be found and what the type of command is. The actions that are needed from the device its side are: get the information and store the information such that we can reply.

Get the UTP command that has the SCSI command

Definition at line 1432 of file ufs_device.cc.

References UFSHostDevice::UTPTransferReqDesc::commandDescBaseAddrHi, UFSHostDevice::UTPTransferReqDesc::commandDescBaseAddrLo, UFSHostDevice::SCSIResumeInfo::destination, UFSHostDevice::SCSIResumeInfo::done, DPRINTF, UFSHostDevice::UTPTransferReqDesc::RequestDescHeader::dWord2, UFSHostDevice::SCSIResumeInfo::finalAddress, UFSHostDevice::SCSIResumeInfo::finalSize, UFSHostDevice::UTPTransferReqDesc::header, UFSHostDevice::UTPTransferReqDesc::PRDTableLength, UFSHostDevice::UTPTransferReqDesc::PRDTableOffset, UFSHostDevice::SCSIResumeInfo::reqPos, UFSHostDevice::SCSIResumeInfo::RequestIn, Event::scheduled(), SCSIInfo, SCSIResumeEvent, transferEventQueue, and writeDevice().

Referenced by transferStart().

void UFSHostDevice::transferStart ( )
private

Transfer Start function.

Transfer start event.

Starts the transfer handler once the transfer data structure has arrived

Definition at line 1362 of file ufs_device.cc.

References DPRINTF, transferEventQueue, transferHandler(), and transferStartInfo.

void UFSHostDevice::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize; needed to restore from checkpoints.

Implements Serializable.

Definition at line 2308 of file ufs_device.cc.

References lunAvail, UFSHCIMem, ClockedObject::unserialize(), UNSERIALIZE_ARRAY, and UNSERIALIZE_SCALAR.

Tick UFSHostDevice::write ( PacketPtr  pkt)
overrideprivatevirtual

UFSHCD write function.

This function allows access to the writeable registers. If any function attempts to write value to an unwriteable register entry, then the value will not be written.

Implements PioDevice.

Definition at line 1067 of file ufs_device.cc.

References UFSHostDevice::HCIMem::CMDUCMDARG1, UFSHostDevice::HCIMem::CMDUCMDARG2, UFSHostDevice::HCIMem::CMDUCMDARG3, UFSHostDevice::HCIMem::CMDUICCMDR, curTick(), data, Packet::get(), Packet::getAddr(), Packet::getSize(), idlePhaseStart, UFSHostDevice::UFSHostDeviceStats::idleTimes, if(), Packet::makeResponse(), UFSHostDevice::HCIMem::ORHostControllerEnable, UFSHostDevice::HCIMem::ORHostControllerStatus, UFSHostDevice::HCIMem::ORInterruptEnable, UFSHostDevice::HCIMem::ORUECDL, UFSHostDevice::HCIMem::ORUECDME, UFSHostDevice::HCIMem::ORUECN, UFSHostDevice::HCIMem::ORUECPA, UFSHostDevice::HCIMem::ORUECT, UFSHostDevice::HCIMem::ORUTRIACR, panic, pioDelay, regControllerCapabilities, regControllerDEVID, regControllerEnable, regControllerPRODID, regControllerStatus, regInterruptEnable, regInterruptStatus, regUFSVersion, regUICCommand, regUICCommandArg1, regUICCommandArg2, regUICCommandArg3, regUICErrorCodeDataLinkLayer, regUICErrorCodeDME, regUICErrorCodeNetworkLayer, regUICErrorCodePHYAdapterLayer, regUICErrorCodeTransportLayer, regUTPTaskREQDoorbell, regUTPTaskREQListBaseH, regUTPTaskREQListBaseL, regUTPTaskREQListClear, regUTPTaskREQListRunStop, regUTPTransferREQDoorbell, regUTPTransferREQINTAGGControl, regUTPTransferREQListBaseH, regUTPTransferREQListBaseL, regUTPTransferREQListClear, regUTPTransferREQListRunStop, requestHandler(), Stats::DistBase< Derived, Stor >::sample(), stats, UFSHostDevice::HCIMem::TMUTMRLBA, UFSHostDevice::HCIMem::TMUTMRLBAU, UFSHostDevice::HCIMem::TMUTMRLCLR, UFSHostDevice::HCIMem::TMUTMRLDBR, UFSHostDevice::HCIMem::TMUTMRLRSR, UFSHostDevice::HCIMem::TRUTRLBA, UFSHostDevice::HCIMem::TRUTRLBAU, UFSHostDevice::HCIMem::TRUTRLCLR, UFSHostDevice::HCIMem::TRUTRLDBR, UFSHostDevice::HCIMem::TRUTRLRSR, UFSHCIMem, and UICCommandReady.

void UFSHostDevice::writeDevice ( Event additional_action,
bool  toDisk,
Addr  start,
int  size,
uint8_t *  destination,
uint64_t  SCSIDiskOffset,
uint32_t  lun_id 
)
private

DMA transfer functions These allow the host to push/pull the data to the memory The provided event indicates what the next phase it that will handle the obtained data, or what the follow up action is once the data has been pushed to the memory.

Important to understand about the transfer flow: We have basically three stages, The "system memory" stage, the "device buffer" stage and the "disk" stage.

In this model we assume an infinite buffer, or a buffer that is big enough to store all the data in the biggest transaction. Between the three stages are two queues. Those queues store the messages to simulate their transaction from one stage to the next. The manage{Action} function fills up one of the queues and triggers the first event, which causes a chain reaction of events executed once they pass through their queues. For a write action the stages are ordered "system memory", "device buffer" and "disk", whereas the read transfers happen "disk", "device buffer" and "system memory". The dma action in the dma device is written from a bus perspective whereas this model is written from a device perspective. To avoid confusion, the translation between the two has been made in the writeDevice and readDevice funtions. Dma transaction function: write device. Note that the dma action is from a device perspective, while this function is from an initiator perspective

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

Definition at line 1878 of file ufs_device.cc.

References curTick(), DmaPort::dmaAction(), DmaDevice::dmaPort, DPRINTF, UFSHostDevice::transferInfo::filePointer, UFSHostDevice::transferInfo::lunID, UFSHostDevice::transferInfo::offset, MemCmd::ReadReq, Event::scheduled(), X86ISA::size(), UFSHostDevice::transferInfo::size, SSDWriteinfo, writeDoneEvent, and writePendingNum.

Referenced by manageWriteTransfer(), requestHandler(), SCSIStart(), transferHandler(), and writeDone().

void UFSHostDevice::writeDone ( )
private

Write done After a DMA write with data intended for the disk, this function is called.

Write done handling function.

It ensures that the disk image is modified, and that the correct timing function is triggered.

Is only initiated when the flash is directly approached

DMA is done, information no longer needed

If there is nothing on the way, we need to start the events

Write the disk

Move to the second queue, enter the logic unit This is where the disk is approached and the flash transaction is handled SSDWriteDone will take care of the timing

so far, only the DMA part has been handled, lets do the disk delay

stats

initiate the next dma action (if any)

Definition at line 1987 of file ufs_device.cc.

References UFSHostDevice::UFSHostDeviceStats::averageWriteSSDQueue, UFSHostDevice::UFSHostDeviceStats::currentWriteSSDQueue, dmaWriteInfo, DPRINTF, SSDWriteinfo, stats, UFSHostDevice::UFSHostDeviceStats::totalWriteDiskTransactions, UFSDevice, writeDevice(), and writePendingNum.

Member Data Documentation

uint8_t UFSHostDevice::activeDoorbells
private

Statistics helper variables Active doorbells indicates how many doorbells are in teh process of being handled.

Pending doorbells have been handled and are waiting to be acknowledged by the host system. The doorbell register is 32 bits wide, so one byte is enough to keep track of the numbers

Definition at line 1024 of file ufs_device.hh.

Referenced by checkDrain(), finalUTP(), regStats(), and requestHandler().

uint32_t UFSHostDevice::countInt
private

interrupt verification This keeps track of the number of interrupts generated.

It is usefull for debug purposes. Make sure that the implemented driver prints the number of interrupts it has handled so far to fully benefit from this feature.

Definition at line 1034 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

std::deque<struct writeToDiskBurst> UFSHostDevice::dmaWriteInfo
private

Information to get a DMA transaction.

Definition at line 1101 of file ufs_device.hh.

Referenced by manageWriteTransfer(), and writeDone().

std::deque<struct UTPTransferReqDesc*> UFSHostDevice::garbage
private

garbage queue, ensure clearing of the allocated memory

Definition at line 1116 of file ufs_device.hh.

Referenced by finalUTP(), and readDone().

BaseGic* UFSHostDevice::gic
private

Definition at line 1000 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

Tick UFSHostDevice::idlePhaseStart
private

Definition at line 1053 of file ufs_device.hh.

Referenced by clearInterrupt(), and write().

const int UFSHostDevice::intNum
private

Definition at line 999 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

const uint32_t UFSHostDevice::lunAvail
private
Callback* UFSHostDevice::memReadCallback
private

Definition at line 1143 of file ufs_device.hh.

Referenced by UFSHostDevice::UFSSCSIDevice::SSDReadStart(), and UFSHostDevice().

uint8_t UFSHostDevice::pendingDoorbells
private

Definition at line 1025 of file ufs_device.hh.

Referenced by finalUTP(), and generateInterrupt().

const Addr UFSHostDevice::pioAddr
private

Host controller information.

Definition at line 996 of file ufs_device.hh.

Referenced by getAddrRanges().

const Tick UFSHostDevice::pioDelay
private

Definition at line 998 of file ufs_device.hh.

Referenced by read(), and write().

const Addr UFSHostDevice::pioSize
private

Definition at line 997 of file ufs_device.hh.

Referenced by getAddrRanges().

std::deque<EventWrapper<UFSHostDevice, &UFSHostDevice::readDone> > UFSHostDevice::readDoneEvent
private

Transfer flow events Basically these events form two queues, one from memory to UFS device (DMA) and one from device to flash (SSD).

The SSD "queue" is maintained by the flash and the lun classes and does not form a queue of events as such, but rather a queue of information. This can be done because the flow of the events is completely in the control of these classes. (Whereas in the DMA case we rely on an external class)

Definition at line 1133 of file ufs_device.hh.

Referenced by readDevice(), and readDone().

std::deque<EventWrapper<UFSHostDevice, &UFSHostDevice::readGarbage> > UFSHostDevice::readGarbageEventQueue
private

Event after a read to clean up the UTP data structures.

Definition at line 1166 of file ufs_device.hh.

Referenced by readCallback(), and readGarbage().

int UFSHostDevice::readPendingNum
private

Track number of DMA transactions in progress.

Definition at line 1012 of file ufs_device.hh.

Referenced by readDevice(), and readDone().

struct SCSIReply UFSHostDevice::request_out_datain
private

SCSI reply structure, used for direct answering.

Might be refered to during the assembly of the reply (data, and response; e.g. if something goes wrong along the way, the reply will be different)

Definition at line 1067 of file ufs_device.hh.

Referenced by SCSIResume().

struct SCSIResumeInfo UFSHostDevice::SCSIInfo
private

SCSI resume info information structure for SCSI resume.

it keeps track of all the information that is needed to successfully complete the transaction (response addresses, communicated information so far, etc.).

Definition at line 1075 of file ufs_device.hh.

Referenced by SCSIStart(), and transferHandler().

EventWrapper<UFSHostDevice, &UFSHostDevice::SCSIStart> UFSHostDevice::SCSIResumeEvent
private

The events that control the functionality.

After a doorbell has been set, either a taskevent or a transfer event is scheduled. A transfer event might schedule a SCSI event, all events sequences end with an UTP event, which can be considered as the event which answers the doorbell. Wait for the SCSI specific data to arive

Definition at line 1155 of file ufs_device.hh.

Referenced by transferHandler().

std::deque<struct transferInfo> UFSHostDevice::SSDReadPending
private

Information from the Disk, waiting to be pushed to the DMA.

Definition at line 1111 of file ufs_device.hh.

Referenced by readCallback(), and readGarbage().

std::deque<struct transferInfo> UFSHostDevice::SSDWriteinfo
private

Information from DMA transaction to disk.

Definition at line 1106 of file ufs_device.hh.

Referenced by writeDevice(), and writeDone().

struct UFSHostDeviceStats UFSHostDevice::stats
private

RequestHandler stats.

Definition at line 1121 of file ufs_device.hh.

Referenced by finalUTP(), manageReadTransfer(), manageWriteTransfer(), readCallback(), regStats(), requestHandler(), write(), and writeDone().

uint32_t UFSHostDevice::taskCommandTrack
private

Definition at line 1045 of file ufs_device.hh.

Referenced by requestHandler(), and taskHandler().

std::deque<EventWrapper<UFSHostDevice, &UFSHostDevice::taskStart> > UFSHostDevice::taskEventQueue
private

Multiple tasks transfers can be scheduled at once for the device, the only thing we know for sure about them is that they will happen in a first come first serve order; hence we need to queue.

Definition at line 1174 of file ufs_device.hh.

Referenced by requestHandler(), and taskStart().

std::deque<struct taskStart> UFSHostDevice::taskInfo
private

When a task/transfer is started it needs information about the task/transfer it is about to perform.

This is defined in these structures. If multiple tasks/transfers are issued at the same time, they still need to be fetched one by one. They then need to be executed in the order specified by the UFS standard (least significant doorbell first). The tasks/transfers are placed in the queue in that specific order.

Definition at line 1095 of file ufs_device.hh.

Referenced by requestHandler(), and taskStart().

Tick UFSHostDevice::transactionStart[32]
private

Helper for latency stats These variables keep track of the latency for every doorbell.

Eventually the latenmcies will be put in a histogram.

Definition at line 1052 of file ufs_device.hh.

Referenced by finalUTP(), and requestHandler().

Callback* UFSHostDevice::transferDoneCallback
private

Callbacks for the logic units.

One to indicate the completion of a transaction, the other one to indicate the completion of a read action.

Definition at line 1142 of file ufs_device.hh.

Referenced by UFSHostDevice().

std::deque<struct transferStart> UFSHostDevice::transferEnd
private

To finish the transaction one needs information about the original message.

This is stored in this queue transferEnd uses the same structure as transferStartInfo, because all the information it needs is in there. It improves readability in the cc file.

Definition at line 1084 of file ufs_device.hh.

Referenced by finalUTP(), and transferDone().

std::deque<EventWrapper<UFSHostDevice, &UFSHostDevice::transferStart> > UFSHostDevice::transferEventQueue
private

Definition at line 1176 of file ufs_device.hh.

Referenced by finalUTP(), requestHandler(), SCSIStart(), transferHandler(), and transferStart().

std::deque<struct transferStart> UFSHostDevice::transferStartInfo
private

Definition at line 1096 of file ufs_device.hh.

Referenced by requestHandler(), SCSIStart(), and transferStart().

uint32_t UFSHostDevice::transferTrack
private

Track the transfer This is allows the driver to "group" certain transfers together by using a tag in the UPIU.

The messages with the same tag should be handled together, i.e. their doorbells should be cleared when they are all done. but we need to keep track of the ones we already handled, this integer shadows the doorbells to allow this behaviour.

Definition at line 1044 of file ufs_device.hh.

Referenced by finalUTP(), generateInterrupt(), and requestHandler().

std::vector<UFSSCSIDevice*> UFSHostDevice::UFSDevice
private

logic units connected to the UFS Host device Note again that the "device" as such is represented by one or multiple logic units.

Definition at line 1060 of file ufs_device.hh.

Referenced by finalUTP(), LUNSignal(), manageReadTransfer(), manageWriteTransfer(), readCallback(), SCSIResume(), SCSIStart(), transferDone(), UFSHostDevice(), and writeDone().

HCIMem UFSHostDevice::UFSHCIMem
private
const uint8_t UFSHostDevice::UFSSlots
private

Definition at line 1002 of file ufs_device.hh.

Referenced by setValues(), and UFSHostDevice().

const unsigned int UFSHostDevice::UICCommandCOMPL = 0x400
staticprivate

Definition at line 1183 of file ufs_device.hh.

Referenced by requestHandler().

const unsigned int UFSHostDevice::UICCommandReady = 0x08
staticprivate

Definition at line 1184 of file ufs_device.hh.

Referenced by write().

EventWrapper<UFSHostDevice, &UFSHostDevice::finalUTP> UFSHostDevice::UTPEvent
private

Wait for the moment where we can send the last frame.

Definition at line 1160 of file ufs_device.hh.

Referenced by transferDone().

const unsigned int UFSHostDevice::UTPTaskREQCOMPL = 0x200
staticprivate

Definition at line 1182 of file ufs_device.hh.

Referenced by taskHandler().

const unsigned int UFSHostDevice::UTPTransferREQCOMPL = 0x01
staticprivate

Bits of interest within UFS data packages.

Definition at line 1181 of file ufs_device.hh.

Referenced by readDone().

std::deque<EventWrapper<UFSHostDevice, &UFSHostDevice::writeDone> > UFSHostDevice::writeDoneEvent
private

Definition at line 1135 of file ufs_device.hh.

Referenced by writeDevice().

int UFSHostDevice::writePendingNum
private

Definition at line 1013 of file ufs_device.hh.

Referenced by writeDevice(), and writeDone().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:22 for gem5 by doxygen 1.8.6