The Pedigree Project
0.1
|
#include <Disk.h>
Public Types | |
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 *) |
Public Member Functions | |
Disk (Device *p) | |
virtual Type | getType () |
virtual SubType | getSubType () |
virtual void | getName (String &str) |
virtual void | dump (String &str) |
virtual uintptr_t | read (uint64_t location) |
virtual void | write (uint64_t location) |
virtual void | align (uint64_t location) |
Sets the page boundary alignment after a specific location on the disk. More... | |
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 void | pin (uint64_t location) |
Pins a cache page. More... | |
virtual void | unpin (uint64_t location) |
virtual bool | cacheIsCritical () |
Whether or not the cache is critical and cannot be flushed or deleted. More... | |
virtual void | flush (uint64_t location) |
Flush a cached page to disk. 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) |
Additional Inherited Members | |
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) |
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 |
|
virtual |
Sets the page boundary alignment after a specific location on the disk.
For example, if one has a partition starting on byte 512, one will probably want 4096-byte reads to be aligned with this (so reading 4096 bytes from byte 0 on the partition will create one page of cache and not span two). Without an align point a read of the first sector of a partition starting at byte 512 will have to have a location of 512 rather than 0.
Use this function to allow reads to fit into the 4096 byte buffers manipulated in read()
or write()
even when location isn't aligned on a 4096 byte boundary.
Reimplemented in ScsiDisk, and FileDisk.
Definition at line 65 of file Disk.cc.
Referenced by FileDisk::getName(), Partition::read(), and Partition::write().
|
virtual |
Whether or not the cache is critical and cannot be flushed or deleted.
Some implementations of this class may provide a Disk that does not actually back onto a writable media, or perhaps sit only in RAM and have no correlation to physical hardware. If cache pages are deleted for these implementations, data may be lost.
Note that cache should only be marked "critical" if it is possible to write via an implementation. There is no need to worry about cache pages being deleted on a read-only disk as they will be re-created on the next read (and no written data is lost).
This function allows callers that want to delete cache pages to verify that the cache is not critical to the performance of the implementation.
|
virtual |
|
virtual |
Flush a cached page to disk.
Essentially a no-op if the given location is not actually in cache. Called either by filesystem drivers (on removable disks) or from a central cache manager which handles flushing caches back to the disk on a regular basis.
Will not remove the page from cache, that must be done by the caller.
|
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 in ScsiDisk, Partition, AtaDisk, and DiskImage.
Definition at line 74 of file Disk.cc.
Referenced by RawFsFile::getBlockSize(), and Partition::getBlockSize().
|
virtual |
Stores the device's name in str.
Reimplemented from Device.
Reimplemented in ScsiDisk, AtaDisk, FileDisk, DiskImage, CdiDisk, and Partition.
Definition at line 46 of file Disk.cc.
Referenced by Ext2Filesystem::initialise(), FatFilesystem::initialise(), and msdosProbeDisk().
|
virtual |
|
virtual |
Returns the (abstract) type of the device.
Reimplemented from Device.
Definition at line 36 of file Disk.cc.
References Device::Disk.
|
virtual |
Pins a cache page.
This allows an upstream user of Disk pages to 'pin' cache pages, causing them to only be freed once all consumers have done an 'unpin'. The pin and unpin semantics allow for memory mappings to be made in a reasonably safe manner, as it can be assumed that the physical page for a particular cache block will not be freed.
|
virtual |
Read from location
on disk and return a pointer to it. location
must be 512 byte aligned. The pointer returned is within a page of cache that maps to 4096 bytes of disk area.
location | The offset from the start of the device, in bytes, to start the read, must be multiple of 512. |
write()
or flush()
). Reimplemented in ScsiDisk, FileDisk, Partition, CdiDisk, and DiskImage.
Definition at line 56 of file Disk.cc.
Referenced by Iso9660Directory::cacheDirectoryContents(), FileDisk::getName(), FatFilesystem::initialise(), msdosProbeDisk(), msdosReadTable(), Partition::read(), RawFsFile::readBlock(), FatFilesystem::readSectorBlock(), and FatFilesystem::writeSectorBlock().
|
virtual |
|
virtual |
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()
).
location | The offset from the start of the device, in bytes, to start the write. Must be 512byte aligned. |
Reimplemented in ScsiDisk, Partition, FileDisk, and CdiDisk.
Definition at line 61 of file Disk.cc.
Referenced by FileDisk::getName(), Partition::write(), and FatFilesystem::writeSectorBlock().