summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/HALKit/AMD64/HalAPICDmaWrapper.cc
blob: b262f2b3bf85bf677271d72c0662fef798b9c75b (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
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#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) {
  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) {
  MUST_PASS(this->fApic);

  UInt32 volatile* io_apic = (UInt32 volatile*) this->fApic;
  io_apic[reg]             = value;
}
}  // namespace Kernel::HAL