summaryrefslogtreecommitdiffhomepage
path: root/Private/Drivers
diff options
context:
space:
mode:
Diffstat (limited to 'Private/Drivers')
-rw-r--r--Private/Drivers/AHCI/Defines.hxx2
-rw-r--r--Private/Drivers/PS2/Mouse.hxx80
-rw-r--r--Private/Drivers/PS2/PS2KernelMouse.hxx104
3 files changed, 105 insertions, 81 deletions
diff --git a/Private/Drivers/AHCI/Defines.hxx b/Private/Drivers/AHCI/Defines.hxx
index 00510c3e..f3b93660 100644
--- a/Private/Drivers/AHCI/Defines.hxx
+++ b/Private/Drivers/AHCI/Defines.hxx
@@ -230,7 +230,7 @@ typedef struct HbaPort final {
HCore::UInt32 serr; // 0x30, SATA error (SCR1:SError)
HCore::UInt32 sact; // 0x34, SATA active (SCR3:SActive)
HCore::UInt32 ci; // 0x38, command issue
- HCore::UInt32 sntf; // 0x3C, SATA notification (SCR4:SNotification)
+ HCore::UInt32 sntf; // 0x20, SATA notification (SCR4:SNotification)
HCore::UInt32 fbs; // 0x40, FIS-based switch control
HCore::UInt32 reserved1[11]; // 0x44 ~ 0x6F, Reserved
HCore::UInt32 vendor[4]; // 0x70 ~ 0x7F, vendor specific
diff --git a/Private/Drivers/PS2/Mouse.hxx b/Private/Drivers/PS2/Mouse.hxx
deleted file mode 100644
index 30fb5620..00000000
--- a/Private/Drivers/PS2/Mouse.hxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
- File: Mouse.hxx
- Purpose: PS/2 mouse.
-
- Revision History:
-
- 03/02/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-#include <ArchKit/ArchKit.hpp>
-#include <CompilerKit/CompilerKit.hxx>
-#include <NewKit/Defines.hpp>
-
-namespace HCore {
-
-class PS2Mouse final {
- public:
- explicit PS2Mouse() {
- HAL::Out8(0x64, 0xa8);
- this->Wait();
- auto stat = HAL::In8(0x60);
-
- stat |= 0b10;
-
- this->Wait();
-
- HAL::Out8(0x64, 0x60);
-
- this->Wait();
-
- HAL::Out8(0x60, stat);
-
- this->Write(0xF6);
- this->Read();
-
- this->Write(0xF4);
- this->Read();
- }
-
- ~PS2Mouse() = default;
-
- HCORE_COPY_DEFAULT(PS2Mouse);
-
- struct PS2MouseTraits final {
- Int16 Status;
- Int32 X, Y;
- };
-
- Boolean operator>>(PS2MouseTraits& stat) noexcept { return true; }
-
- private:
- Bool Wait() noexcept {
- while (!(HAL::In8(0x64) & 1)) {
- asm("pause");
- } // wait until we can read
-
- // return the ack bit.
- return HAL::In8(0x64);
- }
-
- Void Write(UInt8 port) {
- this->Wait();
- HAL::Out8(0x64, 0xD4);
- this->Wait();
-
- HAL::Out8(0x60, port);
- }
-
- UInt8 Read() {
- this->Wait();
- return HAL::In8(0x60);
- }
-};
-} // namespace HCore
diff --git a/Private/Drivers/PS2/PS2KernelMouse.hxx b/Private/Drivers/PS2/PS2KernelMouse.hxx
new file mode 100644
index 00000000..ecfc0459
--- /dev/null
+++ b/Private/Drivers/PS2/PS2KernelMouse.hxx
@@ -0,0 +1,104 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: PS2KernelMouse.hxx
+ Purpose: PS/2 mouse.
+
+ Revision History:
+
+ 03/02/24: Added file (amlel)
+
+------------------------------------------- */
+
+#pragma once
+
+#include <ArchKit/ArchKit.hpp>
+#include <CompilerKit/CompilerKit.hxx>
+#include <NewKit/Defines.hpp>
+
+namespace HCore {
+/// @brief Enabled for kernel purposes, kernel mouse.
+class PS2KernelMouse final {
+ public:
+ explicit PS2KernelMouse() = default;
+ ~PS2KernelMouse() = default;
+
+ HCORE_COPY_DEFAULT(PS2KernelMouse);
+
+ public:
+ Void Init() noexcept {
+ HCore::kcout << "HCoreKrnl.exe: Enabling PS/2 mouse...\r\n";
+
+ this->Write(0xFF);
+
+ this->Wait();
+
+ HAL::Out8(0x64, 0x20);
+
+ this->Wait();
+
+ auto status = HAL::In8(0x60);
+
+ status |= 0x12;
+
+ this->Wait();
+
+ HAL::Out8(0x64, 0x60);
+
+ this->Wait();
+
+ HAL::Out8(0x60, status);
+
+ HCore::kcout << "HCoreKrnl.exe: PS/2 mouse is OK.\r\n";
+ }
+
+ private:
+ Bool WaitInput() noexcept {
+ UInt64 timeout = 100000;
+
+ while (timeout) {
+ if ((HAL::In8(0x64) & 0x1)) {
+ HCore::kcout << "HCoreKrnl.exe: Wait: OK\r\n";
+ return true;
+ }
+
+ --timeout;
+ } // wait until we can read
+
+ HCore::kcout << "HCoreKrnl.exe: Wait: Timeout\r\n";
+ // return the ack bit.
+ return false;
+ }
+
+ Bool Wait() noexcept {
+ UInt64 timeout = 100000;
+
+ while (timeout) {
+ if ((HAL::In8(0x64) & 0b10) == 0) {
+ HCore::kcout << "HCoreKrnl.exe: Wait: OK\r\n";
+ return true;
+ }
+
+ --timeout;
+ } // wait until we can read
+
+ HCore::kcout << "HCoreKrnl.exe: Wait: Timeout\r\n";
+ // return the ack bit.
+ return false;
+ }
+
+ Void Write(UInt8 val) {
+ this->Wait();
+ HAL::Out8(0x64, 0xD4);
+ this->Wait();
+
+ HAL::Out8(0x60, val);
+ }
+
+ UInt8 Read() {
+ this->WaitInput();
+ return HAL::In8(0x60);
+ }
+};
+} // namespace HCore