From eba8b7ddd0a455d9e49f32dcae712c5612c0093c Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 26 Jan 2024 22:26:48 +0100 Subject: Kernel: Major repository refactor. Rework the repo into Private and Public modules. Signed-off-by: Amlal El Mahrouss --- Private/HALKit/AMD64/Processor.cpp | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Private/HALKit/AMD64/Processor.cpp (limited to 'Private/HALKit/AMD64/Processor.cpp') diff --git a/Private/HALKit/AMD64/Processor.cpp b/Private/HALKit/AMD64/Processor.cpp new file mode 100644 index 00000000..13732381 --- /dev/null +++ b/Private/HALKit/AMD64/Processor.cpp @@ -0,0 +1,61 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include + +namespace hCore::HAL { + void out8(UInt16 port, UInt8 value) { + asm volatile("outb %%al, %1" : : "a"(value), "Nd"(port) : "memory"); + } + + void out16(UInt16 port, UInt16 value) { + asm volatile("outw %%ax, %1" : : "a"(value), "Nd"(port) : "memory"); + } + + void out32(UInt16 port, UInt32 value) { + asm volatile("outl %%eax, %1" : : "a"(value), "Nd"(port) : "memory"); + } + + UInt8 in8(UInt16 port) { + UInt8 value = 0UL; + asm volatile("inb %1, %%al" : "=a"(value) : "Nd"(port) : "memory"); + + return value; + } + + UInt16 in16(UInt16 port) { + UInt16 value = 0UL; + asm volatile("inw %1, %%ax" : "=a"(value) : "Nd"(port) : "memory"); + + return value; + } + + UInt32 in32(UInt16 port) { + UInt32 value = 0UL; + asm volatile("inl %1, %%eax" : "=a"(value) : "Nd"(port) : "memory"); + + return value; + } + + void rt_halt() { + asm volatile("hlt"); + } + + void rt_cli() { + asm volatile("cli"); + } + + void rt_sti() { + asm volatile("sti"); + } + + void rt_cld() { + asm volatile("cld"); + } +} // namespace hCore::HAL -- cgit v1.2.3