|
The Pedigree Project 0.1
|
#include <Device.h>
Inheritance diagram for Device:
Collaboration diagram for Device:Classes | |
| class | Address |
| class | TreeLockGuard |
Public Types | |
| enum | Type { Generic , Root , Disk , Bus , Display , Network , Sound , Console , Mouse , Controller , UsbController , UsbGeneric , UsbContainer } |
| typedef Device *(* | Callback) (Device *) |
Public Member Functions | |
| Device (Device *p) | |
| Device * | getParent () const |
| void | setParent (Device *p) |
| virtual void | getName (String &str) |
| virtual Type | getType () |
| 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 void | dump (String &str) |
| 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) |
Static Public Member Functions | |
| 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) |
Protected Member Functions | |
| NOT_COPYABLE_OR_ASSIGNABLE (Device) | |
Static Protected Member Functions | |
| static Device & | root () |
Protected Attributes | |
| 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 | |
| static Device | m_Root |
| static Mutex | m_TreeLock |
Private Member Functions | |
| void | removeIoMappings () |
Static Private Member Functions | |
| static void | foreachInternal (Callback callback, Device *root) |
| template<class F , class... Args> | |
| static void | foreachInternal (pedigree_std::Callable< F > &callback, Device *root, Args... args) |
| static void | searchByVendorIdInternal (uint16_t vendorId, void(*callback)(Device *), Device *root) |
| static void | searchByVendorIdAndDeviceIdInternal (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root) |
| static void | searchByClassInternal (uint16_t classCode, void(*callback)(Device *), Device *root) |
| static void | searchByClassAndSubclassInternal (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root) |
| static void | searchByClassSubclassAndProgInterfaceInternal (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root) |
Represents a node in the device tree. This could either be a bus (non-leaf node) or a device (leaf node).
| enum Device::Type |
Every device has a type. This can be used to downcast to a more specific class during runtime without RTTI.
| Enumerator | |
|---|---|
| Generic | The device type is not covered by any other value. |
| Root | The device is the root of the device tree. |
| Disk | A disk device - a block device in UNIX terms. |
| Bus | A node that performs address space translation and I/O multiplexing. |
| Display | A display device. This can either be a dumb framebuffer or something more complex. |
| Network | A communication device. |
| Sound | A device that can play sounds. |
| Console | A keyboard-like human interface device. |
| Mouse | A mouse-like human interface device (includes trackpads and styluses) |
| Controller | A device which exposes other devices but requires a driver, and does no address space translation. |
| UsbController | Same as Controller, but exposes USB devices. |
| UsbGeneric | Same as Generic, but for USB devices. |
| UsbContainer | Wraps a UsbDevice (which does not inherit Device) in a Device so it can be in the tree. |
| Device::Device | ( | Device * | p | ) |
Definition at line 66 of file Device.cc.
References Vector< T >::count(), Hex, Device::Address::m_Address, m_Addresses, m_Children, Device::Address::m_Io, Device::Address::m_IsIoSpace, Device::Address::m_Name, Device::Address::m_Padding, m_pParent, Device::Address::m_Size, Vector< T >::pushBack(), and removeIoMappings().
| void Device::addChild | ( | Device * | pDevice | ) |
Sets pDevice as a child of this device. pDevice's parent is NOT updated.
Adds a device as a child of this device.
Definition at line 135 of file Device.cc.
References m_Children, and Vector< T >::pushBack().
Referenced by addToRoot(), and Pc::initialiseDeviceTree().
Here is the caller graph for this function:Returns the addresses of the device, in its parent's address space
Definition at line 266 of file Device.h.
Referenced by Pc::initialiseDeviceTree(), and PciAtaController::PciAtaController().
Here is the caller graph for this function:
|
static |
Adds the given object to the root of the device tree, atomically.
Definition at line 114 of file Device.cc.
References addChild(), and root().
Referenced by Pc::initialiseDeviceTree().
Here is the caller graph for this function:
|
inlinevirtual |
Dumps a textual representation of the device into the given string.
Reimplemented in VirtioGpu, DiskImage, VmwareGraphics, UsbDeviceContainer, Bus, Controller, Disk, Display, Network, Ps2Controller, and Partition.
Definition at line 261 of file Device.h.
Referenced by DeviceHashTree::add(), and DeviceHashTree::getHash().
Here is the caller graph for this function:
|
static |
Traverses the full device tree, calling the given callback for each item.
This will take a lock if threading is enabled, such that any operations taking place on the device tree will block until iteration completes.
To facilitate environments that may need to replace objects, the callback returns a Device pointer. If this pointer is null, the referenced Device is removed from the tree. If this pointer is different to the original, the original is replaced by the new pointer in the tree. Otherwise, if the pointer does not differ, no action is taken.
This characteristic allows for a full traversal to be performed, editing the tree along the way, safely and without conflicting with other attempts to edit the tree.
You, in almost every case, want this function if the Device you're editing is already linked into the Device tree.
add filters to avoid the need to filter in callbacks
add a way to end iteration early
Definition at line 107 of file Device.cc.
References root().
Referenced by DeviceHashTree::fill(), ProcFs::initialise(), UsbPnP::reprobeDevices(), PciDevicesFile::resync(), and MountService::serve().
Here is the caller graph for this function:
|
static |
|
staticprivate |
Actual do-er for foreach (does not take lock).
|
staticprivate |
| Device * Device::getChild | ( | size_t | n | ) |
Returns the n'th child of this device, or 0 if the device has less than n children.
Retrieves the n'th child of this device.
Definition at line 139 of file Device.cc.
References m_Children.
Referenced by IsaAtaController::irq(), PciAtaController::irq(), AtaController::maskDiskInterrupts(), searchByVendorIdInternal(), ScsiController::shutdownDiskCaches(), and AtaController::stopDiskDma().
Here is the caller graph for this function:
|
inlinevirtual |
Returns the interrupt number of the device.
Definition at line 271 of file Device.h.
Referenced by AtaDisk::doRead(), AtaDisk::initialise(), PciAtaController::irq(), Ne2k::Ne2k(), PciAtaController::PciAtaController(), Pic::registerHardPciIrqHandler(), Pic::registerPciIrqHandler(), and AtaDisk::writePageBuffer().
Here is the caller graph for this function:
|
virtual |
Stores the device's name in str.
Reimplemented in AhciDisk, NvmeDisk, Xhci, VirtioBlkDisk, VirtioGpu, VirtioNet, Nic3C90x, AtaDisk, IsaAtaController, PciAtaController, Dm9601, ScsiDisk, Ehci, Ohci, Uhci, UsbHubDevice, DiskImage, Ib700Watchdog, Ne2k, Ps2Mouse, VmwareGraphics, FileDisk, UsbDeviceContainer, Bus, Controller, Disk, Display, Network, Ps2Controller, Partition, and AtaController.
Definition at line 130 of file Device.cc.
Referenced by DeviceHashTree::getHash().
Here is the caller graph for this function:| size_t Device::getNumChildren | ( | ) |
Returns the number of children this device has.
Retrieves the number of children of this device.
Definition at line 143 of file Device.cc.
References Vector< T >::count(), and m_Children.
Referenced by IsaAtaController::irq(), PciAtaController::irq(), AtaController::maskDiskInterrupts(), searchByVendorIdInternal(), ScsiController::shutdownDiskCaches(), and AtaController::stopDiskDma().
Here is the caller graph for this function:
|
inline |
Returns the device's parent
Definition at line 166 of file Device.h.
Referenced by Partition::flush(), Partition::getBlockSize(), Partition::getNativeBlockSize(), Dm9601::initialiseDriver(), Ne2k::Ne2k(), Partition::pin(), Partition::read(), Partition::readInto(), Partition::readIntoBatch(), Partition::readView(), Partition::retireCachePage(), MountService::serve(), Partition::sync(), Partition::syncAll(), Partition::syncData(), Partition::syncPages(), Partition::unpin(), Partition::write(), Partition::writeFromBatch(), and Partition::zero().
Here is the caller graph for this function:
|
inline |
Returns the PCI bus position for this device.
Definition at line 236 of file Device.h.
Referenced by DeviceHashTree::getHash().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
Returns the PCI device ID.
Definition at line 228 of file Device.h.
Referenced by PciAtaController::PciAtaController().
Here is the caller graph for this function:
|
inline |
Returns the PCI device position on the bus for this device.
Definition at line 240 of file Device.h.
Referenced by DeviceHashTree::getHash().
Here is the caller graph for this function:
|
inline |
Returns the PCI Function number for this device.
Definition at line 244 of file Device.h.
Referenced by DeviceHashTree::getHash().
Here is the caller graph for this function:
|
inline |
Returns the PCI programming interface.
Definition at line 232 of file Device.h.
Referenced by PciAtaController::PciAtaController().
Here is the caller graph for this function:
|
inline |
|
inline |
Returns the PCI vendor ID.
Definition at line 224 of file Device.h.
Referenced by searchByVendorIdInternal().
Here is the caller graph for this function:
|
inlinevirtual |
|
inlinevirtual |
Returns the (abstract) type of the device.
Reimplemented in UsbDeviceContainer, UsbHub, Bus, Controller, Disk, Display, and Network.
Definition at line 178 of file Device.h.
Referenced by UsbHub::disconnectAllDevices(), UsbPnP::doProbe(), UsbPnP::probeDevice(), and UsbPnP::reprobeDevices().
Here is the caller graph for this function:| void Device::removeChild | ( | Device * | d | ) |
Attempts to find the device d, if found, removes it.
Removes the given Device from this device's child list.
Definition at line 157 of file Device.cc.
References Vector< T >::begin(), Vector< T >::end(), Vector< T >::erase(), and m_Children.
| void Device::removeChild | ( | size_t | n | ) |
Removes the n'th child from this device. The result is undefined if the device does not have n children.
Removes the n'th child of this device.
Definition at line 147 of file Device.cc.
References Vector< T >::begin(), Vector< T >::end(), Vector< T >::erase(), and m_Children.
Referenced by UsbHub::disconnectAllDevices(), and UsbDeviceContainer::replaceUsbDevice().
Here is the caller graph for this function:
|
private |
Destroys all IoBases in this class. Called from the constructor Device(Device*).
Definition at line 121 of file Device.cc.
References m_Addresses, and Device::Address::m_Io.
Referenced by Device().
Here is the caller graph for this function:Attempts to find the device src in this device's children. If found, it replaces 'src' with 'dest' in this device's child list, so that 'src' is no longer a child of this device, and 'dest' is, in the same position that 'src' was.
Definition at line 166 of file Device.cc.
References Vector< T >::begin(), Vector< T >::end(), and m_Children.
|
inlinestaticprotected |
Retrieves the root device. Still needs to be public for RawFs...
Definition at line 344 of file Device.h.
Referenced by addToRoot(), foreach(), searchByVendorId(), and searchByVendorIdInternal().
Here is the caller graph for this function:
|
static |
Search functions
Definition at line 177 of file Device.cc.
References root(), and searchByVendorIdInternal().
|
staticprivate |
Do-ers for search functions.
Definition at line 232 of file Device.cc.
References getChild(), getNumChildren(), getPciVendorId(), root(), and searchByVendorIdInternal().
Referenced by searchByVendorId(), and searchByVendorIdInternal().
Here is the caller graph for this function:
|
inlinevirtual |
Sets the interrupt number of the device.
Definition at line 276 of file Device.h.
Referenced by Pc::initialiseDeviceTree().
Here is the caller graph for this function:
|
inline |
Sets the device's parent.
Definition at line 170 of file Device.h.
Referenced by UsbHub::disconnectAllDevices(), Pc::initialiseDeviceTree(), and UsbDeviceContainer::replaceUsbDevice().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Sets the specific type of the device, in string form.
Definition at line 187 of file Device.h.
Referenced by Pc::initialiseDeviceTree(), Ne2k::Ne2k(), Nic3C90x::Nic3C90x(), and PciAtaController::PciAtaController().
Here is the caller graph for this function:
|
inline |
|
static |
Allows callbacks shared by tree traversals and runtime discovery to preserve the caller's existing tree lock without acquiring it twice.
Definition at line 40 of file Device.cc.
References Mutex::isOwnedByCurrentThread(), and m_TreeLock.
Referenced by PartitionService::serve().
Here is the caller graph for this function:The address of this device, in its parent's address space.
Definition at line 349 of file Device.h.
Referenced by Device(), Ne2k::Ne2k(), Nic3C90x::Nic3C90x(), and removeIoMappings().
The children of this device.
Definition at line 351 of file Device.h.
Referenced by addChild(), Device(), UsbHub::disconnectAllDevices(), getChild(), getNumChildren(), PciAtaController::PciAtaController(), removeChild(), removeChild(), and replaceChild().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
This device's parent.
Definition at line 353 of file Device.h.
Referenced by ScsiDisk::align(), Device(), ScsiDisk::flushCachePage(), ScsiDisk::initialise(), AtaDisk::initialise(), ScsiDisk::pin(), ScsiDisk::readIntoBatch(), ScsiDisk::retireCachePage(), ScsiDisk::retireCachePageCallback(), ScsiDisk::sync(), ScsiDisk::syncAll(), ScsiDisk::syncData(), ScsiDisk::syncPages(), ScsiDisk::write(), ScsiDisk::writeFromBatch(), and ScsiDisk::zero().
|
protected |
|
staticprotected |
|
protected |
|
staticprotected |
Lock to manage access to the device tree.
Definition at line 383 of file Device.h.
Referenced by treeLockHeldByCurrentThread().