From 818c18479270d919775c04180be71826c0d2d891 Mon Sep 17 00:00:00 2001
From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498>
Date: Sun, 22 Jun 2008 01:36:39 +0000
Subject: [PATCH] Keyboard cleanup
---
.../Cosmos.Hardware/Cosmos.Hardware.csproj | 4 +-
source/Cosmos/Cosmos.Hardware/Global.cs | 7 +++-
.../{KeyboardOld.cs => Keyboard.cs} | 41 +++++++++++++++++--
source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs | 26 ------------
.../Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs | 22 ----------
source/Cosmos/Cosmos.Kernel.Plugs/Console.cs | 2 +-
6 files changed, 45 insertions(+), 57 deletions(-)
rename source/Cosmos/Cosmos.Hardware/{KeyboardOld.cs => Keyboard.cs} (79%)
delete mode 100644 source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs
delete mode 100644 source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs
diff --git a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
index 30bb1d6ef..cc186586e 100644
--- a/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
+++ b/source/Cosmos/Cosmos.Hardware/Cosmos.Hardware.csproj
@@ -56,7 +56,7 @@
-
+
@@ -80,7 +80,6 @@
-
@@ -89,7 +88,6 @@
-
diff --git a/source/Cosmos/Cosmos.Hardware/Global.cs b/source/Cosmos/Cosmos.Hardware/Global.cs
index d6991b2a8..99c10ea8b 100644
--- a/source/Cosmos/Cosmos.Hardware/Global.cs
+++ b/source/Cosmos/Cosmos.Hardware/Global.cs
@@ -20,8 +20,11 @@ namespace Cosmos.Hardware {
PC.Bus.PCIBus.Init();
- Device.Add(new PC.Bus.CPU.Keyboard());
- KeyboardOld.Initialize();
+ // Old
+ Keyboard.Initialize();
+ // New
+ //Device.Add(new PC.Bus.CPU.Keyboard());
+
Cosmos.Hardware.PC.Bus.PCIBus.Init();
}
diff --git a/source/Cosmos/Cosmos.Hardware/KeyboardOld.cs b/source/Cosmos/Cosmos.Hardware/Keyboard.cs
similarity index 79%
rename from source/Cosmos/Cosmos.Hardware/KeyboardOld.cs
rename to source/Cosmos/Cosmos.Hardware/Keyboard.cs
index 052e253f3..5c77455e0 100644
--- a/source/Cosmos/Cosmos.Hardware/KeyboardOld.cs
+++ b/source/Cosmos/Cosmos.Hardware/Keyboard.cs
@@ -2,11 +2,46 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
-using HW = Cosmos.Hardware;
namespace Cosmos.Hardware {
- public class KeyboardOld {
- private class KeyMapping {
+
+ //public class Keyboard : Cosmos.Hardware.SerialDevice {
+ // public Keyboard() {
+ // mType = DeviceType.Keyboard;
+ // }
+
+ // public void InterruptReceived() {
+ // byte xByte = Kernel.CPUBus.Read8(0x60);
+ // ByteReceived(xByte);
+ // }
+ // public override string Name {
+ // get {
+ // return "Keyboard";
+ // }
+ // }
+ //}
+
+ public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased);
+ public class Keyboard : Hardware {
+ private static HandleKeyboardDelegate mHandleKeyboardKey;
+ public static void Initialize(HandleKeyboardDelegate aHandleKeyboardKeyDelegate) {
+ mHandleKeyboardKey = aHandleKeyboardKeyDelegate;
+ }
+
+ public static void HandleKeyboardInterrupt() {
+ if (mHandleKeyboardKey != null) {
+ byte xScanCode = IOReadByte(0x60);
+ bool xReleased = (xScanCode & 0x80) == 0x80;
+ if (xReleased) {
+ xScanCode = (byte)(xScanCode ^ 0x80);
+ }
+ mHandleKeyboardKey(xScanCode, xReleased);
+ } else {
+ DebugUtil.SendError("Keyboard", "No Keyboard Handler found!");
+ }
+ }
+
+ private class KeyMapping {
public uint Scancode;
public char Value;
public KeyMapping(uint aScanCode, char aValue) {
diff --git a/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs b/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs
deleted file mode 100644
index 045197caf..000000000
--- a/source/Cosmos/Cosmos.Hardware/Old/Keyboard.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Cosmos.Hardware {
- public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased);
- public class Keyboard: Hardware {
- private static HandleKeyboardDelegate mHandleKeyboardKey;
- public static void Initialize(HandleKeyboardDelegate aHandleKeyboardKeyDelegate) {
- mHandleKeyboardKey = aHandleKeyboardKeyDelegate;
- }
-
- public static void HandleKeyboardInterrupt() {
- if (mHandleKeyboardKey != null) {
- byte xScanCode = IOReadByte(0x60);
- bool xReleased = (xScanCode & 0x80) == 0x80;
- if (xReleased) {
- xScanCode = (byte)(xScanCode ^ 0x80);
- }
- mHandleKeyboardKey(xScanCode, xReleased);
- } else {
- DebugUtil.SendError("Keyboard", "No Keyboard Handler found!");
- }
- }
- }
-}
diff --git a/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs b/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs
deleted file mode 100644
index b786a6f5a..000000000
--- a/source/Cosmos/Cosmos.Hardware/PC/Bus/Keyboard.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Cosmos.Hardware.PC.Bus.CPU {
- public class Keyboard : Cosmos.Hardware.SerialDevice {
- public Keyboard() {
- mType = DeviceType.Keyboard;
- }
-
- public void InterruptReceived() {
- byte xByte = Kernel.CPUBus.Read8(0x60);
- ByteReceived(xByte);
- }
- public override string Name {
- get {
- return "Keyboard";
- }
- }
- }
-}
diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs
index cd81c54fc..7a94171e4 100644
--- a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs
+++ b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs
@@ -116,7 +116,7 @@ namespace Cosmos.Kernel.Plugs {
// HACK: convert this to "while ((current = Keyboard.ReadChar()) != '\n') {"
// MTW: SOmehow an invalid opcode exception is occurring.
while (true) {
- current = Cosmos.Hardware.KeyboardOld.ReadChar();
+ current = Cosmos.Hardware.Keyboard.ReadChar();
if (current == '\n') {
break;
} else if (current == '\u0968') { // Backspace