summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc')
-rw-r--r--src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc b/src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc
new file mode 100644
index 00000000..36a027a2
--- /dev/null
+++ b/src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc
@@ -0,0 +1,39 @@
+/* ========================================
+
+ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#include <HALKit/AMD64/Processor.h>
+#include <modules/ACPI/ACPIFactoryInterface.h>
+
+namespace Kernel::HAL {
+/***********************************************************************************/
+/// Constructors.
+/***********************************************************************************/
+LAPICDmaWrapper::LAPICDmaWrapper(VoidPtr base) : fApic(base) {}
+LAPICDmaWrapper::~LAPICDmaWrapper() = default;
+
+/***********************************************************************************/
+/// @brief Read from APIC controller.
+/// @param reg register.
+/***********************************************************************************/
+UInt32 LAPICDmaWrapper::Read(UInt16 reg) noexcept {
+ MUST_PASS(this->fApic);
+
+ UInt32 volatile* io_apic = (UInt32 volatile*) this->fApic;
+ return io_apic[reg];
+}
+
+/***********************************************************************************/
+/// @brief Write to APIC controller.
+/// @param reg register.
+/// @param value value.
+/***********************************************************************************/
+Void LAPICDmaWrapper::Write(UInt16 reg, UInt32 value) noexcept {
+ MUST_PASS(this->fApic);
+
+ UInt32 volatile* io_apic = (UInt32 volatile*) this->fApic;
+ io_apic[reg] = value;
+}
+} // namespace Kernel::HAL