summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-29 10:51:53 +0200
committerGitHub <noreply@github.com>2025-05-29 10:51:53 +0200
commit5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (patch)
treecb17577bcdc9714c97a84ce417a075117097f146 /dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc
parentd608230b1350b064ceb01e6572519b108f6139b0 (diff)
parent3167f59dbb401d6a79b1524537e04218baf49ee3 (diff)
Merge pull request #32 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc')
-rw-r--r--dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc57
1 files changed, 4 insertions, 53 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc b/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc
index 2fb6ad4c..f9749946 100644
--- a/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc
+++ b/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc
@@ -8,56 +8,10 @@
#include <FSKit/NeFS.h>
#include <HALKit/AMD64/Processor.h>
-#define kPITDefaultTicks (1000U)
-
namespace Kernel::HAL {
namespace Detail {
STATIC ::Kernel::Detail::AMD64::InterruptDescriptorAMD64 kInterruptVectorTable[kKernelIdtSize] =
{};
-
- STATIC ATTRIBUTE(unused) void hal_set_irq_mask(UInt8 irql) [[maybe_unused]] {
- UInt16 port;
- UInt8 value;
-
- if (irql < 8) {
- port = kPICData;
- } else {
- port = kPIC2Data;
- irql -= 8;
- }
-
- value = rt_in8(port) | (1 << irql);
- rt_out8(port, value);
- }
-
- STATIC void hal_clear_irq_mask(UInt8 irql) [[maybe_unused]] {
- UInt16 port;
- UInt8 value;
-
- if (irql < 8) {
- port = kPICData;
- } else {
- port = kPIC2Data;
- irql -= 8;
- }
-
- value = rt_in8(port) & ~(1 << irql);
- rt_out8(port, value);
- }
-
- STATIC Void hal_enable_pit(UInt16 ticks) noexcept {
- if (ticks == 0) ticks = kPITDefaultTicks;
-
- // Configure PIT to receieve scheduler interrupts.
-
- UInt16 kPITCommDivisor = kPITFrequency / ticks; // 100 Hz.
-
- HAL::rt_out8(kPITControlPort, 0x36); // Command to PIT
- HAL::rt_out8(kPITChannel0Port, kPITCommDivisor & 0xFF); // Send low byte
- HAL::rt_out8(kPITChannel0Port, (kPITCommDivisor >> 8) & 0xFF); // Send high byte
-
- hal_clear_irq_mask(32);
- }
} // namespace Detail
/// @brief Loads the provided Global Descriptor Table.
@@ -70,11 +24,10 @@ Void GDTLoader::Load(Register64& gdt) {
}
Void IDTLoader::Load(Register64& idt) {
+#ifndef __NE_MODULAR_KERNEL_COMPONENTS__
rt_cli();
- const Int16 kPITTickForScheduler = kPITDefaultTicks;
-
- volatile ::Kernel::UIntPtr** ptr_ivt = (volatile ::Kernel::UIntPtr**) idt.Base;
+ volatile UIntPtr** ptr_ivt = (volatile UIntPtr**) idt.Base;
for (SizeT idt_indx = 0; idt_indx < kKernelIdtSize; ++idt_indx) {
Detail::kInterruptVectorTable[idt_indx].Selector = kIDTSelector;
@@ -92,13 +45,11 @@ Void IDTLoader::Load(Register64& idt) {
idt.Base = (UIntPtr) &Detail::kInterruptVectorTable[0];
idt.Limit = sizeof(::Kernel::Detail::AMD64::InterruptDescriptorAMD64) * (kKernelIdtSize);
- Detail::hal_enable_pit(kPITTickForScheduler);
-
-#ifndef __NE_MODULAR_KERNEL_COMPONENTS__
hal_load_idt(idt);
+ rt_sti();
#endif // __NE_MODULAR_KERNEL_COMPONENTS__
- rt_sti();
+ return;
}
/// @brief Loads the Global Descriptor Table into the CPU.