diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-17 10:59:07 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-17 11:00:09 +0100 |
| commit | 9898520f721220a2af4be59fd92e8ad8afcd4287 (patch) | |
| tree | 35662af54535ccc07366b1a3a554f6296e76f4ce /Private/HALKit | |
| parent | 45548d516ddf5e88bf80940365d151e1bd69c29f (diff) | |
Unstable: See below.
These changes are related to the current ticket regarding AHCI support.
This commit is just to upstream changes from local.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/HALKit')
| -rw-r--r-- | Private/HALKit/AMD64/HalACPIManager.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalKernelMouse.cxx | 180 |
3 files changed, 94 insertions, 90 deletions
diff --git a/Private/HALKit/AMD64/HalACPIManager.cpp b/Private/HALKit/AMD64/HalACPIManager.cpp index 945ae6d8..b73dd996 100644 --- a/Private/HALKit/AMD64/HalACPIManager.cpp +++ b/Private/HALKit/AMD64/HalACPIManager.cpp @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <Drivers/ACPI/ACPIManager.hxx> +#include <Builtins/ACPI/ACPIManager.hxx> #include <HALKit/AMD64/Processor.hpp> #include <NewKit/String.hpp> diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index 0727aff0..edb821b9 100644 --- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <Drivers/ACPI/ACPIManager.hxx> +#include <Builtins/ACPI/ACPIManager.hxx> #include <HALKit/AMD64/Processor.hpp> /////////////////////////////////////////////////////////////////////////////////////// diff --git a/Private/HALKit/AMD64/HalKernelMouse.cxx b/Private/HALKit/AMD64/HalKernelMouse.cxx index bce6272f..2427ff2d 100644 --- a/Private/HALKit/AMD64/HalKernelMouse.cxx +++ b/Private/HALKit/AMD64/HalKernelMouse.cxx @@ -1,139 +1,143 @@ -#include <KernelKit/Rsrc/Util.hxx> +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Builtins/PS2/PS2MouseInterface.hxx> +#include <KernelKit/Framebuffer.hpp> #include <KernelKit/Rsrc/Cursor.rsrc> -#include <Drivers/PS2/PS2KernelMouse.hxx> +#include <KernelKit/Rsrc/Util.hxx> #include <NewKit/Defines.hpp> -#include <KernelKit/Framebuffer.hpp> STATIC HCore::Int32 kPrevX = 0; STATIC HCore::Int32 kPrevY = 0; STATIC HCore::Int32 kX = 0; STATIC HCore::Int32 kY = 0; STATIC HCore::Int32 kMouseCycle = 0; -STATIC HCore::PS2KernelMouse kMousePS2; +STATIC HCore::PS2MouseInterface kMousePS2; STATIC HCore::Int32 kMousePacket[4]; STATIC HCore::Boolean kMousePacketReady = false; -#define kPS2LeftButton 0b00000001 -#define kPS2MiddleButton 0b00000010 -#define kPS2RightButton 0b00000100 +#define kPS2LeftButton 0b00000001 +#define kPS2MiddleButton 0b00000010 +#define kPS2RightButton 0b00000100 + +#define kPS2XSign 0b00010000 +#define kPS2YSign 0b00100000 +#define kPS2XOverflow 0b01000000 +#define kPS2YOverflow 0b10000000 -#define kPS2XSign 0b00010000 -#define kPS2YSign 0b00100000 -#define kPS2XOverflow 0b01000000 -#define kPS2YOverflow 0b10000000 +using namespace HCore; -EXTERN_C void _hal_mouse_handler() -{ +/// @brief Interrupt handler for the mouse. +/// @return +EXTERN_C Void _hal_mouse_handler() { #ifdef __DEBUG__ - HCore::UInt8 data = HCore::HAL::In8(0x60); + HCore::UInt8 data = HCore::HAL::In8(0x60); - switch (kMouseCycle) - { - case 0: - { - if (kMousePacketReady) break; - if ((data & 0b00001000) == 0) break; + switch (kMouseCycle) { + case 0: { + if (kMousePacketReady) break; + if ((data & 0b00001000) == 0) break; - kMousePacket[0] = data; - ++kMouseCycle; + kMousePacket[0] = data; + ++kMouseCycle; - break; + break; } - case 1: - { - if (kMousePacketReady) break; + case 1: { + if (kMousePacketReady) break; - kMousePacket[1] = data; - ++kMouseCycle; + kMousePacket[1] = data; + ++kMouseCycle; - break; + break; } - case 2: - { - if (kMousePacketReady) break; + case 2: { + if (kMousePacketReady) break; - kMousePacket[2] = data; - ++kMouseCycle; - kMousePacketReady = true; - kMouseCycle = 0; + kMousePacket[2] = data; + ++kMouseCycle; + kMousePacketReady = true; + kMouseCycle = 0; - break; + break; } default: - break; - } + break; + } - // Notify PIC controller that we're done with it's interrupt. + // Notify PIC controller that we're done with it's interrupt. - HCore::HAL::Out8(0x20, 0x20); - HCore::HAL::Out8(0xA0, 0x20); + HCore::HAL::Out8(0x20, 0x20); + HCore::HAL::Out8(0xA0, 0x20); #endif } -EXTERN_C void _hal_mouse_draw() -{ +/// @brief Draws the kernel's mouse. +/// @return void +EXTERN_C Void _hal_mouse_draw() { #ifdef __DEBUG__ - if (!kMousePacketReady) return; - - bool xNeg, yNeg, xOvf, yOvf; + if (!kMousePacketReady) return; - xNeg = (kMousePacket[0] & kPS2XSign); - yNeg = (kMousePacket[0] & kPS2YSign); - - xOvf = (kMousePacket[0] & kPS2XOverflow); - yOvf = (kMousePacket[0] & kPS2YOverflow); + bool xNeg, yNeg, xOvf, yOvf; - kX += xNeg ? (256 - kMousePacket[1]) : (256 - (-kMousePacket[1])); - kY += yNeg ? (256 - kMousePacket[2]) : (256 - (-kMousePacket[2]));; + xNeg = (kMousePacket[0] & kPS2XSign); + yNeg = (kMousePacket[0] & kPS2YSign); - if (xOvf) { - kX += xNeg ? 255 : -255; - } + xOvf = (kMousePacket[0] & kPS2XOverflow); + yOvf = (kMousePacket[0] & kPS2YOverflow); - if (yOvf) { - kY += yNeg ? 255 : -255; - } + kX += xNeg ? (256 - kMousePacket[1]) : (256 - (-kMousePacket[1])); + kY += yNeg ? (256 - kMousePacket[2]) : (256 - (-kMousePacket[2])); + ; - if (kY > kHandoverHeader->f_GOP.f_Height) - { - return; - } + if (xOvf) { + kX += xNeg ? 255 : -255; + } - if (kX > kHandoverHeader->f_GOP.f_Width) - { - return; - } + if (yOvf) { + kY += yNeg ? 255 : -255; + } + + if (kY > kHandoverHeader->f_GOP.f_Height) { + return; + } + + if (kX > kHandoverHeader->f_GOP.f_Width) { + return; + } - KeClearZone(POINTER_HEIGHT, POINTER_WIDTH, kPrevX, kPrevY); + KeClearZone(POINTER_HEIGHT, POINTER_WIDTH, kPrevX, kPrevY); - KeInitRsrc(); - KeDrawRsrc(Pointer, POINTER_HEIGHT, POINTER_WIDTH, kX, kY); - KeClearRsrc(); + KeInitRsrc(); + KeDrawRsrc(Pointer, POINTER_HEIGHT, POINTER_WIDTH, kX, kY); + KeClearRsrc(); - kPrevX = kMousePacket[1]; - kPrevY = kMousePacket[2]; + kPrevX = kMousePacket[1]; + kPrevY = kMousePacket[2]; - kMousePacketReady = false; + kMousePacketReady = false; #endif } /// @brief Inital kernel mouse initializer -/// @param -EXTERN_C void _hal_init_mouse(void) -{ +/// @param +EXTERN_C Void _hal_init_mouse(void) { #ifdef __DEBUG__ - kMousePS2.Init(); + kMousePS2.Init(); - auto pic1Port = 0x20; - auto pic2Port = 0xA0; + auto pic1Port = 0x20; + auto pic2Port = 0xA0; - auto mask = 1 << 12; - auto currentMask = HCore::HAL::In8(pic1Port + 1); - auto newMask = currentMask & ~mask; - HCore::HAL::Out8(pic1Port + 1, newMask); + auto mask = 1 << 12; + auto currentMask = HCore::HAL::In8(pic1Port + 1); + auto newMask = currentMask & ~mask; + HCore::HAL::Out8(pic1Port + 1, newMask); - currentMask = HCore::HAL::In8(pic2Port + 1); - newMask = currentMask & ~mask; - HCore::HAL::Out8(pic2Port + 1, newMask); + currentMask = HCore::HAL::In8(pic2Port + 1); + newMask = currentMask & ~mask; + HCore::HAL::Out8(pic2Port + 1, newMask); #endif }
\ No newline at end of file |
