The Pedigree Project
0.1
|
#include <AtaDisk.h>
Classes | |
struct | Buffer |
Public Member Functions | |
AtaDisk (class AtaController *pDev, bool isMaster, IoBase *commandRegs, IoBase *controlRegs, BusMasterIde *busMaster=0) | |
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 void | irqReceived () |
virtual BusMasterIde * | getBusMaster () const |
virtual size_t | getSize () const |
Gets the size of the disk. More... | |
virtual size_t | getBlockSize () const |
Gets the block size of the disk. More... | |
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) |
Public Member Functions inherited from ScsiDisk | |
bool | initialise (class ScsiController *pController, size_t nUnit) |
virtual uintptr_t | read (uint64_t location) |
virtual void | write (uint64_t location) |
virtual void | flush (uint64_t location) |
Flush a cached page to disk. More... | |
virtual void | align (uint64_t location) |
Sets the page boundary alignment after a specific location on the disk. More... | |
virtual uint64_t | doSync (uint64_t location) |
virtual void | pin (uint64_t location) |
Pins a cache page. More... | |
virtual void | unpin (uint64_t location) |
Public Member Functions inherited from Disk | |
Disk (Device *p) | |
virtual Type | getType () |
virtual SubType | getSubType () |
virtual void | dump (String &str) |
virtual bool | cacheIsCritical () |
Whether or not the cache is critical and cannot be flushed or deleted. More... | |
Public Member Functions inherited from Device | |
Device (Device *p) | |
Device * | getParent () const |
void | setParent (Device *p) |
virtual 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 () |
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 | setupLBA28 (uint64_t n, uint32_t nSectors) |
void | setupLBA48 (uint64_t n, uint32_t nSectors) |
virtual size_t | defaultBlockSize () |
void | setFeatures (uint8_t command, uint8_t countreg, uint8_t lowreg, uint8_t midreg, uint8_t hireg) |
Private Attributes | |
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 |
Mutex * | m_IrqReceived |
Mutex | m_IrqLock |
ConditionVariable | m_IrqCondition |
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 |
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 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 |
Protected Member Functions inherited from ScsiDisk | |
Cache & | getCache () |
Inquiry * | getInquiry () const |
Protected Member Functions inherited from Device | |
NOT_COPYABLE_OR_ASSIGNABLE (Device) | |
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 |
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.
|
inlineprivatevirtual |
Default block size for this device.
Reimplemented from ScsiDisk.
Definition at line 110 of file AtaDisk.h.
References m_AtaDiskType.
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 681 of file AtaDisk.cc.
References ALIGN, assert, AtaDisk::Buffer::buffer, ScsiDisk::doRead(), ERROR, FATAL, Device::getInterruptNumber(), Processor::getInterrupts(), AtaDisk::Buffer::offset, IoBase::read16(), IoBase::read8(), AtaStatus::reg, Processor::setInterrupts(), WARNING, and IoBase::write8().
Referenced by IsaAtaController::executeRequest(), PciAtaController::executeRequest(), and getName().
|
virtual |
Reimplemented from ScsiDisk.
Definition at line 943 of file AtaDisk.cc.
References FATAL, Device::getInterruptNumber(), Processor::getInterrupts(), NOTICE, panic(), IoBase::read8(), AtaStatus::reg, Processor::setInterrupts(), WARNING, IoBase::write16(), and IoBase::write8().
Referenced by IsaAtaController::executeRequest(), PciAtaController::executeRequest(), and getName().
|
virtual |
Gets the block size of the disk.
This is the native block size with which all reads and writes are performed, regardless of how much data is available to be read/written.
Reimplemented from ScsiDisk.
Definition at line 1261 of file AtaDisk.cc.
References ScsiDisk::getBlockSize().
Referenced by AtaController::compareRequests(), and getBusMaster().
|
inlinevirtual |
Retrieve the BusMaster IDE interface for this disk.
Definition at line 88 of file AtaDisk.h.
References getBlockSize(), getNativeBlockSize(), getSize(), sendCommand(), setupLBA28(), and setupLBA48().
Referenced by PciAtaController::irq().
|
inlinevirtual |
Stores the device's name in str.
Reimplemented from ScsiDisk.
Definition at line 67 of file AtaDisk.h.
References doRead(), doWrite(), initialise(), irqReceived(), and m_pName.
|
virtual |
Retrieves the native block size - that is, the logical block size. This differs from the main block size, which is for caching.
Reimplemented from ScsiDisk.
Definition at line 1270 of file AtaDisk.cc.
References ScsiDisk::getNativeBlockSize().
Referenced by getBusMaster().
|
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 1228 of file AtaDisk.cc.
References ScsiDisk::getSize().
Referenced by getBusMaster().
bool AtaDisk::initialise | ( | size_t | nUnit = ~0 | ) |
Initialises the device and detects its features, if it is present.
Definition at line 60 of file AtaDisk.cc.
References AtaStatus::__reg_contents, Dec, ERROR, Device::getInterruptNumber(), Hex, ScsiDisk::initialise(), Device::m_pParent, NOTICE, IoBase::read16(), IoBase::read8(), AtaStatus::reg, WARNING, and IoBase::write8().
Referenced by getName(), and PciAtaController::PciAtaController().
|
virtual |
Called when an IRQ is received by the controller.
Definition at line 1156 of file AtaDisk.cc.
Referenced by getName(), IsaAtaController::irq(), and PciAtaController::irq().
|
virtual |
Definition at line 470 of file AtaDisk.cc.
References AtaStatus::__reg_contents, ERROR, NOTICE, IoBase::read16(), IoBase::read8(), AtaStatus::reg, WARNING, IoBase::write16(), and IoBase::write8().
Referenced by getBusMaster(), and PciAtaController::PciAtaController().
|
private |
Performs the SET FEATURES command.
Definition at line 1210 of file AtaDisk.cc.
References IoBase::write8().
|
private |
Sets the drive up for reading from address 'n' in LBA28 mode.
Definition at line 1162 of file AtaDisk.cc.
References IoBase::write8().
Referenced by getBusMaster().
|
private |
Sets the drive up for reading from address 'n' in LBA48 mode.
Definition at line 1186 of file AtaDisk.cc.
References IoBase::write8().
Referenced by getBusMaster().
|
private |
What type of disk are we?
Definition at line 160 of file AtaDisk.h.
Referenced by defaultBlockSize().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
MemoryRegion for the PRD table
|
private |
|
private |
|
private |
|
private |