20#include "pedigree/kernel/Log.h"
21#include "pedigree/kernel/machine/Device.h"
22#include "pedigree/kernel/machine/DeviceHashTree.h"
23#include "pedigree/kernel/utilities/Cord.h"
24#include "pedigree/kernel/utilities/StaticString.h"
25#include "pedigree/kernel/utilities/sha1/sha1.h"
26#include "pedigree/kernel/utilities/utility.h"
30DeviceHashTree::DeviceHashTree() : m_bInitialised(false), m_DeviceTree() {}
32DeviceHashTree::~DeviceHashTree() {}
36 DeviceHashTree::instance().
add(p);
44 m_bInitialised =
true;
49 if (m_DeviceTree.
lookup(hash))
55 NOTICE(
"Device hash for `" << dump <<
"' is: " << hash <<
".");
56 m_DeviceTree.
insert(hash, p);
63 return m_DeviceTree.
lookup(hash);
70 uint32_t inthash = StringToUnsignedLong(
static_cast<const char*
>(hash), 0, 16);
71 return m_DeviceTree.
lookup(inthash);
93 hashBuild.append(name);
94 hashBuild.append(
"-");
95 hashBuild.append(dump);
96 hashBuild.append(
"-");
97 hashBuild.append(busStr);
98 hashBuild.append(
".");
99 hashBuild.append(devStr);
100 hashBuild.append(
".");
101 hashBuild.append(funcStr);
105 for (
auto it = hashBuild.segbegin(); it != hashBuild.segend(); ++it) {
106 mySha1.Input(it.ptr(), it.length());
108 unsigned int digest[5];
109 mySha1.Result(digest);
void fill(Device *root=0)
Device * getDevice(uint32_t hash)
size_t getHash(Device *p)
uint32_t getPciFunctionNumber()
uint32_t getPciDevicePosition()
static void foreach(Callback callback, Device *root=0)
virtual void dump(String &str)
@ Root
The device is the root of the device tree.
virtual void getName(String &str)
uint32_t getPciBusPosition()
E lookup(const K &key) const
void insert(const K &key, const E &value)