gem5  v20.1.0.0
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 ClockedObject SimObject Clocked EventManager Serializable Drainable Stats::Group

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, uint32_t sid, uint32_t ssid, Tick delay=0)
 
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, uint32_t sid, uint32_t ssid, 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
 
PortgetPort (const std::string &if_name, PortID idx=InvalidPortID) override
 Get a port with a given name and index. More...
 
- Public Member Functions inherited from PioDevice
 PioDevice (const Params *p)
 
virtual ~PioDevice ()
 
const Paramsparams () const
 
void init () override
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
PortgetPort (const std::string &if_name, PortID idx=InvalidPortID) override
 Get a port with a given name and index. More...
 
- 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...
 
- 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 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
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)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. More...
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue. More...
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- 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 Stats::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (Stats::Info *info)
 Register a stat with this group. More...
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object. More...
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object. More...
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block. More...
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from Clocked
void updateClockPeriod ()
 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 writeToDiskBurstdmaWriteInfo
 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< EventFunctionWrapperreadDoneEvent
 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< EventFunctionWrapperwriteDoneEvent
 
EventFunctionWrapper SCSIResumeEvent
 The events that control the functionality. More...
 
EventFunctionWrapper UTPEvent
 Wait for the moment where we can send the last frame. More...
 
std::deque< EventFunctionWrapperreadGarbageEventQueue
 Event after a read to clean up the UTP data structures. More...
 
std::deque< EventFunctionWrappertaskEventQueue
 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< EventFunctionWrappertransferEventQueue
 

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 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 ()
 Gets the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 Serializes all the SimObjects. More...
 
static void unserializeGlobals (CheckpointIn &cp)
 
- Public Attributes inherited from ClockedObject
PowerStatepowerState
 
- 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...
 
virtual void clockPeriodUpdated ()
 A hook subclasses can implement so they can do any extra work that's needed when the clock rate is changed. More...
 
- Protected Attributes inherited from DmaDevice
DmaPort dmaPort
 
- Protected Attributes inherited from PioDevice
Systemsys
 
PioPort< PioDevicepioPort
 The pioPort that handles the requests for us and provides us requests that it sees. More...
 
- 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 169 of file ufs_device.hh.

Member Enumeration Documentation

◆ UFSHCIRegisters

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 1183 of file ufs_device.hh.

Constructor & Destructor Documentation

◆ UFSHostDevice()

UFSHostDevice::UFSHostDevice ( const UFSHostDeviceParams *  p)

Constructor for the UFS Host device.

Definition at line 715 of file ufs_device.cc.

References SCSIStart().

Member Function Documentation

◆ checkDrain()

void UFSHostDevice::checkDrain ( )

Checkdrain; needed to enable checkpoints.

Definition at line 2340 of file ufs_device.cc.

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

Referenced by clearInterrupt(), and generateInterrupt().

◆ clearInterrupt()

void UFSHostDevice::clearInterrupt ( )
private

Interrupt control functions.

Clear interrupt.

end of a transaction

Definition at line 1834 of file ufs_device.cc.

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

Referenced by read().

◆ commandHandler()

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 1376 of file ufs_device.cc.

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

Referenced by requestHandler().

◆ drain()

DrainState UFSHostDevice::drain ( )
overridevirtual

Drain; needed to enable checkpoints.

Implements Drainable.

Definition at line 2324 of file ufs_device.cc.

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

◆ finalUTP()

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 1737 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().

◆ generateInterrupt()

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 1811 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().

◆ getAddrRanges()

AddrRangeList UFSHostDevice::getAddrRanges ( ) const
overrideprivatevirtual

Address range functions.

Determine address ranges.

Implements PioDevice.

Definition at line 908 of file ufs_device.cc.

References pioAddr, pioSize, and RangeSize().

◆ LUNSignal()

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 1666 of file ufs_device.cc.

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

◆ manageReadTransfer()

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 2113 of file ufs_device.cc.

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

Referenced by SCSIResume().

◆ manageWriteTransfer()

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 1924 of file ufs_device.cc.

References X86ISA::count, dmaWriteInfo, DPRINTF, UFSHostDevice::writeToDiskBurst::LUN, ArmISA::offset, UFSHostDevice::writeToDiskBurst::SCSIDiskOffset, 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().

◆ read()

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 921 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::setLE(), 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.

◆ readCallback()

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 2240 of file ufs_device.cc.

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

◆ readDevice()

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 2078 of file ufs_device.cc.

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

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

◆ readDone()

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 1783 of file ufs_device.cc.

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

Referenced by readDevice().

◆ readGarbage()

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 2278 of file ufs_device.cc.

References DPRINTF, readGarbageEventQueue, and SSDReadPending.

Referenced by readCallback().

◆ regStats()

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 Stats::Group.

Definition at line 767 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, Stats::Group::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.

◆ requestHandler()

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 1223 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, UFSHostDevice::transferStart::mask, UFSHostDevice::taskStart::mask, ArmISA::mask, UFSHostDevice::UFSHostDeviceStats::maxDoorbell, SimObject::name(), UFSHostDevice::HCIMem::ORInterruptStatus, UFSHostDevice::transferStart::size, UFSHostDevice::taskStart::size, stats, taskCommandTrack, taskEventQueue, taskInfo, taskStart(), UFSHostDevice::HCIMem::TMUTMRLBA, UFSHostDevice::HCIMem::TMUTMRLBAU, UFSHostDevice::HCIMem::TMUTMRLDBR, transactionStart, transferEventQueue, transferStart(), transferStartInfo, transferTrack, UFSHostDevice::HCIMem::TRUTRLBA, UFSHostDevice::HCIMem::TRUTRLBAU, UFSHostDevice::HCIMem::TRUTRLDBR, UFSHCIMem, UICCommandCOMPL, Stats::ScalarBase< Derived, Stor >::value(), and writeDevice().

Referenced by write().

◆ SCSIResume()

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 1514 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, UFSHostDevice::UFSHCDSGEntry::size, UFSHostDevice::SCSIReply::status, transferDone(), UFSHostDevice::HCIMem::TRUTRLDBR, UFSDevice, UFSHCIMem, and UFSHostDevice::UFSHCDSGEntry::upperAddr.

Referenced by finalUTP(), and SCSIStart().

◆ 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 1469 of file ufs_device.cc.

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

Referenced by UFSHostDevice().

◆ serialize()

void UFSHostDevice::serialize ( CheckpointOut cp) const
overridevirtual

Serialize; needed to make checkpoints.

Implements Serializable.

Definition at line 2290 of file ufs_device.cc.

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

◆ setValues()

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 881 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.

◆ taskHandler()

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 1390 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().

◆ 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 1342 of file ufs_device.cc.

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

Referenced by requestHandler().

◆ transferDone()

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 1698 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(), UFSHostDevice::transferStart::size, transferEnd, UFSHostDevice::HCIMem::TRUTRLDBR, UFSDevice, UFSHCIMem, and UTPEvent.

Referenced by LUNSignal(), and SCSIResume().

◆ transferHandler()

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 1426 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().

◆ 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 1356 of file ufs_device.cc.

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

Referenced by requestHandler().

◆ unserialize()

void UFSHostDevice::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize; needed to restore from checkpoints.

Implements Serializable.

Definition at line 2307 of file ufs_device.cc.

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

◆ write()

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 1059 of file ufs_device.cc.

References UFSHostDevice::HCIMem::CMDUCMDARG1, UFSHostDevice::HCIMem::CMDUCMDARG2, UFSHostDevice::HCIMem::CMDUCMDARG3, UFSHostDevice::HCIMem::CMDUICCMDR, curTick(), data, Packet::getAddr(), Packet::getLE(), Packet::getSize(), idlePhaseStart, UFSHostDevice::UFSHostDeviceStats::idleTimes, 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.

◆ writeDevice()

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 1872 of file ufs_device.cc.

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

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

◆ 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 1983 of file ufs_device.cc.

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

Referenced by writeDevice().

Member Data Documentation

◆ activeDoorbells

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 1029 of file ufs_device.hh.

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

◆ countInt

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 1039 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

◆ dmaWriteInfo

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

Information to get a DMA transaction.

Definition at line 1106 of file ufs_device.hh.

Referenced by manageWriteTransfer(), and writeDone().

◆ garbage

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

garbage queue, ensure clearing of the allocated memory

Definition at line 1121 of file ufs_device.hh.

Referenced by finalUTP(), and readDone().

◆ gic

BaseGic* UFSHostDevice::gic
private

Definition at line 1005 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

◆ idlePhaseStart

Tick UFSHostDevice::idlePhaseStart
private

Definition at line 1058 of file ufs_device.hh.

Referenced by clearInterrupt(), and write().

◆ intNum

const int UFSHostDevice::intNum
private

Definition at line 1004 of file ufs_device.hh.

Referenced by clearInterrupt(), and generateInterrupt().

◆ lunAvail

const uint32_t UFSHostDevice::lunAvail
private

◆ pendingDoorbells

uint8_t UFSHostDevice::pendingDoorbells
private

Definition at line 1030 of file ufs_device.hh.

Referenced by finalUTP(), and generateInterrupt().

◆ pioAddr

const Addr UFSHostDevice::pioAddr
private

Host controller information.

Definition at line 1001 of file ufs_device.hh.

Referenced by getAddrRanges().

◆ pioDelay

const Tick UFSHostDevice::pioDelay
private

Definition at line 1003 of file ufs_device.hh.

Referenced by read(), and write().

◆ pioSize

const Addr UFSHostDevice::pioSize
private

Definition at line 1002 of file ufs_device.hh.

Referenced by getAddrRanges().

◆ readDoneEvent

std::deque<EventFunctionWrapper> 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 1137 of file ufs_device.hh.

Referenced by readDevice(), and readDone().

◆ readGarbageEventQueue

std::deque<EventFunctionWrapper> UFSHostDevice::readGarbageEventQueue
private

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

Definition at line 1160 of file ufs_device.hh.

Referenced by readCallback(), and readGarbage().

◆ readPendingNum

int UFSHostDevice::readPendingNum
private

Track number of DMA transactions in progress.

Definition at line 1017 of file ufs_device.hh.

Referenced by readDevice(), and readDone().

◆ request_out_datain

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 1072 of file ufs_device.hh.

Referenced by SCSIResume().

◆ SCSIInfo

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 1080 of file ufs_device.hh.

Referenced by SCSIStart(), and transferHandler().

◆ SCSIResumeEvent

EventFunctionWrapper 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 1150 of file ufs_device.hh.

Referenced by transferHandler().

◆ SSDReadPending

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

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

Definition at line 1116 of file ufs_device.hh.

Referenced by readCallback(), and readGarbage().

◆ SSDWriteinfo

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

Information from DMA transaction to disk.

Definition at line 1111 of file ufs_device.hh.

Referenced by writeDevice(), and writeDone().

◆ stats

struct UFSHostDeviceStats UFSHostDevice::stats
private

RequestHandler stats.

Definition at line 1126 of file ufs_device.hh.

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

◆ taskCommandTrack

uint32_t UFSHostDevice::taskCommandTrack
private

Definition at line 1050 of file ufs_device.hh.

Referenced by requestHandler(), and taskHandler().

◆ taskEventQueue

std::deque<EventFunctionWrapper> 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 1167 of file ufs_device.hh.

Referenced by requestHandler(), and taskStart().

◆ taskInfo

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 1100 of file ufs_device.hh.

Referenced by requestHandler(), and taskStart().

◆ transactionStart

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 1057 of file ufs_device.hh.

Referenced by finalUTP(), and requestHandler().

◆ transferEnd

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 1089 of file ufs_device.hh.

Referenced by finalUTP(), and transferDone().

◆ transferEventQueue

std::deque<EventFunctionWrapper> UFSHostDevice::transferEventQueue
private

Definition at line 1168 of file ufs_device.hh.

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

◆ transferStartInfo

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

Definition at line 1101 of file ufs_device.hh.

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

◆ transferTrack

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 1049 of file ufs_device.hh.

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

◆ UFSDevice

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 1065 of file ufs_device.hh.

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

◆ UFSHCIMem

HCIMem UFSHostDevice::UFSHCIMem
private

◆ UFSSlots

const uint8_t UFSHostDevice::UFSSlots
private

Definition at line 1007 of file ufs_device.hh.

Referenced by setValues().

◆ UICCommandCOMPL

const unsigned int UFSHostDevice::UICCommandCOMPL = 0x400
staticprivate

Definition at line 1175 of file ufs_device.hh.

Referenced by requestHandler().

◆ UICCommandReady

const unsigned int UFSHostDevice::UICCommandReady = 0x08
staticprivate

Definition at line 1176 of file ufs_device.hh.

Referenced by write().

◆ UTPEvent

EventFunctionWrapper UFSHostDevice::UTPEvent
private

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

Definition at line 1155 of file ufs_device.hh.

Referenced by transferDone().

◆ UTPTaskREQCOMPL

const unsigned int UFSHostDevice::UTPTaskREQCOMPL = 0x200
staticprivate

Definition at line 1174 of file ufs_device.hh.

Referenced by taskHandler().

◆ UTPTransferREQCOMPL

const unsigned int UFSHostDevice::UTPTransferREQCOMPL = 0x01
staticprivate

Bits of interest within UFS data packages.

Definition at line 1173 of file ufs_device.hh.

Referenced by readDone().

◆ writeDoneEvent

std::deque<EventFunctionWrapper> UFSHostDevice::writeDoneEvent
private

Definition at line 1138 of file ufs_device.hh.

Referenced by writeDevice().

◆ writePendingNum

int UFSHostDevice::writePendingNum
private

Definition at line 1018 of file ufs_device.hh.

Referenced by writeDevice(), and writeDone().


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

Generated on Wed Sep 30 2020 14:02:33 for gem5 by doxygen 1.8.17