blob: e547d982c90ddfce7fdf43c859cc56b22138fe5a (
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
|
/* -------------------------------------------
Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
#include <HALKit/AMD64/Processor.h>
#include <modules/ACPI/ACPIFactoryInterface.h>
#define kIOAPICRegVal (4)
#define kIOAPICRegReg (0)
namespace Kernel::HAL {
APICController::APICController(VoidPtr base) : fApic(base) {}
/// @brief Read from APIC controller.
/// @param reg register.
UInt32 APICController::Read(UInt32 reg) noexcept {
MUST_PASS(this->fApic);
UInt32 volatile* io_apic = (UInt32 volatile*) this->fApic;
io_apic[kIOAPICRegReg] = (reg & 0xFF);
return io_apic[kIOAPICRegVal];
}
/// @brief Write to APIC controller.
/// @param reg register.
/// @param value value.
Void APICController::Write(UInt32 reg, UInt32 value) noexcept {
MUST_PASS(this->fApic);
UInt32 volatile* io_apic = (UInt32 volatile*) this->fApic;
io_apic[kIOAPICRegReg] = (reg & 0xFF);
io_apic[kIOAPICRegVal] = value;
}
} // namespace Kernel::HAL
|