gem5
v20.1.0.0
|
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...
Public Types | |
using | Callback = std::function< void()> |
Public Member Functions | |
UFSSCSIDevice (const UFSHostDeviceParams *p, uint32_t lun_id, const Callback &transfer_cb, const Callback &read_cb) | |
Constructor and destructor. More... | |
~UFSSCSIDevice () | |
struct SCSIReply | SCSICMDHandle (uint32_t *SCSI_msg) |
SCSI command handle function; determines what the command is and returns a reply structure that allows the host device to continue with the transfer. More... | |
void | readFlash (uint8_t *readaddr, uint64_t offset, uint32_t size) |
Disk access functions. More... | |
void | writeFlash (uint8_t *writeaddr, uint64_t offset, uint32_t size) |
Write flash. More... | |
bool | finishedCommand () const |
finished command. More... | |
void | clearSignal () |
Clear signal. More... | |
bool | finishedRead () const |
Finished read. More... | |
void | clearReadSignal () |
Clear signal. More... | |
void | SSDReadStart (uint32_t total_read) |
Start the transactions to (and from) the disk The host will queue all the transactions. More... | |
void | SSDWriteStart () |
SSD write start. More... | |
void | setTotalWrite (uint32_t total_write) |
Sets total amount of write transactions that needs to be made. More... | |
Public Attributes | |
transferDoneInfo | transferInfo |
End of transfer information. More... | |
std::deque< struct SCSIResumeInfo > | SCSIInfoQueue |
Information message queues, as there can be multiple messages queued for handling in this system. More... | |
std::deque< struct transferInfo > | SSDReadInfo |
SSDReadInfo: Structure from disk to dma, that contains data, and helper info to get it to the right place in the memory. More... | |
std::deque< struct transferInfo > | SSDWriteDoneInfo |
SSDWriteDoneInfo: Structure from dma to disk, that contains data, and helper info to get it to the right place in the memory. More... | |
Private Member Functions | |
void | readCallback () |
Functions to indicate that the action to the SSD has completed. More... | |
void | SSDReadDone () |
SSD Read done; Determines if the final callback of the transaction should be made at the end of a read transfer. More... | |
void | SSDWriteDone () |
SSD Write Done; This is the callback function for the memory model. More... | |
void | statusCheck (uint8_t status, uint8_t *sensecodelist) |
Status of SCSI. More... | |
void | setSignal () |
set signal to indicate that the transaction has been completed. More... | |
void | setReadSignal () |
set signal to indicate that the read action has been completed More... | |
Private Member Functions inherited from SimObject | |
const Params * | params () const |
SimObject (const Params *_params) | |
virtual | ~SimObject () |
virtual const std::string | name () const |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. More... | |
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... | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. More... | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. 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... | |
Private Member Functions inherited from EventManager | |
EventQueue * | eventQueue () 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) | |
Private 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) |
Private 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... | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. More... | |
void | signalDrainDone () const |
Signal that an object is drained. More... | |
Private Member Functions inherited from Stats::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. More... | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. More... | |
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 Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. More... | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Private Attributes | |
DiskImage * | flashDisk |
The objects this model links to. More... | |
AbstractNVM * | flashDevice |
const uint32_t | blkSize |
Logic unit dimensions. More... | |
const uint32_t | lunAvail |
const uint64_t | diskSize |
const uint32_t | capacityLower |
const uint32_t | capacityUpper |
struct LUNInfo | lunInfo |
Logic unit info; needed for SCSI Info messages and LU identification. More... | |
const uint32_t | lunID |
bool | transferCompleted |
Signals to Host layer 1: signal for transaction completion 2: signal for read action completion. More... | |
bool | readCompleted |
uint32_t | totalRead |
Total amount transactions that need to be made. More... | |
uint32_t | totalWrite |
uint32_t | amountOfWriteTransfers |
transaction progress tracking More... | |
uint32_t | amountOfReadTransfers |
Callback | signalDone |
Callbacks between Host and Device. More... | |
Callback | deviceReadCallback |
Callback | memReadCallback |
Callbacks between Device and Memory. More... | |
Callback | memWriteCallback |
Private Attributes inherited from SimObject | |
const SimObjectParams * | _params |
Cached copy of the object parameters. More... | |
Private Attributes inherited from EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. More... | |
Static Private Attributes | |
static const unsigned int | UPIUHeaderDataIndWord0 = 0x0000C022 |
static const unsigned int | UPIUHeaderDataIndWord1 = 0x00000000 |
static const unsigned int | UPIUHeaderDataIndWord2 = 0x40000000 |
static const unsigned int | controlPage [3] |
These pages are SCSI specific. More... | |
static const unsigned int | recoveryPage [3] |
static const unsigned int | cachingPage [5] |
Additional Inherited Members | |
Static Private Member Functions inherited from SimObject | |
static void | serializeAll (CheckpointOut &cp) |
Serialize all SimObjects in the system. More... | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. More... | |
Static Private 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) |
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
Definition at line 536 of file ufs_device.hh.
using UFSHostDevice::UFSSCSIDevice::Callback = std::function<void()> |
Definition at line 539 of file ufs_device.hh.
|
private |
Definition at line 759 of file ufs_device.hh.
|
private |
Definition at line 810 of file ufs_device.hh.
|
private |
Enumerator | |
---|---|
SCSIGood | |
SCSICheckCondition | |
SCSIConditionGood | |
SCSIBusy | |
SCSIIntermediateGood | |
SCSIIntermediatCGood | |
SCSIReservationConflict | |
SCSICommandTerminated | |
SCSITaskSetFull | |
SCSIACAActive | |
SCSITaskAborted |
Definition at line 792 of file ufs_device.hh.
UFSHostDevice::UFSSCSIDevice::UFSSCSIDevice | ( | const UFSHostDeviceParams * | p, |
uint32_t | lun_id, | ||
const Callback & | transfer_cb, | ||
const Callback & | read_cb | ||
) |
Constructor and destructor.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec.org/standards-documents/results/jesd220 UFS HCI specification http://www.jedec.org/standards-documents/results/jesd223.
Constructor and destructor functions of UFSHCM device
These callbacks are used to communicate the events that are triggered upstream; e.g. from the Memory Device to the UFS SCSI Device or from the UFS SCSI device to the UFS host.
make ascii out of lun_id (and add more characters) UFS allows up to 8 logic units, so the numbering should work out
Definition at line 75 of file ufs_device.cc.
References deviceReadCallback, diskSize, DPRINTF, UFSHostDevice::LUNInfo::dWord0, UFSHostDevice::LUNInfo::dWord1, flashDevice, AbstractNVM::initializeMemory(), lunAvail, lunID, lunInfo, memReadCallback, memWriteCallback, UFSHostDevice::LUNInfo::product0, UFSHostDevice::LUNInfo::product1, UFSHostDevice::LUNInfo::product2, UFSHostDevice::LUNInfo::product3, UFSHostDevice::LUNInfo::productRevision, readCallback(), SectorSize, signalDone, SSDWriteDone(), UFSHostDevice::LUNInfo::vendor0, and UFSHostDevice::LUNInfo::vendor1.
UFSHostDevice::UFSSCSIDevice::~UFSSCSIDevice | ( | ) |
Definition at line 143 of file ufs_device.cc.
|
inline |
Clear signal.
Handle for the host to clear the read complete signal.
Definition at line 597 of file ufs_device.hh.
References readCompleted.
|
inline |
Clear signal.
Handle for the host to clear the transfer complete signal.
Definition at line 582 of file ufs_device.hh.
References transferCompleted.
|
inline |
finished command.
Probe to find out wether this logic unit finished its transfer and triggered the callback; The host needs this to handle the final part of the transaction.
Definition at line 576 of file ufs_device.hh.
References transferCompleted.
|
inline |
Finished read.
Probe to find out which logic unit finished its read. This is needed, because multiple units can do transactions at the same time, and need to push back data at the right time in the right order. (because writes work the other way round, they do not need this mechanism)
Definition at line 591 of file ufs_device.hh.
References readCompleted.
|
private |
Functions to indicate that the action to the SSD has completed.
Read callback, on the way from the disk to the DMA.
Read Call back; This is the callback function for the memory model
Called by the flash layer. Intermediate step to the host layer
Callback; make sure data is transfered upstream: UFSHostDevice::readCallback
Definition at line 2220 of file ufs_device.cc.
Referenced by UFSSCSIDevice().
void UFSHostDevice::UFSSCSIDevice::readFlash | ( | uint8_t * | readaddr, |
uint64_t | offset, | ||
uint32_t | size | ||
) |
Disk access functions.
read from the flashdisk
These will transfer the data from/to the disk Read flash. read the data from the disk image. This function doesn't model timing behaviour
read from image, and get to memory
Definition at line 688 of file ufs_device.cc.
References X86ISA::count, ArmISA::offset, and SectorSize.
struct UFSHostDevice::SCSIReply UFSHostDevice::UFSSCSIDevice::SCSICMDHandle | ( | uint32_t * | SCSI_msg | ) |
SCSI command handle function; determines what the command is and returns a reply structure that allows the host device to continue with the transfer.
UFS specific SCSI handling function.
The following attributes may still be added: SCSI format unit, Send diagnostic and UNMAP; Synchronize Cache and buffer read/write could not be tested yet All parameters can be found in: Universal Flash Storage (UFS) JESD220 FEB 2011 (JEDEC) http://www.jedec.org/standards-documents/results/jesd220 (a JEDEC acount may be required {free of charge})
Create the standard SCSI reponse information These values might changes over the course of a transfer
Determine what the message is and fill the response packet
SCSI inquiry: tell about this specific logic unit
Read command. Number indicates the length of the command.
BE and not nicely aligned. Apart from that it only has information in five bits of the first byte that is relevant for this field.
Renew status check, for the request may have been illegal
BE and not nicely aligned.
Renew status check, for the request may have been illegal
BE and not nicely aligned.
Renew status check, for the request may have been illegal
read the capacity of the device
Find out how many Logic Units this device has.
See if the blocks that the host plans to request are in range of the device.
BE and not nicely aligned.
Renew status check, for the request may have been illegal
Write command.
BE and not nicely aligned. Apart from that it only has information in five bits of the first byte that is relevant for this field.
Renew status check, for the request may have been illegal
BE and not nicely aligned.
Renew status check, for the request may have been illegal
BE and not nicely aligned.
Renew status check, for the request may have been illegal
Get more discriptive information about the SCSI functionality within this logic unit.
BE and not nicely aligned.
less trivial than normal read. Size is in bytes instead of blocks, and it is assumed (though not guaranteed) that reading is from cache.
BE and not nicely aligned.
linux sends this command three times from kernel 3.9 onwards, UFS does not support it, nor does this model. Linux knows this, but tries anyway (useful for some SD card types). Lets make clear we don't want it and just ignore it.
Definition at line 157 of file ufs_device.cc.
References betoh(), X86ISA::count, UFSHostDevice::UPIUMessage::dataCount, UFSHostDevice::UPIUMessage::dataMsg, DPRINTF, UFSHostDevice::UTPUPIUHeader::dWord0, UFSHostDevice::UTPUPIUHeader::dWord1, UFSHostDevice::UTPUPIUHeader::dWord2, UFSHostDevice::SCSIReply::expectMore, UFSHostDevice::UPIUMessage::header, inform, UFSHostDevice::SCSIReply::LUN, UFSHostDevice::lunAvail, UFSHostDevice::SCSIReply::message, UFSHostDevice::SCSIReply::msgSize, UFSHostDevice::SCSIReply::offset, UFSHostDevice::SCSIReply::reset(), UFSHostDevice::SCSIReply::senseCode, UFSHostDevice::SCSIReply::senseSize, and UFSHostDevice::SCSIReply::status.
|
inlineprivate |
set signal to indicate that the read action has been completed
Definition at line 679 of file ufs_device.hh.
References readCompleted.
|
inlineprivate |
set signal to indicate that the transaction has been completed.
Definition at line 674 of file ufs_device.hh.
References transferCompleted.
|
inline |
Sets total amount of write transactions that needs to be made.
First they need to be fetched via DMA, so this value is needed in a later stage.
Definition at line 612 of file ufs_device.hh.
|
private |
SSD Read done; Determines if the final callback of the transaction should be made at the end of a read transfer.
SSDisk read done.
Callback: transferdone
Definition at line 2199 of file ufs_device.cc.
References DPRINTF.
void UFSHostDevice::UFSSCSIDevice::SSDReadStart | ( | uint32_t | total_read | ) |
Start the transactions to (and from) the disk The host will queue all the transactions.
SSDisk start read; this function was created to keep the interfaces between the layers simpler.
Once the next phase commences, this function should be started.
Without this function UFSHost would need to know about the flashdevice.
Load all the read request to the Memory device. It will call back when done.
Definition at line 2178 of file ufs_device.cc.
|
private |
SSD Write Done; This is the callback function for the memory model.
SSDisk write done.
test whether call was correct
are we there yet? (did we do everything)
Definition at line 2048 of file ufs_device.cc.
References DPRINTF.
Referenced by UFSSCSIDevice().
void UFSHostDevice::UFSSCSIDevice::SSDWriteStart | ( | ) |
SSD write start.
Starts the write action in the timing model
Definition at line 2029 of file ufs_device.cc.
References DPRINTF.
|
private |
Status of SCSI.
SCSI status check function.
This may be linked to a status check in the future. For now it (mainly) fills a data structure with sense information for a successfull transaction
generic device test, creates sense codes Future versions may include TODO: device checks, which is why this is in a separate function.
Definition at line 671 of file ufs_device.cc.
References X86ISA::count, and ArmISA::status.
void UFSHostDevice::UFSSCSIDevice::writeFlash | ( | uint8_t * | writeaddr, |
uint64_t | offset, | ||
uint32_t | size | ||
) |
Write flash.
Write to the flashdisk.
write the data to the disk image. This function doesn't model timing behaviour
Get from fifo and write to image
Definition at line 702 of file ufs_device.cc.
References X86ISA::count, ArmISA::offset, and SectorSize.
|
private |
Definition at line 723 of file ufs_device.hh.
|
private |
transaction progress tracking
Definition at line 722 of file ufs_device.hh.
|
private |
Logic unit dimensions.
Definition at line 692 of file ufs_device.hh.
|
staticprivate |
Definition at line 753 of file ufs_device.hh.
|
private |
Definition at line 695 of file ufs_device.hh.
|
private |
Definition at line 696 of file ufs_device.hh.
|
staticprivate |
These pages are SCSI specific.
For more information refer to: Universal Flash Storage (UFS) JESD220 FEB 2011 (JEDEC) http://www.jedec.org/standards-documents/results/jesd220
Definition at line 751 of file ufs_device.hh.
|
private |
Definition at line 729 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Definition at line 694 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Definition at line 687 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
The objects this model links to.
1: the disk data model 2: the memory timing model
Definition at line 679 of file ufs_device.hh.
|
private |
Definition at line 693 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Definition at line 703 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Logic unit info; needed for SCSI Info messages and LU identification.
Definition at line 702 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Callbacks between Device and Memory.
Definition at line 734 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Definition at line 735 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
|
private |
Definition at line 711 of file ufs_device.hh.
Referenced by clearReadSignal(), finishedRead(), and setReadSignal().
|
staticprivate |
Definition at line 752 of file ufs_device.hh.
std::deque<struct SCSIResumeInfo> UFSHostDevice::UFSSCSIDevice::SCSIInfoQueue |
Information message queues, as there can be multiple messages queued for handling in this system.
These are the main communication interfaces between the Host and the device layers SCSIInfoQueue: each LU handles its own SCSI commands.
Definition at line 628 of file ufs_device.hh.
|
private |
Callbacks between Host and Device.
Definition at line 728 of file ufs_device.hh.
Referenced by UFSSCSIDevice().
std::deque<struct transferInfo> UFSHostDevice::UFSSCSIDevice::SSDReadInfo |
SSDReadInfo: Structure from disk to dma, that contains data, and helper info to get it to the right place in the memory.
Definition at line 634 of file ufs_device.hh.
std::deque<struct transferInfo> UFSHostDevice::UFSSCSIDevice::SSDWriteDoneInfo |
SSDWriteDoneInfo: Structure from dma to disk, that contains data, and helper info to get it to the right place in the memory.
The done is added because it is going to the last phase of the write transfer.
Definition at line 642 of file ufs_device.hh.
|
private |
Total amount transactions that need to be made.
Definition at line 716 of file ufs_device.hh.
|
private |
Definition at line 717 of file ufs_device.hh.
|
private |
Signals to Host layer 1: signal for transaction completion 2: signal for read action completion.
Definition at line 710 of file ufs_device.hh.
Referenced by clearSignal(), finishedCommand(), and setSignal().
transferDoneInfo UFSHostDevice::UFSSCSIDevice::transferInfo |
End of transfer information.
Definition at line 612 of file ufs_device.hh.
|
staticprivate |
Definition at line 741 of file ufs_device.hh.
|
staticprivate |
Definition at line 742 of file ufs_device.hh.
|
staticprivate |
Definition at line 743 of file ufs_device.hh.