mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
Kernel: Simplify scanning BIOS/EBDA and MP parser initialization
Add a MappedROM::find_chunk_starting_with() helper since that's a very common usage pattern in clients of this code. Also convert MultiProcessorParser from a persistent singleton object to a temporary object constructed via a failable factory function.
This commit is contained in:
parent
84b7bc5e14
commit
4b847810bf
8 changed files with 47 additions and 101 deletions
|
@ -39,6 +39,15 @@ struct MappedROM {
|
|||
size_t offset { 0 };
|
||||
PhysicalAddress paddr;
|
||||
|
||||
Optional<PhysicalAddress> find_chunk_starting_with(StringView prefix, size_t chunk_size) const
|
||||
{
|
||||
for (auto* candidate = base(); candidate < end(); candidate += chunk_size) {
|
||||
if (!__builtin_memcmp(prefix.characters_without_null_termination(), candidate, prefix.length()))
|
||||
return paddr_of(candidate);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
PhysicalAddress paddr_of(const u8* ptr) const { return paddr.offset(ptr - this->base()); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue