20 #ifndef MACHINE_DEVICE_H 21 #define MACHINE_DEVICE_H 23 #include "pedigree/kernel/compiler.h" 24 #include "pedigree/kernel/processor/types.h" 25 #include "pedigree/kernel/utilities/String.h" 26 #include "pedigree/kernel/utilities/Vector.h" 28 #include "pedigree/kernel/LockGuard.h" 29 #include "pedigree/kernel/process/Mutex.h" 32 #include "pedigree/kernel/machine/openfirmware/OpenFirmware.h" 34 #include "pedigree/kernel/machine/Pci.h" 35 #include "pedigree/kernel/utilities/utility.h" 79 const String &n, uintptr_t a,
size_t s,
bool io,
size_t pad = 1);
83 map(
size_t forcedSize = 0,
bool bUser =
false,
84 bool bWriteCombine =
false,
bool bWriteThrough =
false);
140 static void foreach (Callback callback,
Device *root = 0);
141 template <
class F,
class... Args>
142 static void foreach (
143 pedigree_std::Callable<F> &callback,
Device * root, Args... args);
146 static void addToRoot(
Device *device);
160 virtual void getName(
String &str);
171 return m_SpecificType;
176 m_SpecificType = pedigree_std::move(str);
183 m_PciDevicePos = device;
184 m_PciFunctionNum = func;
189 uint8_t classCode, uint8_t subclassCode, uint16_t vendorId,
190 uint16_t deviceId, uint8_t progIf)
192 m_ClassCode = classCode;
193 m_SubclassCode = subclassCode;
194 m_VendorId = vendorId;
195 m_DeviceId = deviceId;
196 m_ProgInterface = progIf;
201 m_ConfigHeader = space;
206 return m_ConfigHeader;
216 return m_SubclassCode;
231 return m_ProgInterface;
241 return m_PciDevicePos;
246 return m_PciFunctionNum;
252 str =
"Abstract Device";
264 return m_InterruptNumber;
270 m_InterruptNumber = n;
275 void addChild(
Device *pDevice);
279 Device *getChild(
size_t n);
282 size_t getNumChildren();
286 void removeChild(
size_t n);
289 void removeChild(
Device *d);
298 static void searchByVendorId(
299 uint16_t vendorId,
void (*callback)(
Device *),
Device *root = 0);
300 static void searchByVendorIdAndDeviceId(
301 uint16_t vendorId, uint16_t deviceId,
void (*callback)(
Device *),
303 static void searchByClass(
304 uint16_t classCode,
void (*callback)(
Device *),
Device *root = 0);
305 static void searchByClassAndSubclass(
306 uint16_t classCode, uint16_t subclassCode,
void (*callback)(
Device *),
308 static void searchByClassSubclassAndProgInterface(
309 uint16_t classCode, uint16_t subclassCode, uint8_t progInterface,
314 OFHandle getOFHandle()
319 void setOFHandle(OFHandle h)
326 static void foreachInternal(Callback callback,
Device *root);
327 template <
class F,
class... Args>
328 static void foreachInternal(
329 pedigree_std::Callable<F> &callback,
Device *root, Args... args);
331 static void searchByVendorIdInternal(
332 uint16_t vendorId,
void (*callback)(
Device *),
Device *root);
333 static void searchByVendorIdAndDeviceIdInternal(
334 uint16_t vendorId, uint16_t deviceId,
void (*callback)(
Device *),
336 static void searchByClassInternal(
337 uint16_t classCode,
void (*callback)(
Device *),
Device *root);
338 static void searchByClassAndSubclassInternal(
339 uint16_t classCode, uint16_t subclassCode,
void (*callback)(
Device *),
341 static void searchByClassSubclassAndProgInterfaceInternal(
342 uint16_t classCode, uint16_t subclassCode, uint8_t progInterface,
347 void removeIoMappings();
350 NOT_COPYABLE_OR_ASSIGNABLE(
Device);
402 template <
class F,
class... Args>
404 pedigree_std::Callable<F> &callback,
Device * root, Args... args)
415 foreachInternal(callback, root, args...);
418 template <
class F,
class... Args>
420 pedigree_std::Callable<F> &callback,
Device *root, Args... args)
426 Device *result = callback(child, args...);
434 else if (result != child)
443 foreachInternal(callback, child);
The device is the root of the device tree.
void removeChild(size_t n)
virtual void dump(String &str)
Device * getChild(size_t n)
uint8_t getPciSubclassCode()
uint32_t getPciDevicePosition()
A vector / dynamic array.
virtual String getSpecificType()
A disk device - a block device in UNIX terms.
virtual void setInterruptNumber(uintptr_t n)
virtual Vector< Address * > & addresses()
The device type is not covered by any other value.
PciBus::ConfigSpace m_ConfigHeader
PciBus::ConfigSpace getPciConfigHeader() const
Abstrace base class for hardware I/O capabilities.
void replaceChild(Device *src, Device *dest)
uint32_t getPciBusPosition()
virtual uintptr_t getInterruptNumber()
uint32_t getPciFunctionNumber()
Same as Generic, but for USB devices.
virtual void setSpecificType(String str)
uint8_t getPciProgInterface()
void setPciPosition(uint32_t bus, uint32_t device, uint32_t func)
A device that can play sounds.
uint32_t m_PciFunctionNum
uint16_t getPciDeviceId()
void setParent(Device *p)
static void foreach(Callback callback, Device *root=0)
uintptr_t m_InterruptNumber
Vector< Address * > m_Addresses
void setPciIdentifiers(uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
void setPciConfigHeader(const PciBus::ConfigSpace &space)
uint8_t getPciClassCode()
A keyboard-like human interface device.
Device * getParent() const
static void foreachInternal(Callback callback, Device *root)
Vector< Device * > m_Children
uint16_t getPciVendorId()