The Pedigree Project 0.1
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
VirtioBlkDisk Class Referencefinal
+ Inheritance diagram for VirtioBlkDisk:
+ Collaboration diagram for VirtioBlkDisk:

Public Member Functions

 VirtioBlkDisk (VirtioBlkController *controller)
 
void getName (String &name) override
 
size_t getSize () const override
 Gets the size of the disk.
 
size_t getBlockCount () const override
 
size_t getBlockSize () const override
 Gets the preferred I/O extent of the disk.
 
size_t getNativeBlockSize () const override
 
bool writeFrom (uint64_t location, const void *buffer, size_t length) override
 
bool writeFromBatch (WriteBuffer *buffers, size_t count) override
 
void write (uint64_t location) override
 
bool zero (uint64_t location, size_t length) override
 
uint64_t doRead (uint64_t location) override
 
uint64_t doWrite (uint64_t location) override
 
uint64_t doWriteDirect (uint64_t location, uintptr_t page) override
 
uint64_t doSync (uint64_t location) override
 
- Public Member Functions inherited from ScsiDisk
 ScsiDisk (size_t cacheConstraints=PhysicalMemoryManager::below4GB)
 
void shutdownCache ()
 
virtual void shutdownDeviceCache ()
 
bool hasNoCacheLoans ()
 
bool initialise (class ScsiController *pController, size_t nUnit)
 
virtual BufferView read (uint64_t location)
 
bool readInto (uint64_t location, void *buffer, size_t length) override
 
bool readIntoBatch (ReadBuffer *buffers, size_t count) override
 
bool syncData () override
 
virtual void flush (uint64_t location)
 Flush a cached page to disk.
 
virtual bool sync (uint64_t location, bool async)
 
virtual MUST_USE_RESULT bool syncAll ()
 
bool syncPages (const uint64_t *locations, size_t count) override
 
virtual MUST_USE_RESULT bool retireCachePage (uint64_t location)
 
virtual void align (uint64_t location)
 Sets the page boundary alignment after a specific location on the disk.
 
virtual uint64_t doWriteDirectPhysical (uint64_t location, uintptr_t page, physical_uintptr_t physical)
 
virtual PagingStatus doPagingTransfer (PagingOperation operation, uint64_t offset, void *page)
 
virtual bool pin (uint64_t location)
 Pins a cache page.
 
virtual void unpin (uint64_t location)
 
- Public Member Functions inherited from Disk
 Disk (Device *p)
 
virtual Disk * physicalDisk ()
 
bool acquireUse (DiskUse &use)
 
uint32_t endpointId ()
 
virtual bool getPartitionUuid (String &uuid) const
 
virtual bool getPartitionLabel (String &label) const
 
virtual PagingStatus preparePagingTransport (PagingTransport *&transport)
 
void retireEndpoint ()
 
bool tryCloseEndpoint ()
 
void reopenEndpoint ()
 
virtual Type getType ()
 
virtual SubType getSubType ()
 
virtual void dump (String &str)
 
virtual DiskReadView readView (uint64_t location)
 
virtual DiskWriteView writeView (uint64_t location)
 
MUST_USE_RESULT bool readViews (uint64_t location, size_t length, BufferViewSequence &views)
 
void unpinViews (uint64_t location, BufferViewSequence &views)
 
virtual bool cacheIsCritical ()
 Whether or not the cache is critical and cannot be flushed or deleted.
 
- Public Member Functions inherited from Device
 Device (Device *p)
 
Device * getParent () const
 
void setParent (Device *p)
 
virtual const String & getSpecificType ()
 
virtual void setSpecificType (String str)
 
void setPciPosition (uint32_t bus, uint32_t device, uint32_t func)
 
void setPciIdentifiers (uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
 
void setPciConfigHeader (const PciBus::ConfigSpace &space)
 
PciBus::ConfigSpace getPciConfigHeader () const
 
uint8_t getPciClassCode ()
 
uint8_t getPciSubclassCode ()
 
uint16_t getPciVendorId ()
 
uint16_t getPciDeviceId ()
 
uint8_t getPciProgInterface ()
 
uint32_t getPciBusPosition ()
 
uint32_t getPciDevicePosition ()
 
uint32_t getPciFunctionNumber ()
 
Device * getPhysicalFunction () const
 
size_t getVirtualFunctionIndex () const
 
void setVirtualFunction (Device *physicalFunction, size_t index)
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
Device * getChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 

Protected Member Functions

BufferView acquireView (uint64_t location, bool writable, uint64_t &token) override
 
bool supportsBufferTransfers () const override
 
bool transferBuffer (uint64_t location, void *buffer, size_t length, bool writing) override
 
- Protected Member Functions inherited from ScsiDisk
void releaseView (uint64_t token, bool writable) override
 
virtual bool supportsDirectCacheWrite () const
 
virtual Device * dmaDevice () const
 
virtual bool transferReadBuffers (ReadBuffer *buffers, size_t count)
 
virtual bool transferWriteBuffers (WriteBuffer *buffers, size_t count)
 
ScsiController * acquirePagingController (OperationBarrier::Lease &use)
 
PagingStatus preparePagingCache (PagingTransport &transport)
 
virtual size_t getCacheFillSize () const
 
size_t getCacheFillLength (uint64_t location) const
 
Cache & getCache ()
 
Inquiry * getInquiry () const
 
- Protected Member Functions inherited from Disk
void reserveEndpoint ()
 
void publishEndpoint ()
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 

Private Member Functions

size_t validPageLength (uint64_t location) const
 

Private Attributes

VirtioBlkController * m_Controller
 

Friends

class VirtioBlkController
 

Additional Inherited Members

- Public Types inherited from Disk
enum  SubType { ATA = 0 , ATAPI }
 
- Public Types inherited from Device
enum  Type {
  Generic , Root , Disk , Bus ,
  Display , Network , Sound , Console ,
  Mouse , Controller , UsbController , UsbGeneric ,
  UsbContainer
}
 
typedef Device *(* Callback) (Device *)
 
- Static Public Member Functions inherited from Device
static bool treeLockHeldByCurrentThread ()
 
static void foreach (Callback callback, Device *root=0)
 
template<class F , class... Args>
static void foreach (pedigree_std::Callable< F > &callback, Device *root, Args... args)
 
static void addToRoot (Device *device)
 
static void searchByVendorId (uint16_t vendorId, void(*callback)(Device *), Device *root=0)
 
static void searchByVendorIdAndDeviceId (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root=0)
 
static void searchByClass (uint16_t classCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassAndSubclass (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassSubclassAndProgInterface (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root=0)
 
- Public Attributes inherited from ScsiDisk
struct ScsiDisk::Sense PACKED
 
struct ScsiDisk::Inquiry PACKED
 
struct ScsiDisk::Capacity PACKED
 
- Static Public Attributes inherited from ScsiDisk
static constexpr uint64_t SyncWholeDevice = ~uint64_t{0}
 
- Static Public Attributes inherited from Disk
static constexpr size_t MaxReadBuffers = 32
 
static constexpr size_t MaxWriteBuffers = 32
 
static constexpr size_t MaxSyncPages = 64
 
- Static Protected Member Functions inherited from ScsiDisk
static bool syncCacheBatch (const Cache::WritebackPage *pages, size_t count, void *context)
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Device * m_pParent
 
Device * m_PhysicalFunction
 
size_t m_VirtualFunctionIndex
 
uintptr_t m_InterruptNumber
 
String m_SpecificType
 
PciBus::ConfigSpace m_ConfigHeader
 
uint8_t m_ClassCode
 
uint8_t m_SubclassCode
 
uint16_t m_VendorId
 
uint16_t m_DeviceId
 
uint8_t m_ProgInterface
 
uint32_t m_PciBusPos
 
uint32_t m_PciDevicePos
 
uint32_t m_PciFunctionNum
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 

Detailed Description

Definition at line 9 of file VirtioBlkDisk.h.

Constructor & Destructor Documentation

◆ VirtioBlkDisk()

VirtioBlkDisk::VirtioBlkDisk ( VirtioBlkController *  controller)
explicit

Definition at line 9 of file VirtioBlkDisk.cc.

◆ ~VirtioBlkDisk()

VirtioBlkDisk::~VirtioBlkDisk ( )
override

Definition at line 14 of file VirtioBlkDisk.cc.

Member Function Documentation

◆ acquireView()

BufferView VirtioBlkDisk::acquireView ( uint64_t  location,
bool  writable,
uint64_t &  token 
)
overrideprotectedvirtual

Reimplemented from ScsiDisk.

Definition at line 67 of file VirtioBlkDisk.cc.

◆ doRead()

uint64_t VirtioBlkDisk::doRead ( uint64_t  location)
overridevirtual

Reimplemented from ScsiDisk.

Definition at line 84 of file VirtioBlkDisk.cc.

◆ doSync()

uint64_t VirtioBlkDisk::doSync ( uint64_t  location)
overridevirtual

Reimplemented from ScsiDisk.

Definition at line 141 of file VirtioBlkDisk.cc.

◆ doWrite()

uint64_t VirtioBlkDisk::doWrite ( uint64_t  location)
overridevirtual

Reimplemented from ScsiDisk.

Definition at line 113 of file VirtioBlkDisk.cc.

◆ doWriteDirect()

uint64_t VirtioBlkDisk::doWriteDirect ( uint64_t  location,
uintptr_t  page 
)
overridevirtual

Writes one caller-borrowed page without acquiring cache ownership.

Reimplemented from ScsiDisk.

Definition at line 129 of file VirtioBlkDisk.cc.

◆ getBlockCount()

size_t VirtioBlkDisk::getBlockCount ( ) const
overridevirtual

Reimplemented from ScsiDisk.

Definition at line 27 of file VirtioBlkDisk.cc.

◆ getBlockSize()

size_t VirtioBlkDisk::getBlockSize ( ) const
overridevirtual

Gets the preferred I/O extent of the disk.

This may describe a native device block or a larger cache-fill/readahead extent, depending on the implementation. It is independent of the cache page boundary reported by BufferView::size().

Reimplemented from ScsiDisk.

Definition at line 31 of file VirtioBlkDisk.cc.

References TargetInfo::getPageSize().

◆ getName()

void VirtioBlkDisk::getName ( String &  str)
overridevirtual

Stores the device's name in str.

Reimplemented from ScsiDisk.

Definition at line 19 of file VirtioBlkDisk.cc.

◆ getNativeBlockSize()

size_t VirtioBlkDisk::getNativeBlockSize ( ) const
overridevirtual

Retrieves the native block size - that is, the logical block size. This differs from the preferred I/O/cache-fill extent.

Reimplemented from ScsiDisk.

Definition at line 35 of file VirtioBlkDisk.cc.

◆ getSize()

size_t VirtioBlkDisk::getSize ( ) const
overridevirtual

Gets the size of the disk.

This is the size in bytes of the disk. Reads or writes beyond this size will fail.

Reimplemented from ScsiDisk.

Definition at line 23 of file VirtioBlkDisk.cc.

Referenced by zero().

+ Here is the caller graph for this function:

◆ supportsBufferTransfers()

bool VirtioBlkDisk::supportsBufferTransfers ( ) const
inlineoverrideprotectedvirtual

Reimplemented from ScsiDisk.

Definition at line 31 of file VirtioBlkDisk.h.

◆ transferBuffer()

bool VirtioBlkDisk::transferBuffer ( uint64_t  location,
void *  buffer,
size_t  length,
bool  writing 
)
overrideprotectedvirtual

Reimplemented from ScsiDisk.

Definition at line 150 of file VirtioBlkDisk.cc.

◆ validPageLength()

size_t VirtioBlkDisk::validPageLength ( uint64_t  location) const
private

Definition at line 74 of file VirtioBlkDisk.cc.

◆ write()

void VirtioBlkDisk::write ( uint64_t  location)
overridevirtual

This function schedules a cache writeback of the given location. The data to be written back is fetched from the cache (pointer returned by read() ).

Parameters
locationThe offset from the start of the device, in bytes, to start the write. Must be 512byte aligned.

Reimplemented from ScsiDisk.

Definition at line 56 of file VirtioBlkDisk.cc.

References ScsiDisk::write().

◆ writeFrom()

bool VirtioBlkDisk::writeFrom ( uint64_t  location,
const void *  buffer,
size_t  length 
)
overridevirtual

Reimplemented from ScsiDisk.

Definition at line 39 of file VirtioBlkDisk.cc.

◆ writeFromBatch()

bool VirtioBlkDisk::writeFromBatch ( WriteBuffer *  buffers,
size_t  count 
)
overridevirtual

Writes caller-owned buffers, draining all issued I/O before return. complete reports each fully transferred range, including on partial failure. Storage must remain valid until return; syncData() supplies durability.

Reimplemented from ScsiDisk.

Definition at line 46 of file VirtioBlkDisk.cc.

References ScsiDisk::writeFromBatch().

◆ zero()

bool VirtioBlkDisk::zero ( uint64_t  location,
size_t  length 
)
overridevirtual

Zeroes a range in the cache; syncAll supplies durability. A failed call may have zeroed a prefix. Full cache pages need no old contents read.

Reimplemented from ScsiDisk.

Definition at line 62 of file VirtioBlkDisk.cc.

References getSize(), and ScsiDisk::zero().

Friends And Related Symbol Documentation

◆ VirtioBlkController

friend class VirtioBlkController
friend

Definition at line 37 of file VirtioBlkDisk.h.

Member Data Documentation

◆ m_Controller

VirtioBlkController* VirtioBlkDisk::m_Controller
private

Definition at line 40 of file VirtioBlkDisk.h.


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