Skip to content

Commit

Permalink
Merge branch 'master' into mod-test
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaTy authored Dec 18, 2022
2 parents 2fd971e + e30c313 commit cee5886
Show file tree
Hide file tree
Showing 137 changed files with 1,606 additions and 2,788 deletions.
19 changes: 9 additions & 10 deletions Tests/Kernels/GraphicTest/Kernel.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions source/Cosmos.Common/StringHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public static string GetNumberString(float aValue)
int hexVal = BitConverter.ToInt32(singleBytes, 0);

/* Let's extract the parts that compose our single: sign, exponent and mantissa */
bool isNeg = (hexVal >> 31) != 0;
int exp = ((hexVal >> 23) & 0xFF);
bool isNeg = hexVal >> 31 != 0;
int exp = (hexVal >> 23) & 0xFF;
ulong mantissa = (ulong)(hexVal & 0x7FFFFF);

ulong intPart = 0, fracPart = 0;
Expand Down Expand Up @@ -256,7 +256,7 @@ public static string GetNumberString(float aValue)
}
else
{
fracPart = (mantissa & 0xFFFFFF) >> (-(exp + 1));
fracPart = (mantissa & 0xFFFFFF) >> -(exp + 1);
}

string result = "";
Expand Down Expand Up @@ -289,7 +289,7 @@ public static string GetNumberString(float aValue)
}
fracPart = (fracPart << 3) + (fracPart << 1);
char remain = (char)((fracPart >> 24) + '0');
if ((remain > '5') && (result[result.Length - 1] > '0'))
if (remain > '5' && result[result.Length - 1] > '0')
{
char[] answer = result.ToCharArray();
int digitPos = answer.Length - 1;
Expand Down Expand Up @@ -341,7 +341,7 @@ public static string GetNumberString(double aValue)
mDebugger.SendInternal(hexVal);

/* Let's extract the parts that compose our double: sign, exponent and mantissa */
bool isNeg = (hexVal >> 63) != 0;
bool isNeg = hexVal >> 63 != 0;
int exp = (int)((hexVal >> 52) & 0x07FF);
ulong mantissa = (ulong)(hexVal & 0x0FFFFFFFFFFFFF);
mDebugger.SendInternal("isNeg = ");
Expand Down Expand Up @@ -395,7 +395,7 @@ public static string GetNumberString(double aValue)
}
else
{
fracPart = (mantissa & 0x1FFFFFFFFFFFFF) >> (-(exp + 1));
fracPart = (mantissa & 0x1FFFFFFFFFFFFF) >> -(exp + 1);
}

string result = "";
Expand Down Expand Up @@ -427,7 +427,7 @@ public static string GetNumberString(double aValue)
}
fracPart = (fracPart << 3) + (fracPart << 1);
char remain = (char)((fracPart >> 53) + '0');
if ((remain > '5') && (result[result.Length - 1] > '0'))
if (remain > '5' && result[result.Length - 1] > '0')
{
char[] answer = result.ToCharArray();
int digitPos = answer.Length - 1;
Expand Down
50 changes: 25 additions & 25 deletions source/Cosmos.Core/ACPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public unsafe struct RSDPtr
/// <summary>
/// IO port.
/// </summary>
private static IOPort smiIO, pm1aIO, pm1bIO;
private static ushort smiIO, pm1aIO, pm1bIO;

// ACPI variables
/// <summary>
Expand Down Expand Up @@ -191,10 +191,10 @@ static bool Check_RSD(uint address)

for (int i = 0; i < 20; i++)
{
sum += *(check++);
sum += *check++;
}

return (sum == 0);
return sum == 0;
}

/// <summary>
Expand Down Expand Up @@ -227,11 +227,11 @@ public static void Shutdown()
Init();
}

pm1aIO.Word = (ushort)(SLP_TYPa | SLP_EN);
IOPort.Write16(pm1aIO, (ushort)(SLP_TYPa | SLP_EN));

if (PM1b_CNT != null)
{
pm1bIO.Word = (ushort)(SLP_TYPb | SLP_EN);
IOPort.Write16(pm1bIO, (ushort)(SLP_TYPb | SLP_EN));
}

CPU.Halt();
Expand All @@ -258,17 +258,17 @@ private static bool Init()

for (int i = 19; i >= 16; i--)
{
addr += (*(ptr + i));
addr = (i == 16) ? addr : addr << 8;
addr += *(ptr + i);
addr = i == 16 ? addr : addr << 8;
}

ptr = (byte*)addr;
ptr += 4; addr = 0;

for (int i = 3; i >= 0; i--)
{
addr += (*(ptr + i));
addr = (i == 0) ? addr : addr << 8;
addr += *(ptr + i);
addr = i == 0 ? addr : addr << 8;
}

int length = addr;
Expand All @@ -286,8 +286,8 @@ private static bool Init()
{
for (int i = 3; i >= 0; i--)
{
addr += (*(ptr + i));
addr = (i == 0) ? addr : addr << 8;
addr += *(ptr + i);
addr = i == 0 ? addr : addr << 8;
}

yeuse = (byte*)addr;
Expand Down Expand Up @@ -317,13 +317,13 @@ private static bool Init()
{
S5Addr++;
}
SLP_TYPa = (short)(*(S5Addr) << 10);
SLP_TYPa = (short)(*S5Addr << 10);
S5Addr++;
if (*S5Addr == 0x0A)
{
S5Addr++;
}
SLP_TYPb = (short)(*(S5Addr) << 10);
SLP_TYPb = (short)(*S5Addr << 10);
SMI_CMD = facpget(1);
ACPI_ENABLE = facpbget(0);
ACPI_DISABLE = facpbget(1);
Expand All @@ -332,9 +332,9 @@ private static bool Init()
PM1_CNT_LEN = facpbget(3);
SLP_EN = 1 << 13;

smiIO = new IOPort((ushort)SMI_CMD);
pm1aIO = new IOPort((ushort)PM1a_CNT);
pm1bIO = new IOPort((ushort)PM1b_CNT);
smiIO = (ushort)SMI_CMD;
pm1aIO = (ushort)PM1a_CNT;
pm1bIO = (ushort)PM1b_CNT;

return true;
}
Expand All @@ -352,15 +352,15 @@ private static bool Init()
/// </summary>
public static void Enable()
{
smiIO = new IOPort(ACPI_ENABLE);
smiIO = ACPI_ENABLE;
}

/// <summary>
/// Disable ACPI.
/// </summary>
public static void Disable()
{
smiIO = new IOPort(ACPI_DISABLE);
smiIO = ACPI_DISABLE;
}

/// <summary>
Expand All @@ -380,7 +380,7 @@ private static unsafe uint RSDPAddress()
}
}

uint ebda_address = *((uint*)0x040E);
uint ebda_address = *(uint*)0x040E;
ebda_address = (ebda_address * 0x10) & 0x000fffff;

for (uint addr = ebda_address; addr < ebda_address + 1024; addr += 4)
Expand Down Expand Up @@ -435,7 +435,7 @@ private static unsafe uint RSDPAddress()
/// <summary>
/// Get data from the FACP table.
/// </summary>
/// <param name="number">Index number of the data to get.
/// <param name="number">Index number of the data to get.
/// <list type="bullet">
/// <item>0 - ACPI ENABLE</item>
/// <item>1 - ACPI DISABLE</item>
Expand All @@ -462,7 +462,7 @@ private static byte facpbget(int number)
/// <summary>
/// Get pointer to the data on the FACP.
/// </summary>
/// <param name="number">Index number of the data to get.
/// <param name="number">Index number of the data to get.
/// <list type="bullet">
/// <item>0 - DSDT</item>
/// <item>1 - SMI CMD</item>
Expand All @@ -477,13 +477,13 @@ private static byte facpbget(int number)
switch (number)
{
case 0:
return (int*)*((int*)(Facp + 40));
return (int*)*(int*)(Facp + 40);
case 1:
return (int*)*((int*)(Facp + 48));
return (int*)*(int*)(Facp + 48);
case 2:
return (int*)*((int*)(Facp + 64));
return (int*)*(int*)(Facp + 64);
case 3:
return (int*)*((int*)(Facp + 68));
return (int*)*(int*)(Facp + 68);
default:
return null;
}
Expand Down
48 changes: 0 additions & 48 deletions source/Cosmos.Core/BaseIOGroups.cs

This file was deleted.

50 changes: 25 additions & 25 deletions source/Cosmos.Core/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public static void Reboot()
// Disable all interrupts
DisableInterrupts();

var myPort = new IOPort(0x64);
while ((myPort.Byte & 0x02) != 0)
const ushort myPort = 0x64;
while ((IOPort.Read8(myPort) & 0x02) != 0)
{
}
myPort.Byte = 0xFE;
IOPort.Write8(myPort, 0xFE);
Halt(); // If it didn't work, Halt the CPU
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public static void EnableInterrupts()
DoEnableInterrupts();
}

/// <summary>
/// <summary>
/// Returns if the interrupts were actually enabled.
/// </summary>
/// <returns>bool value.</returns>
Expand Down Expand Up @@ -161,11 +161,11 @@ public static string GetCPUVendorName()
s += (char)((ebx >> 8) & 0xff);
s += (char)((ebx >> 16) & 0xff);
s += (char)(ebx >> 24);
s += (char)((edx) & 0xff);
s += (char)(edx & 0xff);
s += (char)((edx >> 8) & 0xff);
s += (char)((edx >> 16) & 0xff);
s += (char)(edx >> 24);
s += (char)((ecx) & 0xff);
s += (char)(ecx & 0xff);
s += (char)((ecx >> 8) & 0xff);
s += (char)((ecx >> 16) & 0xff);
s += (char)(ecx >> 24);
Expand All @@ -177,7 +177,7 @@ public static string GetCPUVendorName()
}

/// <summary>
/// Get CPU up time.
/// Get CPU up time.
/// </summary>
/// <returns>ulong value.</returns>
/// <exception cref="NotImplementedException">Thrown on fatal error, contact support.</exception>
Expand Down Expand Up @@ -293,22 +293,22 @@ public static string GetCPUBrandString()
for (uint i = 0; i < 3; i++)
{
ReadCPUID(0x80000002 + i, ref eax, ref ebx, ref ecx, ref edx);
s[(i * 16) + 0] = (eax % 256);
s[(i * 16) + 1] = ((eax >> 8) % 256);
s[(i * 16) + 2] = ((eax >> 16) % 256);
s[(i * 16) + 3] = ((eax >> 24) % 256);
s[(i * 16) + 4] = (ebx % 256);
s[(i * 16) + 5] = ((ebx >> 8) % 256);
s[(i * 16) + 6] = ((ebx >> 16) % 256);
s[(i * 16) + 7] = ((ebx >> 24) % 256);
s[(i * 16) + 8] = (ecx % 256);
s[(i * 16) + 9] = ((ecx >> 8) % 256);
s[(i * 16) + 10] = ((ecx >> 16) % 256);
s[(i * 16) + 11] = ((ecx >> 24) % 256);
s[(i * 16) + 12] = (edx % 256);
s[(i * 16) + 13] = ((edx >> 8) % 256);
s[(i * 16) + 14] = ((edx >> 16) % 256);
s[(i * 16) + 15] = ((edx >> 24) % 256);
s[i * 16 + 0] = eax % 256;
s[i * 16 + 1] = (eax >> 8) % 256;
s[i * 16 + 2] = (eax >> 16) % 256;
s[i * 16 + 3] = (eax >> 24) % 256;
s[i * 16 + 4] = ebx % 256;
s[i * 16 + 5] = (ebx >> 8) % 256;
s[i * 16 + 6] = (ebx >> 16) % 256;
s[i * 16 + 7] = (ebx >> 24) % 256;
s[i * 16 + 8] = ecx % 256;
s[i * 16 + 9] = (ecx >> 8) % 256;
s[i * 16 + 10] = (ecx >> 16) % 256;
s[i * 16 + 11] = (ecx >> 24) % 256;
s[i * 16 + 12] = edx % 256;
s[i * 16 + 13] = (edx >> 8) % 256;
s[i * 16 + 14] = (edx >> 16) % 256;
s[i * 16 + 15] = (edx >> 24) % 256;
}
for (int i = 0; i < s.Length; i++)
{
Expand Down Expand Up @@ -382,7 +382,7 @@ public static unsafe MemoryMapBlock[] GetMemoryMap()
uint entrySize = Multiboot2.MemoryMap->EntrySize;

int counter = 0;
while ((uint)currentMap < ((uint)baseMap + totalSize) && counter < 64)
while ((uint)currentMap < (uint)baseMap + totalSize && counter < 64)
{
rawMap[counter++] = *currentMap;
currentMap = (RawMemoryMapBlock*)((uint)currentMap + entrySize);
Expand Down Expand Up @@ -431,7 +431,7 @@ public static unsafe MemoryMapBlock[] GetMemoryMap()

int counter = 0;
ulong bestSize = 0;
while ((uint)currentMap < ((uint)baseMap + totalSize) && counter < 64)
while ((uint)currentMap < (uint)baseMap + totalSize && counter < 64)
{
currentMap = (RawMemoryMapBlock*)((uint)currentMap + entrySize);

Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.Core/GCImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public unsafe static class GCImplementation
private static ulong memLength = 0;
private static bool StartedMemoryManager = false;
/// <summary>
///
///
/// Acquire lock. Not implemented.
/// </summary>
/// <exception cref="NotImplementedException">Thrown always.</exception>
Expand Down Expand Up @@ -96,7 +96,7 @@ public static unsafe void Init()
{
memPtr = (byte*)CPU.GetEndOfKernel() + 1024;
memPtr += RAT.PageSize - (uint)memPtr % RAT.PageSize;
memLength = (128 * 1024 * 1024);
memLength = 128 * 1024 * 1024;
}
RAT.Init(memPtr, (uint)memLength);
}
Expand Down
5 changes: 0 additions & 5 deletions source/Cosmos.Core/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ public static class Global
/// </summary>
public static readonly Debugger mDebugger = new Debugger("Core", "Global");

/// <summary>
/// Base IO gruops.
/// </summary>
public static BaseIOGroups BaseIOGroups = new BaseIOGroups();

// These are used by Bootstrap.. but also called to signal end of interrupt etc...
// Need to chagne this.. I dont like how this is.. maybe isolate or split into to classes... one for boostrap one for
// later user
Expand Down
Loading

0 comments on commit cee5886

Please sign in to comment.