mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOr
This mostly just moved the problem, as a lot of the callers are not capable of propagating the errors themselves, but it's a step in the right direction.
This commit is contained in:
parent
e2e5d4da16
commit
fb3e46e930
14 changed files with 80 additions and 57 deletions
|
@ -133,10 +133,14 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize()
|
|||
return false;
|
||||
dmesgln("HPET @ {}", hpet_table.value());
|
||||
|
||||
auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value());
|
||||
auto sdt_or_error = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value());
|
||||
if (sdt_or_error.is_error()) {
|
||||
dbgln("Failed mapping HPET table");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note: HPET is only usable from System Memory
|
||||
VERIFY(sdt->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory);
|
||||
VERIFY(sdt_or_error.value()->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory);
|
||||
|
||||
if (TimeManagement::is_hpet_periodic_mode_allowed()) {
|
||||
if (!check_for_exisiting_periodic_timers()) {
|
||||
|
@ -154,9 +158,15 @@ UNMAP_AFTER_INIT bool HPET::check_for_exisiting_periodic_timers()
|
|||
if (!hpet_table.has_value())
|
||||
return false;
|
||||
|
||||
auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value());
|
||||
auto sdt_or_error = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value());
|
||||
if (sdt_or_error.is_error())
|
||||
return false;
|
||||
auto sdt = sdt_or_error.release_value();
|
||||
VERIFY(sdt->event_timer_block.address_space == 0);
|
||||
auto registers = Memory::map_typed<HPETRegistersBlock>(PhysicalAddress(sdt->event_timer_block.address));
|
||||
auto registers_or_error = Memory::map_typed<HPETRegistersBlock>(PhysicalAddress(sdt->event_timer_block.address));
|
||||
if (registers_or_error.is_error())
|
||||
return false;
|
||||
auto registers = registers_or_error.release_value();
|
||||
|
||||
size_t timers_count = ((registers->capabilities.attributes >> 8) & 0x1f) + 1;
|
||||
for (size_t index = 0; index < timers_count; index++) {
|
||||
|
@ -393,7 +403,7 @@ void HPET::set_comparators_to_optimal_interrupt_state(size_t)
|
|||
|
||||
PhysicalAddress HPET::find_acpi_hpet_registers_block()
|
||||
{
|
||||
auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
|
||||
auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table).release_value_but_fixme_should_propagate_errors();
|
||||
VERIFY(sdt->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory);
|
||||
return PhysicalAddress(sdt->event_timer_block.address);
|
||||
}
|
||||
|
@ -426,7 +436,7 @@ UNMAP_AFTER_INIT HPET::HPET(PhysicalAddress acpi_hpet)
|
|||
{
|
||||
s_hpet = this; // Make available as soon as possible so that IRQs can use it
|
||||
|
||||
auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
|
||||
auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table).release_value_but_fixme_should_propagate_errors();
|
||||
m_vendor_id = sdt->pci_vendor_id;
|
||||
m_minimum_tick = sdt->mininum_clock_tick;
|
||||
dmesgln("HPET: Minimum clock tick - {}", m_minimum_tick);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue