|
The Pedigree Project 0.1
|
#include <AtaDisk.h>
Inheritance diagram for AtaDisk:
Collaboration diagram for AtaDisk:Classes | |
| struct | Buffer |
| class | IrqCompletion |
Public Member Functions | |
| AtaDisk (class AtaController *pDev, bool isMaster, IoBase *commandRegs, IoBase *controlRegs, BusMasterIde *busMaster=0) | |
| void | shutdownDeviceCache () override |
| virtual void | getName (String &str) |
| bool | initialise (size_t nUnit=~0) |
| virtual uint64_t | doRead (uint64_t location) |
| virtual uint64_t | doWrite (uint64_t location) |
| virtual uint64_t | doSync (uint64_t location) |
| PagingStatus | preparePagingTransport (PagingTransport *&transport) override |
| PagingStatus | doPagingTransfer (PagingOperation operation, uint64_t offset, void *page) override |
| virtual void | irqReceived () |
| void | maskInterrupts () |
| void | stopDma () |
| virtual BusMasterIde * | getBusMaster () const |
| virtual size_t | getSize () const |
| Gets the size of the disk. | |
| virtual size_t | getBlockSize () const |
| Gets the preferred I/O extent of the disk. | |
| virtual size_t | getNativeBlockSize () const |
| virtual size_t | getBlockCount () const |
| virtual bool | sendCommand (size_t nUnit, uintptr_t pCommand, uint8_t nCommandSize, uintptr_t pRespBuffer, uint16_t nRespBytes, bool bWrite) |
| virtual MUST_USE_RESULT uint64_t | doWriteDirect (uint64_t location, uintptr_t page) |
Public Member Functions inherited from ScsiDisk | |
| ScsiDisk (size_t cacheConstraints=PhysicalMemoryManager::below4GB) | |
| void | shutdownCache (bool deviceAvailable=true) |
| 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 | writeFrom (uint64_t location, const void *buffer, size_t length) override |
| bool | writeFromBatch (WriteBuffer *buffers, size_t count) override |
| bool | syncData () override |
| virtual void | write (uint64_t location) |
| 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 | zero (uint64_t location, size_t length) override |
| 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 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 |
| 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) |
Private Member Functions | |
| void | preparePagingStorage () |
| void | releasePagingStorage () |
| virtual size_t | getCacheFillSize () const |
| void | setupLBA28 (uint64_t n, uint32_t nSectors) |
| void | setupLBA48 (uint64_t n, uint32_t nSectors) |
| virtual size_t | defaultBlockSize () |
| uint64_t | writePageBuffer (uint64_t location, uintptr_t page) |
| void | setFeatures (uint8_t command, uint8_t countreg, uint8_t lowreg, uint8_t midreg, uint8_t hireg) |
Private Attributes | |
| AtaPagingTransport * | m_Paging |
| bool | m_IsMaster |
| IdentifyData | m_pIdent |
| char | m_pName [64] |
| char | m_pSerialNumber [64] |
| char | m_pFirmwareRevision [64] |
| bool | m_SupportsLBA28 |
| bool | m_SupportsLBA48 |
| size_t | m_BlockSize |
| Semaphore * | m_IrqReceived |
| Spinlock | m_IrqLock |
| AtaDiskType | m_AtaDiskType |
| uint8_t | m_PacketSize |
| bool | m_Removable |
| IoBase * | m_CommandRegs |
| IoBase * | m_ControlRegs |
| BusMasterIde * | m_BusMaster |
| Mutex | m_PrdTableLock |
| PhysicalRegionDescriptor * | m_PrdTable |
| size_t | m_LastPrdTableOffset |
| physical_uintptr_t | m_PrdTablePhys |
| MemoryRegion | m_PrdTableMemRegion |
| bool | m_bDma |
| Atomic< size_t > | m_IrqCount |
Friends | |
| class | AtaPagingTransport |
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 |
Protected Member Functions inherited from ScsiDisk | |
| BufferView | acquireView (uint64_t location, bool writable, uint64_t &token) override |
| void | releaseView (uint64_t token, bool writable) override |
| virtual bool | supportsBufferTransfers () const |
| virtual bool | supportsDirectCacheWrite () const |
| virtual Device * | dmaDevice () const |
| virtual bool | transferBuffer (uint64_t location, void *buffer, size_t length, bool writing) |
| 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) |
| 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) | |
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 |
An ATA device.
This could be anything from an ATAPI device (eg, CDROM) to a pure and simple IDE disk. We inherit ScsiDisk as it is needed for ATAPI. Non-ATAPI disks simply don't use the ScsiDisk interface.
| AtaDisk::AtaDisk | ( | class AtaController * | pDev, |
| bool | isMaster, | ||
| IoBase * | commandRegs, | ||
| IoBase * | controlRegs, | ||
| BusMasterIde * | busMaster = 0 |
||
| ) |
Definition at line 211 of file AtaDisk.cc.
|
virtual |
Definition at line 235 of file AtaDisk.cc.
|
inlineprivatevirtual |
Default block size for this device.
Reimplemented from ScsiDisk.
Definition at line 148 of file AtaDisk.h.
References m_AtaDiskType.
|
overridevirtual |
Reimplemented from ScsiDisk.
Definition at line 118 of file AtaDisk-paging.cc.
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 844 of file AtaDisk.cc.
References Semaphore::acquireForCompletion(), ALIGN, AtaDisk::Buffer::buffer, ScsiDisk::doRead(), ScsiDisk::getCacheFillLength(), Device::getInterruptNumber(), ProcessorBase::getInterrupts(), BusMasterIde::hasCompleted(), BusMasterIde::hasError(), BusMasterIde::hasInterrupt(), Cache::insert(), Cache::lookup(), m_AtaDiskType, m_bDma, m_CommandRegs, m_IsMaster, m_pIdent, m_SupportsLBA48, AtaDisk::Buffer::offset, ProcessorBase::pause(), IoBase::read16(), Cache::release(), ProcessorBase::setInterrupts(), setupLBA28(), setupLBA48(), and IoBase::write8().
Referenced by IsaAtaController::executeRequest(), and PciAtaController::executeRequest().
Here is the caller graph for this function:
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 1139 of file AtaDisk.cc.
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 1089 of file AtaDisk.cc.
References m_AtaDiskType, panic(), Cache::release(), and writePageBuffer().
Referenced by IsaAtaController::executeRequest(), and PciAtaController::executeRequest().
Here is the caller graph for this function:
|
virtual |
Writes one caller-borrowed page without acquiring cache ownership.
Reimplemented from ScsiDisk.
Definition at line 1124 of file AtaDisk.cc.
References m_AtaDiskType, and writePageBuffer().
Referenced by IsaAtaController::executeRequest(), and PciAtaController::executeRequest().
Here is the caller graph for this function:
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 1486 of file AtaDisk.cc.
|
virtual |
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 1457 of file AtaDisk.cc.
References ScsiDisk::getBlockSize(), m_AtaDiskType, and m_BlockSize.
|
inlinevirtual |
Retrieve the BusMaster IDE interface for this disk.
Definition at line 126 of file AtaDisk.h.
Referenced by PciAtaController::irq().
Here is the caller graph for this function:
|
privatevirtual |
Size of one cache fill performed by this implementation.
The generic path owns independently evictable target pages. A subclass may opt into a larger extent only when its doRead() handles partially populated extents page by page.
Reimplemented from ScsiDisk.
Definition at line 1464 of file AtaDisk.cc.
References ScsiDisk::getCacheFillSize(), m_AtaDiskType, and m_BlockSize.
|
inlinevirtual |
|
virtual |
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 1471 of file AtaDisk.cc.
References ScsiDisk::getNativeBlockSize(), m_AtaDiskType, and m_pIdent.
Referenced by preparePagingTransport(), and writePageBuffer().
Here is the caller graph for this function:
|
virtual |
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 1430 of file AtaDisk.cc.
References ScsiDisk::getSize(), m_AtaDiskType, m_pIdent, and m_SupportsLBA48.
Referenced by preparePagingTransport().
Here is the caller graph for this function:| bool AtaDisk::initialise | ( | size_t | nUnit = ~0 | ) |
Initialises the device and detects its features, if it is present.
Definition at line 258 of file AtaDisk.cc.
References Dec, Device::getInterruptNumber(), TargetInfo::getPageSize(), Hex, ScsiDisk::initialise(), m_AtaDiskType, m_bDma, m_BlockSize, m_CommandRegs, m_IsMaster, m_PacketSize, m_pFirmwareRevision, m_pIdent, m_pName, Device::m_pParent, m_pSerialNumber, m_Removable, m_SupportsLBA48, IoBase::read16(), IoBase::read8(), setFeatures(), and IoBase::write8().
|
virtual |
Called when an IRQ is received by the controller.
Definition at line 1361 of file AtaDisk.cc.
References m_IrqReceived, and Semaphore::release().
Referenced by IsaAtaController::irq(), and PciAtaController::irq().
Here is the caller graph for this function:| void AtaDisk::maskInterrupts | ( | ) |
Masks fresh device interrupts before controller IRQ removal.
Definition at line 245 of file AtaDisk.cc.
References IoBase::write8().
|
private |
Definition at line 81 of file AtaDisk-paging.cc.
|
overridevirtual |
Called while the endpoint excludes new ordinary users.
Reimplemented from Disk.
Definition at line 92 of file AtaDisk-paging.cc.
References getNativeBlockSize(), getSize(), m_AtaDiskType, m_pIdent, and m_SupportsLBA48.
|
private |
Definition at line 87 of file AtaDisk-paging.cc.
|
virtual |
Definition at line 617 of file AtaDisk.cc.
|
private |
Performs the SET FEATURES command.
Definition at line 1414 of file AtaDisk.cc.
References m_CommandRegs, m_IsMaster, and IoBase::write8().
Referenced by initialise().
Here is the caller graph for this function:
|
private |
Sets the drive up for reading from address 'n' in LBA28 mode.
Definition at line 1368 of file AtaDisk.cc.
References m_CommandRegs, m_IsMaster, and IoBase::write8().
Referenced by doRead(), and writePageBuffer().
Here is the caller graph for this function:
|
private |
Sets the drive up for reading from address 'n' in LBA48 mode.
Definition at line 1391 of file AtaDisk.cc.
References m_CommandRegs, and IoBase::write8().
Referenced by doRead(), and writePageBuffer().
Here is the caller graph for this function:
|
overridevirtual |
Reimplemented from ScsiDisk.
Definition at line 239 of file AtaDisk.cc.
| void AtaDisk::stopDma | ( | ) |
Stops and acknowledges the bus-master channel after IRQ removal.
Definition at line 252 of file AtaDisk.cc.
References BusMasterIde::commandComplete().
|
private |
Writes one supplied page through the native ATA data path.
Definition at line 1197 of file AtaDisk.cc.
References Semaphore::acquireForCompletion(), Device::getInterruptNumber(), ProcessorBase::getInterrupts(), getNativeBlockSize(), BusMasterIde::hasCompleted(), BusMasterIde::hasError(), BusMasterIde::hasInterrupt(), m_bDma, m_CommandRegs, m_IsMaster, m_pIdent, m_SupportsLBA48, ProcessorBase::pause(), ProcessorBase::setInterrupts(), setupLBA28(), setupLBA48(), and IoBase::write8().
Referenced by doWrite(), and doWriteDirect().
Here is the caller graph for this function:
|
friend |
|
private |
What type of disk are we?
Definition at line 198 of file AtaDisk.h.
Referenced by defaultBlockSize(), doRead(), doWrite(), doWriteDirect(), getBlockSize(), getCacheFillSize(), getNativeBlockSize(), getSize(), initialise(), and preparePagingTransport().
|
private |
Can we do DMA?
Definition at line 232 of file AtaDisk.h.
Referenced by doRead(), initialise(), and writePageBuffer().
|
private |
Block size in bytes for all read/write operations.
Definition at line 189 of file AtaDisk.h.
Referenced by getBlockSize(), getCacheFillSize(), and initialise().
|
private |
|
private |
Command & control registers, and DMA access for this disk
Definition at line 211 of file AtaDisk.h.
Referenced by doRead(), initialise(), setFeatures(), setupLBA28(), setupLBA48(), and writePageBuffer().
|
private |
A per-command completion released by the interrupt handler.
Definition at line 194 of file AtaDisk.h.
Referenced by irqReceived().
|
private |
Is this the master device on the bus?
Definition at line 174 of file AtaDisk.h.
Referenced by doRead(), initialise(), setFeatures(), setupLBA28(), and writePageBuffer().
|
private |
|
private |
|
private |
|
private |
|
private |
The result of the IDENTIFY command.
Definition at line 177 of file AtaDisk.h.
Referenced by doRead(), getNativeBlockSize(), getSize(), initialise(), preparePagingTransport(), and writePageBuffer().
|
private |
The model name of the device.
Definition at line 179 of file AtaDisk.h.
Referenced by getName(), and initialise().
|
private |
|
private |
|
private |
MemoryRegion for the PRD table
|
private |
|
private |
The serial number of the device.
Definition at line 181 of file AtaDisk.h.
Referenced by initialise().
|
private |
|
private |
|
private |
Does the device support LBA48?
Definition at line 187 of file AtaDisk.h.
Referenced by doRead(), getSize(), initialise(), preparePagingTransport(), and writePageBuffer().