The Pedigree Project 0.1
MappingIndex.h
1/* Copyright (c) 2026, Pedigree Developers. */
2
3#ifndef KERNEL_PROCESSOR_HOSTED_MAPPINGINDEX_H
4#define KERNEL_PROCESSOR_HOSTED_MAPPINGINDEX_H
5
6#include <stddef.h>
7#include <stdint.h>
8
10 public:
11 static constexpr size_t Missing = ~size_t(0);
12
15
17 HostedMappingIndex& operator=(const HostedMappingIndex&) = delete;
19 HostedMappingIndex& operator=(HostedMappingIndex&&) = delete;
20
21 size_t lookup(uintptr_t page) const;
22 bool reserveForInsert();
23 void insert(uintptr_t page, size_t slot);
24 void erase(uintptr_t page);
25 void clear();
26
27 private:
28 enum State : uint8_t { Empty, Occupied, Deleted };
29 struct Entry {
30 uintptr_t page;
31 size_t slot;
32 State state;
33 };
34
35 static size_t hash(uintptr_t page);
36
37 Entry* m_Entries;
38 size_t m_Capacity;
39 size_t m_Live;
40 size_t m_Used;
41};
42
43#endif