Skip to content

Commit

Permalink
Renamed IO Ports, proper names from osdev and 8253/8254 documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Siaranite committed Apr 14, 2018
1 parent 1c4a40b commit 76c277d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions source/Cosmos.Core/IOGroup/PCSpeaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ namespace Cosmos.Core.IOGroup
{
public class PCSpeaker : IOGroup
{
public readonly IOPort Port61 = new IOPort(0x61);
public readonly IOPort Port43 = new IOPort(0x43);
public readonly IOPort Port42 = new IOPort(0x42);
// IO Port 61, channel 2 gate
public readonly IOPort Gate = new IOPort(0x61);
// These two ports are shared with the PIT, so names are the same
// IO Port 43
public readonly IOPort CommandRegister = new IOPort(0x43);
// IO Port 42
public readonly IOPort Channel2Data = new IOPort(0x42);
}
}
14 changes: 7 additions & 7 deletions source/Cosmos.HAL2/PCSpeaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class PCSpeaker

private static void EnableSound()
{
IO.Port61.Byte = (byte)(IO.Port61.Byte | 0x03);
IO.Gate.Byte = (byte)(IO.Gate.Byte | 0x03);
}
private static void DisableSound()
{
IO.Port61.Byte = (byte)(IO.Port61.Byte & ~3);
IO.Gate.Byte = (byte)(IO.Gate.Byte & ~3);
//IO.Port61.Byte = (byte)(IO.Port61.Byte | 0xFC);
}

Expand All @@ -41,13 +41,13 @@ public static void Beep(uint frequency)

uint divisor = 1193180 / frequency;
byte temp;
IO.Port43.Byte = 0xB6;
IO.Port42.Byte = (byte)(divisor & 0xFF);
IO.Port42.Byte = (byte)((divisor >> 8) & 0xFF);
temp = IO.Port61.Byte;
IO.CommandRegister.Byte = 0xB6;
IO.Channel2Data.Byte = (byte)(divisor & 0xFF);
IO.Channel2Data.Byte = (byte)((divisor >> 8) & 0xFF);
temp = IO.Gate.Byte;
if (temp != (temp | 3))
{
IO.Port61.Byte = (byte)(temp | 3);
IO.Gate.Byte = (byte)(temp | 3);
}
EnableSound();
}
Expand Down

0 comments on commit 76c277d

Please sign in to comment.