20 #include "pedigree/kernel/machine/DeviceHashTree.h" 21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/machine/Device.h" 23 #include "pedigree/kernel/utilities/StaticString.h" 24 #include "pedigree/kernel/utilities/sha1/sha1.h" 25 #include "pedigree/kernel/utilities/utility.h" 29 DeviceHashTree::DeviceHashTree() : m_bInitialised(false), m_DeviceTree()
33 DeviceHashTree::~DeviceHashTree()
40 DeviceHashTree::instance().add(p);
49 m_bInitialised =
true;
54 size_t hash = getHash(p);
55 if (m_DeviceTree.lookup(hash))
61 NOTICE(
"Device hash for `" << dump <<
"' is: " << hash <<
".");
62 m_DeviceTree.insert(hash, p);
70 return m_DeviceTree.lookup(hash);
80 StringToUnsignedLong(static_cast<const char *>(hash), 0, 16);
81 return m_DeviceTree.lookup(inthash);
104 theString.append(bus);
106 theString.append(dev);
108 theString.append(func);
112 mySha1.Input(static_cast<const char *>(theString), theString.length());
113 unsigned int digest[5];
114 mySha1.Result(digest);
The device is the root of the device tree.
virtual void dump(String &str)
uint32_t getPciDevicePosition()
virtual void getName(String &str)
size_t getHash(Device *p)
uint32_t getPciBusPosition()
uint32_t getPciFunctionNumber()
Device * getDevice(uint32_t hash)
static void foreach(Callback callback, Device *root=0)
void fill(Device *root=0)