mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
Kernel: Use NonnullRefPtrVector for HardwareTimer and HPETComparator
This commit is contained in:
parent
03c91fce74
commit
c24304dca3
4 changed files with 12 additions and 24 deletions
|
@ -161,11 +161,6 @@ bool HPET::check_for_exisiting_periodic_timers()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FixedArray<RefPtr<HPETComparator>>& HPET::comparators() const
|
|
||||||
{
|
|
||||||
return m_comparators;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HPET::global_disable()
|
void HPET::global_disable()
|
||||||
{
|
{
|
||||||
auto* registers_block = (volatile HPETRegistersBlock*)m_hpet_mmio_region->vaddr().offset(m_physical_acpi_hpet_registers.offset_in_page()).as_ptr();
|
auto* registers_block = (volatile HPETRegistersBlock*)m_hpet_mmio_region->vaddr().offset(m_physical_acpi_hpet_registers.offset_in_page()).as_ptr();
|
||||||
|
@ -331,7 +326,6 @@ HPET::HPET(PhysicalAddress acpi_hpet)
|
||||||
size_t timers_count = ((registers_block->raw_capabilites.reg >> 8) & 0x1f) + 1;
|
size_t timers_count = ((registers_block->raw_capabilites.reg >> 8) & 0x1f) + 1;
|
||||||
klog() << "HPET: Timers count - " << timers_count;
|
klog() << "HPET: Timers count - " << timers_count;
|
||||||
ASSERT(timers_count >= 2);
|
ASSERT(timers_count >= 2);
|
||||||
m_comparators.resize(timers_count);
|
|
||||||
auto* capabilities_register = (const volatile HPETCapabilityRegister*)®isters_block->raw_capabilites.reg;
|
auto* capabilities_register = (const volatile HPETCapabilityRegister*)®isters_block->raw_capabilites.reg;
|
||||||
|
|
||||||
global_disable();
|
global_disable();
|
||||||
|
@ -345,15 +339,8 @@ HPET::HPET(PhysicalAddress acpi_hpet)
|
||||||
if (registers_block->raw_capabilites.reg & (u32)HPETFlags::Attributes::LegacyReplacementRouteCapable)
|
if (registers_block->raw_capabilites.reg & (u32)HPETFlags::Attributes::LegacyReplacementRouteCapable)
|
||||||
registers_block->configuration.reg |= (u32)HPETFlags::Configuration::LegacyReplacementRoute;
|
registers_block->configuration.reg |= (u32)HPETFlags::Configuration::LegacyReplacementRoute;
|
||||||
|
|
||||||
for (size_t index = 0; index < m_comparators.size(); index++) {
|
m_comparators.append(HPETComparator::create(0, 0, is_periodic_capable(0)));
|
||||||
bool periodic = is_periodic_capable(index);
|
m_comparators.append(HPETComparator::create(1, 8, is_periodic_capable(1)));
|
||||||
if (index == 0) {
|
|
||||||
m_comparators[index] = HPETComparator::create(index, 0, periodic);
|
|
||||||
}
|
|
||||||
if (index == 1) {
|
|
||||||
m_comparators[index] = HPETComparator::create(index, 8, periodic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
global_enable();
|
global_enable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FixedArray.h>
|
#include <AK/FixedArray.h>
|
||||||
|
#include <AK/NonnullRefPtrVector.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <Kernel/Time/HPET.h>
|
|
||||||
#include <Kernel/VM/Region.h>
|
#include <Kernel/VM/Region.h>
|
||||||
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
u64 main_counter_value() const;
|
u64 main_counter_value() const;
|
||||||
u64 frequency() const;
|
u64 frequency() const;
|
||||||
|
|
||||||
const FixedArray<RefPtr<HPETComparator>>& comparators() const;
|
const NonnullRefPtrVector<HPETComparator>& comparators() const { return m_comparators; }
|
||||||
void disable(const HPETComparator&);
|
void disable(const HPETComparator&);
|
||||||
void enable(const HPETComparator&);
|
void enable(const HPETComparator&);
|
||||||
|
|
||||||
|
@ -85,6 +85,6 @@ private:
|
||||||
bool counter_is_64_bit_capable : 1;
|
bool counter_is_64_bit_capable : 1;
|
||||||
bool legacy_replacement_route_capable : 1;
|
bool legacy_replacement_route_capable : 1;
|
||||||
|
|
||||||
FixedArray<RefPtr<HPETComparator>> m_comparators;
|
NonnullRefPtrVector<HPETComparator> m_comparators;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,10 +121,10 @@ Vector<HardwareTimer*> TimeManagement::scan_and_initialize_periodic_timers()
|
||||||
dbg() << "Time: Scanning for periodic timers";
|
dbg() << "Time: Scanning for periodic timers";
|
||||||
Vector<HardwareTimer*> timers;
|
Vector<HardwareTimer*> timers;
|
||||||
for (auto& hardware_timer : m_hardware_timers) {
|
for (auto& hardware_timer : m_hardware_timers) {
|
||||||
if (hardware_timer && hardware_timer->is_periodic_capable()) {
|
if (hardware_timer.is_periodic_capable()) {
|
||||||
timers.append(hardware_timer);
|
timers.append(&hardware_timer);
|
||||||
if (should_enable)
|
if (should_enable)
|
||||||
hardware_timer->set_periodic();
|
hardware_timer.set_periodic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return timers;
|
return timers;
|
||||||
|
@ -135,8 +135,8 @@ Vector<HardwareTimer*> TimeManagement::scan_for_non_periodic_timers()
|
||||||
dbg() << "Time: Scanning for non-periodic timers";
|
dbg() << "Time: Scanning for non-periodic timers";
|
||||||
Vector<HardwareTimer*> timers;
|
Vector<HardwareTimer*> timers;
|
||||||
for (auto& hardware_timer : m_hardware_timers) {
|
for (auto& hardware_timer : m_hardware_timers) {
|
||||||
if (hardware_timer && !hardware_timer->is_periodic_capable())
|
if (!hardware_timer.is_periodic_capable())
|
||||||
timers.append(hardware_timer);
|
timers.append(&hardware_timer);
|
||||||
}
|
}
|
||||||
return timers;
|
return timers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/FixedArray.h>
|
#include <AK/FixedArray.h>
|
||||||
|
#include <AK/NonnullRefPtrVector.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
@ -65,7 +66,7 @@ private:
|
||||||
bool probe_and_set_non_legacy_hardware_timers();
|
bool probe_and_set_non_legacy_hardware_timers();
|
||||||
Vector<HardwareTimer*> scan_and_initialize_periodic_timers();
|
Vector<HardwareTimer*> scan_and_initialize_periodic_timers();
|
||||||
Vector<HardwareTimer*> scan_for_non_periodic_timers();
|
Vector<HardwareTimer*> scan_for_non_periodic_timers();
|
||||||
Vector<RefPtr<HardwareTimer>> m_hardware_timers;
|
NonnullRefPtrVector<HardwareTimer> m_hardware_timers;
|
||||||
|
|
||||||
u32 m_ticks_this_second { 0 };
|
u32 m_ticks_this_second { 0 };
|
||||||
u32 m_seconds_since_boot { 0 };
|
u32 m_seconds_since_boot { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue