Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/CosmosOS/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleb committed Nov 29, 2016
2 parents a133012 + fee2ef5 commit c4d6219
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 78 deletions.
26 changes: 14 additions & 12 deletions Demos/Guess/Guess.Cosmos
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Profile>Bochs</Profile>
<Profile>VMware</Profile>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<Framework>MicrosoftNET</Framework>
Expand All @@ -26,13 +26,13 @@
<BuildTarget>PXE</BuildTarget>
<VMWareFlavor>Player</VMWareFlavor>
<StartCosmosGDB>False</StartCosmosGDB>
<VMwareEdition>Workstation</VMwareEdition>
<VMwareEdition>Player</VMwareEdition>
<VMwareDeploy>ISO</VMwareDeploy>
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
<Deployment>ISO</Deployment>
<Launch>Bochs</Launch>
<Launch>VMware</Launch>
<DebugEnabled>True</DebugEnabled>
<TraceAssemblies>User</TraceAssemblies>
<TraceAssemblies>All</TraceAssemblies>
<PXE_Deployment>PXE</PXE_Deployment>
<PXE_Launch>None</PXE_Launch>
<PXE_DebugEnabled>False</PXE_DebugEnabled>
Expand Down Expand Up @@ -82,7 +82,7 @@
<ISO_EnableGDB>False</ISO_EnableGDB>
<ISO_StartCosmosGDB>false</ISO_StartCosmosGDB>
<Name>Guess</Name>
<Description>Use Bochs emulator to deploy and debug.</Description>
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
<ISO_Name>User 001</ISO_Name>
<ISO_Description>Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system.</ISO_Description>
<USB_Name>Guess</USB_Name>
Expand Down Expand Up @@ -129,7 +129,7 @@
<ISO_VisualStudioDebugPort>Pipe: Cosmos\Serial</ISO_VisualStudioDebugPort>
<PXE_ShowLaunchConsole>False</PXE_ShowLaunchConsole>
<PXE_VisualStudioDebugPort>Pipe: Cosmos\Serial</PXE_VisualStudioDebugPort>
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
<StackCorruptionDetectionEnabled>False</StackCorruptionDetectionEnabled>
<VMware_StackCorruptionDetectionEnabled>False</VMware_StackCorruptionDetectionEnabled>
<Bochs_Name>Guess</Bochs_Name>
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
Expand Down Expand Up @@ -181,9 +181,10 @@
<USB_EnableBochsDebug>False</USB_EnableBochsDebug>
<StackCorruptionDetectionLevel>AllInstructions</StackCorruptionDetectionLevel>
<Bochs_StackCorruptionDetectionLevel>AllInstructions</Bochs_StackCorruptionDetectionLevel>
<VMware_StackCorruptionDetectionLevel>AllInstructions</VMware_StackCorruptionDetectionLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Profile>Bochs</Profile>
<Profile>VMware</Profile>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<Framework>MicrosoftNET</Framework>
Expand All @@ -194,13 +195,13 @@
<BuildTarget>PXE</BuildTarget>
<VMWareFlavor>Player</VMWareFlavor>
<StartCosmosGDB>False</StartCosmosGDB>
<VMwareEdition>Workstation</VMwareEdition>
<VMwareEdition>Player</VMwareEdition>
<VMwareDeploy>ISO</VMwareDeploy>
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
<Deployment>ISO</Deployment>
<Launch>Bochs</Launch>
<Launch>VMware</Launch>
<DebugEnabled>True</DebugEnabled>
<TraceAssemblies>User</TraceAssemblies>
<TraceAssemblies>All</TraceAssemblies>
<PXE_Deployment>PXE</PXE_Deployment>
<PXE_Launch>None</PXE_Launch>
<PXE_DebugEnabled>False</PXE_DebugEnabled>
Expand Down Expand Up @@ -250,7 +251,7 @@
<ISO_EnableGDB>False</ISO_EnableGDB>
<ISO_StartCosmosGDB>false</ISO_StartCosmosGDB>
<Name>Guess</Name>
<Description>Use Bochs emulator to deploy and debug.</Description>
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
<ISO_Name>User 001</ISO_Name>
<ISO_Description>Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system.</ISO_Description>
<USB_Name>Guess</USB_Name>
Expand Down Expand Up @@ -303,7 +304,7 @@
<VMware_ShowLaunchConsole>False</VMware_ShowLaunchConsole>
<ISO_ShowLaunchConsole>False</ISO_ShowLaunchConsole>
<PXE_ShowLaunchConsole>False</PXE_ShowLaunchConsole>
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
<StackCorruptionDetectionEnabled>False</StackCorruptionDetectionEnabled>
<VMware_StackCorruptionDetectionEnabled>False</VMware_StackCorruptionDetectionEnabled>
<Bochs_Name>Guess</Bochs_Name>
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
Expand Down Expand Up @@ -355,6 +356,7 @@
<USB_EnableBochsDebug>False</USB_EnableBochsDebug>
<StackCorruptionDetectionLevel>AllInstructions</StackCorruptionDetectionLevel>
<Bochs_StackCorruptionDetectionLevel>AllInstructions</Bochs_StackCorruptionDetectionLevel>
<VMware_StackCorruptionDetectionLevel>AllInstructions</VMware_StackCorruptionDetectionLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="Cosmos.bxrc">
Expand Down
4 changes: 2 additions & 2 deletions Demos/Guess/GuessOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace GuessKernel
public class GuessOS : Sys.Kernel
{
protected int mCount = 0;


protected int mMagicNo = 22;

public GuessOS()
{
// Didnt check if tickcount is working yet.. can change this later
//var xRandom = new Random(234243534);
//mMagicNo = xRandom.Next(1, 100);
}
}

protected override void BeforeRun()
{
Expand Down
2 changes: 1 addition & 1 deletion Demos/zMachine/Frotz.Net/source/zConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void Main(string[] args)
Frotz.os_.debug_mode = false;
//if (File.Exists("debug.log"))
// File.Delete("debug.log");
string fName = "";
string fName = args[0];
//while(!File.Exists(fName))
//{
// Console.WriteLine("Please type a path to a storyfile:");
Expand Down
5 changes: 4 additions & 1 deletion Docs/Kernel/Levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Things that Core implements and exposes to HAL:

Core also manages consumers of its services to avoid conflicts and security to prevent a specific driver from accessing "everything".

Notes:
https://github.com/joeduffy/slice.net

### 1 HAL (Hardware Abstraction Layer)

Summary: Hardware control
Expand Down Expand Up @@ -191,7 +194,7 @@ references.
## Graphics

0 IO/Memory access (Cosmos)
1 DirectX / Graphics Memory
1 DirectX / VESA / Graphics Memory
2 WinForms, WPF, Other UI, Canvas, JPG/PNG/GIF
3 Application

Expand Down
4 changes: 3 additions & 1 deletion Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;

using Cosmos.Common.Extensions;
using Cosmos.System.FileSystem;
using Cosmos.System.FileSystem.VFS;
Expand Down Expand Up @@ -728,9 +729,10 @@ private void TestFile()
/// </summary>
private void TestFileStream()
{
mDebugger.Send("START TEST: Filestream:");

using (var xFS = new FileStream(@"0:\Kudzu.txt", FileMode.Create))
{
mDebugger.Send("START TEST: Filestream:");
mDebugger.Send("Start writing");
var xStr = "Test FAT Write.";
byte[] xWriteBuff = xStr.GetUtf8Bytes(0, (uint)xStr.Length);
Expand Down
140 changes: 80 additions & 60 deletions source/Cosmos.Common/Extensions/ToHexString.cs
Original file line number Diff line number Diff line change
@@ -1,128 +1,148 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cosmos.Common.Extensions {
public static class ToHexString {

namespace Cosmos.Common.Extensions
{
public static class ToHexString
{
//TODO: Can add several more overloads for other numbertypes, with and without width argument.

public static string ToHex(this byte n) {
return ConvertToHex((UInt32)n, 2);
public static string ToHex(this byte n)
{
return ConvertToHex((uint)n, 2);
}
public static string ToHex(this byte n, int aWidth) {
return ConvertToHex((UInt32)n, aWidth);

public static string ToHex(this byte n, int aWidth)
{
return ConvertToHex((uint)n, aWidth);
}

public static string ToHex(this int n) {
return ConvertToHex((UInt32)n);
public static string ToHex(this int n)
{
return ConvertToHex((uint)n, 4);
}
public static string ToHex(this int n, int aWidth) {
return ConvertToHex((UInt32)n, aWidth);

public static string ToHex(this int n, int aWidth)
{
return ConvertToHex((uint)n, aWidth);
}

public static string ToHex(this UInt16 n) {
return ConvertToHex((UInt32)n, 4);
public static string ToHex(this ushort n)
{
return ConvertToHex((uint)n, 4);
}
public static string ToHex(this UInt16 n, int aWidth) {
return ConvertToHex((UInt32)n, aWidth);

public static string ToHex(this ushort n, int aWidth)
{
return ConvertToHex((uint)n, aWidth);
}

public static string ToHex(this uint aValue) {
public static string ToHex(this uint aValue)
{
return ConvertToHex(aValue, 8);
}
public static string ToHex(this uint aValue, int aWidth) {

public static string ToHex(this uint aValue, int aWidth)
{
return ConvertToHex(aValue, aWidth);
}

public static string ToHex(this ulong aValue) {
public static string ToHex(this ulong aValue)
{
return ConvertToHex(aValue).PadLeft(16, '0');
}
public static string ToHex(this ulong aValue, int aWidth) {

public static string ToHex(this ulong aValue, int aWidth)
{
return ConvertToHex(aValue).PadLeft(aWidth, '0');
}

private static string GetPrefix() {
private static string GetPrefix()
{
return "0x";
}

private static string GetSuffix() {
private static string GetSuffix()
{
return "h";
}

private static string ConvertToHex(UInt32 num) {
private static string ConvertToHex(uint num)
{
string xHex = string.Empty;

if (num == 0) {
xHex = "0";
} else {
while (num != 0) {
//Note; char is converted to string because Cosmos crashes when adding char and string. Frode, 7.june.
//TODO: Is this still true? I think Cosmos can handle char + string just fine now.
xHex = SingleDigitToHex((byte)(num & 0xf)) + xHex;
num = num >> 4;
}
if (num == 0)
{
xHex = "0";
}
else
{
while (num != 0)
{
xHex = DigitToHexChar((byte)(num & 0xf)) + xHex;
num = num >> 4;
}
}

return xHex;
}

private static string ConvertToHex(UInt32 aValue, int aWidth) {
private static string ConvertToHex(uint aValue, int aWidth)
{
return ConvertToHex(aValue).PadLeft(aWidth, '0');
}


private static string ConvertToHex(UInt64 num) {
private static string ConvertToHex(ulong num)
{
string xHex = string.Empty;

while (num != 0) {
while (num != 0)
{
//Note; char is converted to string because Cosmos crashes when adding char and string. Frode, 7.june.
xHex = SingleDigitToHex((byte)(num & 0xf)) + xHex;
xHex = DigitToHexChar((byte)(num & 0xf)) + xHex;
num = num >> 4;
}

return xHex;
}

public static string SingleDigitToHex(byte d) {
switch (d) {
public static char DigitToHexChar(byte d)
{
switch (d)
{
case 0:
return "0";
return '0';
case 1:
return "1";
return '1';
case 2:
return "2";
return '2';
case 3:
return "3";
return '3';
case 4:
return "4";
return '4';
case 5:
return "5";
return '5';
case 6:
return "6";
return '6';
case 7:
return "7";
return '7';
case 8:
return "8";
return '8';
case 9:
return "9";
return '9';
case 10:
return "A";
return 'A';
case 11:
return "B";
return 'B';
case 12:
return "C";
return 'C';
case 13:
return "D";
return 'D';
case 14:
return "E";
return 'E';
case 15:
return "F";
return 'F';
}
return " ";

return ' ';
}

}
}
Loading

0 comments on commit c4d6219

Please sign in to comment.