blob: 04e21714ceb400bb816af2e75bad25dc7eade486 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtrVector.h>
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/Region.h>
namespace Kernel {
class HPETComparator;
struct HPETRegistersBlock;
class HPET {
public:
static bool initialized();
static bool test_and_initialize();
static bool check_for_exisiting_periodic_timers();
static HPET& the();
u64 frequency() const { return m_frequency; }
u64 raw_counter_ticks_to_ns(u64) const;
u64 ns_to_raw_counter_ticks(u64) const;
const NonnullRefPtrVector<HPETComparator>& comparators() const { return m_comparators; }
void disable(const HPETComparator&);
void enable(const HPETComparator&);
void update_periodic_comparator_value();
void update_non_periodic_comparator_value(const HPETComparator& comparator);
void set_comparator_irq_vector(u8 comparator_number, u8 irq_vector);
void enable_periodic_interrupt(const HPETComparator& comparator);
void disable_periodic_interrupt(const HPETComparator& comparator);
u64 update_time(u64& seconds_since_boot, u32& ticks_this_second, bool query_only);
u64 read_main_counter_unsafe() const;
u64 read_main_counter() const;
Vector<unsigned> capable_interrupt_numbers(u8 comparator_number);
Vector<unsigned> capable_interrupt_numbers(const HPETComparator&);
private:
const HPETRegistersBlock& registers() const;
HPETRegistersBlock& registers();
void global_disable();
void global_enable();
bool is_periodic_capable(u8 comparator_number) const;
bool is_64bit_capable(u8 comparator_number) const;
void set_comparators_to_optimal_interrupt_state(size_t timers_count);
u64 nanoseconds_to_raw_ticks() const;
PhysicalAddress find_acpi_hpet_registers_block();
explicit HPET(PhysicalAddress acpi_hpet);
PhysicalAddress m_physical_acpi_hpet_table;
PhysicalAddress m_physical_acpi_hpet_registers;
OwnPtr<Region> m_hpet_mmio_region;
u64 m_main_counter_last_read { 0 };
u64 m_main_counter_drift { 0 };
u32 m_32bit_main_counter_wraps { 0 };
u16 m_vendor_id;
u16 m_minimum_tick;
u64 m_frequency;
u8 m_revision_id;
bool m_main_counter_64bits : 1;
bool legacy_replacement_route_capable : 1;
NonnullRefPtrVector<HPETComparator> m_comparators;
};
}
|