Skip to content

Commit 3a071e0

Browse files
committed
Kernel/Memory: Allow getting a pointer to a matching chunk in MappedROM
1 parent a5f4645 commit 3a071e0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Kernel/Memory/MappedROM.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,24 @@ class MappedROM {
2121
size_t offset { 0 };
2222
PhysicalAddress paddr;
2323

24-
Optional<PhysicalAddress> find_chunk_starting_with(StringView prefix, size_t chunk_size) const
24+
u8 const* pointer_to_chunk_starting_with(StringView prefix, size_t chunk_size) const
2525
{
2626
auto prefix_length = prefix.length();
2727
if (size < prefix_length)
2828
return {};
2929
for (auto* candidate = base(); candidate <= end() - prefix_length; candidate += chunk_size) {
3030
if (!__builtin_memcmp(prefix.characters_without_null_termination(), candidate, prefix.length()))
31-
return paddr_of(candidate);
31+
return candidate;
3232
}
33-
return {};
33+
return nullptr;
34+
}
35+
36+
Optional<PhysicalAddress> find_chunk_starting_with(StringView prefix, size_t chunk_size) const
37+
{
38+
auto result = pointer_to_chunk_starting_with(prefix, chunk_size);
39+
if (!result)
40+
return {};
41+
return paddr_of(result);
3442
}
3543

3644
PhysicalAddress paddr_of(u8 const* ptr) const { return paddr.offset(ptr - this->base()); }

0 commit comments

Comments
 (0)