From 5e2e85d23e04bbf2cbeb6cd50064144578765239 Mon Sep 17 00:00:00 2001 From: fanoI Date: Sun, 16 Jul 2017 14:54:55 +0200 Subject: [PATCH 1/4] CGS works only with Bochs. --- .../Cosmos Graphic SubsystemBoot.Cosmos | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos b/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos index e02f6adac..d4cab3767 100644 --- a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos +++ b/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos @@ -1,9 +1,7 @@  - net462 - elf True @@ -17,16 +15,43 @@ MethodFooters False Serial: COM1 - VMware - VMware - Use VMware Player or Workstation to deploy and debug. + Bochs + Bochs + Use Bochs emulator to deploy and debug. + 192.168.0.8 + True + MethodFooters + Use VMware Player or Workstation to deploy and debug. + ISO + VMware + True + Source + False + Serial: COM1 + Pipe: Cosmos\Serial + 192.168.0.8 + bin\Debug\net462\ + False + False + True + MethodFooters + Use Bochs emulator to deploy and debug. + ISO + Bochs + True + Source + False + Serial: COM1 + Pipe: Cosmos\Serial + 192.168.0.8 + bin\Debug\net462\ + False + False - - Cosmos.Core.Plugs.Asm @@ -54,7 +79,5 @@ True - - \ No newline at end of file From 0e6d0d0f75d698a5bbff8827fcaab2cbb777c65f Mon Sep 17 00:00:00 2001 From: fanoI Date: Sun, 16 Jul 2017 19:36:36 +0200 Subject: [PATCH 2/4] Renamed Demo "Cosmos Graphic Subsystem" to "CosmosGraphicSubsystem" --- Cosmos.sln | 6 ++-- .../CosmosGraphicSubsystem.csproj} | 2 +- .../CosmosGraphicSubsystemBoot.Cosmos} | 21 +++++++++-- .../Kernel.cs | 0 Demos/Guess/GuessKernelBoot.Cosmos | 35 +++++++++++++++++-- Kernel.sln | 8 ++--- 6 files changed, 58 insertions(+), 14 deletions(-) rename Demos/{Cosmos Graphic Subsystem/Cosmos Graphic Subsystem.csproj => CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj} (88%) rename Demos/{Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos => CosmosGraphicSubsystem/CosmosGraphicSubsystemBoot.Cosmos} (79%) rename Demos/{Cosmos Graphic Subsystem => CosmosGraphicSubsystem}/Kernel.cs (100%) diff --git a/Cosmos.sln b/Cosmos.sln index 6915760d2..dae34840d 100644 --- a/Cosmos.sln +++ b/Cosmos.sln @@ -161,11 +161,11 @@ Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "GuessKernelBoot", "Demos\Gu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Core.Memory.Test", "Tests\Cosmos.Core.Memory.Test\Cosmos.Core.Memory.Test.csproj", "{408E5ACC-EA9A-41E8-AA95-514C5F47BD34}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cosmos Graphic Subsystem", "Cosmos Graphic Subsystem", "{A9D558E8-B0C7-4FF6-99D8-CB2BC6FEB7C7}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CosmosGraphicSubsystem", "CosmosGraphicSubsystem", "{A9D558E8-B0C7-4FF6-99D8-CB2BC6FEB7C7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos Graphic Subsystem", "Demos\Cosmos Graphic Subsystem\Cosmos Graphic Subsystem.csproj", "{49F2C01D-D2C5-4564-810B-1AE92236C5C1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosGraphicSubsystem", "Demos\CosmosGraphicSubsystem\CosmosGraphicSubsystem.csproj", "{49F2C01D-D2C5-4564-810B-1AE92236C5C1}" EndProject -Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Cosmos Graphic SubsystemBoot", "Demos\Cosmos Graphic Subsystem\Cosmos Graphic SubsystemBoot.Cosmos", "{79D68062-46C5-466D-9289-C033F7348485}" +Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "CosmosGraphicSubsystemBoot", "Demos\CosmosGraphicSubsystem\CosmosGraphicSubsystemBoot.Cosmos", "{79D68062-46C5-466D-9289-C033F7348485}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Core_Asm", "source\Cosmos.Core_Asm\Cosmos.Core_Asm.csproj", "{B7077A34-D7F0-4422-BE7C-65DF26C65489}" EndProject diff --git a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic Subsystem.csproj b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj similarity index 88% rename from Demos/Cosmos Graphic Subsystem/Cosmos Graphic Subsystem.csproj rename to Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj index ea3ee692d..5bf9756d3 100644 --- a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic Subsystem.csproj +++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj @@ -6,7 +6,7 @@ - + diff --git a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystemBoot.Cosmos similarity index 79% rename from Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos rename to Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystemBoot.Cosmos index d4cab3767..730dd2ec8 100644 --- a/Demos/Cosmos Graphic Subsystem/Cosmos Graphic SubsystemBoot.Cosmos +++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystemBoot.Cosmos @@ -47,6 +47,21 @@ bin\Debug\net462\ False False + True + MethodFooters + Makes a USB device such as a flash drive or external hard disk bootable. + USB + None + False + Source + False + Serial: COM1 + Pipe: Cosmos\Serial + 192.168.0.8 + bin\Debug\net462\ + False + False + CosmosGraphicSubsystemBoot @@ -73,11 +88,11 @@ {9431ff1f-ad75-4a1e-b38a-46e0f109411d} True - - Cosmos Graphic Subsystem + + CosmosGraphicSubsystem {49f2c01d-d2c5-4564-810b-1ae92236c5c1} True - \ No newline at end of file + diff --git a/Demos/Cosmos Graphic Subsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs similarity index 100% rename from Demos/Cosmos Graphic Subsystem/Kernel.cs rename to Demos/CosmosGraphicSubsystem/Kernel.cs diff --git a/Demos/Guess/GuessKernelBoot.Cosmos b/Demos/Guess/GuessKernelBoot.Cosmos index 79cefad24..e1461a10c 100644 --- a/Demos/Guess/GuessKernelBoot.Cosmos +++ b/Demos/Guess/GuessKernelBoot.Cosmos @@ -1,10 +1,10 @@ - + net462 elf - True + False Source User False @@ -18,6 +18,35 @@ VMware VMware Use VMware Player or Workstation to deploy and debug. + 192.168.0.8 + True + MethodFooters + Use VMware Player or Workstation to deploy and debug. + ISO + VMware + False + Source + False + Serial: COM1 + Pipe: Cosmos\Serial + 192.168.0.8 + bin\Debug\net462\ + False + False + True + MethodFooters + Use Bochs emulator to deploy and debug. + ISO + Bochs + True + Source + False + Serial: COM1 + Pipe: Cosmos\Serial + 192.168.0.8 + bin\Debug\net462\ + False + False @@ -30,4 +59,4 @@ - + \ No newline at end of file diff --git a/Kernel.sln b/Kernel.sln index 3c55186b7..d605c3703 100644 --- a/Kernel.sln +++ b/Kernel.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26430.13 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel", "Kernel", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}" EndProject @@ -32,11 +32,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GuessKernel", "Demos\Guess\ EndProject Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "GuessKernelBoot", "Demos\Guess\GuessKernelBoot.Cosmos", "{77DD08F5-0751-4EFC-B222-78F9F06E1F7C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cosmos Graphic Subsystem", "Cosmos Graphic Subsystem", "{A9D558E8-B0C7-4FF6-99D8-CB2BC6FEB7C7}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CosmosGraphicSubsystem", "CosmosGraphicSubsystem", "{A9D558E8-B0C7-4FF6-99D8-CB2BC6FEB7C7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos Graphic Subsystem", "Demos\Cosmos Graphic Subsystem\Cosmos Graphic Subsystem.csproj", "{49F2C01D-D2C5-4564-810B-1AE92236C5C1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosGraphicSubsystem", "Demos\CosmosGraphicSubsystem\CosmosGraphicSubsystem.csproj", "{49F2C01D-D2C5-4564-810B-1AE92236C5C1}" EndProject -Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Cosmos Graphic SubsystemBoot", "Demos\Cosmos Graphic Subsystem\Cosmos Graphic SubsystemBoot.Cosmos", "{79D68062-46C5-466D-9289-C033F7348485}" +Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "CosmosGraphicSubsystemBoot", "Demos\CosmosGraphicSubsystem\CosmosGraphicSubsystemBoot.Cosmos", "{79D68062-46C5-466D-9289-C033F7348485}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Debug.Kernel", "source\Cosmos.Debug.Kernel\Cosmos.Debug.Kernel.csproj", "{94DBCFC7-B5D2-4148-BE18-D76654C379E2}" EndProject From baa9d4caa94f3aa0d3c43f17db787059a4613aa9 Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Sun, 16 Jul 2017 20:19:49 +0200 Subject: [PATCH 3/4] Improvements. --- source/Cosmos.Core/ACPI.cs | 83 +++++++++++++++-------------------- source/Cosmos.HAL/Global.cs | 3 +- source/Cosmos.HAL/Power.cs | 18 ++------ source/Cosmos.System/Power.cs | 16 +------ 4 files changed, 42 insertions(+), 78 deletions(-) diff --git a/source/Cosmos.Core/ACPI.cs b/source/Cosmos.Core/ACPI.cs index 58b2b942f..faa88f181 100644 --- a/source/Cosmos.Core/ACPI.cs +++ b/source/Cosmos.Core/ACPI.cs @@ -92,7 +92,7 @@ namespace Cosmos.Core Init(); if (enable) - Enable(); + Enable(); } // Shutdown @@ -113,17 +113,7 @@ namespace Cosmos.Core // Reboot public static void Reboot() { - Console.Clear(); - IOPort port = new IOPort(0x64); - byte good = 0x02; - - while ((good & 0x02) != 0) - good = port.Byte; - - port.Byte = 0xFE; - - // Halt CPU - Global.CPU.Halt(); + throw new NotImplementedException("ACPI Reset not implemented yet."); //TODO } // Initializazion @@ -169,49 +159,49 @@ namespace Cosmos.Core yeuse = (byte*)addr; Facp = yeuse; - if (acpiCheckHeader((byte*)facpget(0), "DSDT") == 0) + if (acpiCheckHeader((byte*)facpget(0), "DSDT") == 0) + { + byte* S5Addr = (byte*)facpget(0) + 36; + int dsdtLength = *(facpget(0) + 1) - 36; + + while (0 < dsdtLength--) { - byte* S5Addr = (byte*)facpget(0) + 36; - int dsdtLength = *(facpget(0) + 1) - 36; - - while (0 < dsdtLength--) - { - if (Compare("_S5_", S5Addr) == 0) + if (Compare("_S5_", S5Addr) == 0) break; - S5Addr++; - } + S5Addr++; + } - if (dsdtLength > 0) + if (dsdtLength > 0) + { + if ((*(S5Addr - 1) == 0x08 || (*(S5Addr - 2) == 0x08 && *(S5Addr - 1) == '\\')) && *(S5Addr + 4) == 0x12) { - if ((*(S5Addr - 1) == 0x08 || (*(S5Addr - 2) == 0x08 && *(S5Addr - 1) == '\\')) && *(S5Addr + 4) == 0x12) - { - S5Addr += 5; - S5Addr += ((*S5Addr & 0xC0) >> 6) + 2; - if (*S5Addr == 0x0A) - S5Addr++; - SLP_TYPa = (short)(*(S5Addr) << 10); + S5Addr += 5; + S5Addr += ((*S5Addr & 0xC0) >> 6) + 2; + if (*S5Addr == 0x0A) S5Addr++; - if (*S5Addr == 0x0A) - S5Addr++; - SLP_TYPb = (short)(*(S5Addr) << 10); - SMI_CMD = facpget(1); - ACPI_ENABLE = facpbget(0); - ACPI_DISABLE = facpbget(1); - PM1a_CNT = facpget(2); - PM1b_CNT = facpget(3); - PM1_CNT_LEN = facpbget(3); - SLP_EN = 1 << 13; - SCI_EN = 1; + SLP_TYPa = (short)(*(S5Addr) << 10); + S5Addr++; + if (*S5Addr == 0x0A) + S5Addr++; + SLP_TYPb = (short)(*(S5Addr) << 10); + SMI_CMD = facpget(1); + ACPI_ENABLE = facpbget(0); + ACPI_DISABLE = facpbget(1); + PM1a_CNT = facpget(2); + PM1b_CNT = facpget(3); + PM1_CNT_LEN = facpbget(3); + SLP_EN = 1 << 13; + SCI_EN = 1; - smiIO = new IOPort((ushort)SMI_CMD); - pm1aIO = new IOPort((ushort)PM1a_CNT); - pm1bIO = new IOPort((ushort)PM1b_CNT); + smiIO = new IOPort((ushort)SMI_CMD); + pm1aIO = new IOPort((ushort)PM1a_CNT); + pm1bIO = new IOPort((ushort)PM1b_CNT); - return true; - } + return true; } } - ptr += 4; + } + ptr += 4; } } @@ -221,7 +211,6 @@ namespace Cosmos.Core // Enable ACPI public static void Enable() { - Init(); smiIO = new IOPort(ACPI_ENABLE); } diff --git a/source/Cosmos.HAL/Global.cs b/source/Cosmos.HAL/Global.cs index ac04cf711..9bd6f03f7 100644 --- a/source/Cosmos.HAL/Global.cs +++ b/source/Cosmos.HAL/Global.cs @@ -132,14 +132,13 @@ namespace Cosmos.HAL // system level and not accessible from Core. Need to think about this // for the future. Console.WriteLine("Finding PCI Devices"); - PCI.Setup(); } public static void StartACPI() { Console.WriteLine("Starting ACPI"); - Core.ACPI.Start(); + ACPI.Start(); } public static void EnableInterrupts() diff --git a/source/Cosmos.HAL/Power.cs b/source/Cosmos.HAL/Power.cs index 29669136b..7289615d0 100644 --- a/source/Cosmos.HAL/Power.cs +++ b/source/Cosmos.HAL/Power.cs @@ -16,27 +16,15 @@ namespace Cosmos.HAL } //Reboot with ACPI - public static void Reboot() + public static void ACPIReboot() { - ACPI.Reboot(); + ACPI.Reboot(); //TODO } //Shutdown with ACPI - public static void Shutdown() + public static void ACPIShutdown() { ACPI.Shutdown(); } - - //Enable ACPI - public static void ACPIEnable() - { - ACPI.Enable(); - } - - //Disable ACPI - public static void ACPIDisable() - { - ACPI.Disable(); - } } } \ No newline at end of file diff --git a/source/Cosmos.System/Power.cs b/source/Cosmos.System/Power.cs index b741b284c..fdd6e610b 100644 --- a/source/Cosmos.System/Power.cs +++ b/source/Cosmos.System/Power.cs @@ -8,25 +8,13 @@ namespace Cosmos.System { public class Power { - public static void CPUReboot() + public static void Reboot() { HAL.Power.CPUReboot(); } - public static void Reboot() - { - HAL.Power.Reboot(); - } public static void Shutdown() { - HAL.Power.Shutdown(); - } - public static void ACPIEnable() - { - HAL.Power.ACPIEnable(); - } - public static void ACPIDisable() - { - HAL.Power.ACPIDisable(); + HAL.Power.ACPIShutdown(); } } } \ No newline at end of file From 453eadcc5c0472242b4505dde6b241b265f322e8 Mon Sep 17 00:00:00 2001 From: Kudzu Date: Sun, 16 Jul 2017 15:52:36 -0400 Subject: [PATCH 4/4] sln folders --- Kernel.sln | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Kernel.sln b/Kernel.sln index d605c3703..02e9d5bd5 100644 --- a/Kernel.sln +++ b/Kernel.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.13 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel", "Kernel", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}" EndProject @@ -48,6 +48,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Debug.Kernel.Plugs.A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Core.DebugStub", "source\Cosmos.Core.DebugStub\Cosmos.Core.DebugStub.csproj", "{9BDA0399-0CFD-42E8-8CF4-3DDE16122A82}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel Test", "Kernel Test", "{0005698B-5FB4-47C4-BD4C-2C81A20DCD7D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "10 Core", "10 Core", "{67CA4591-0EFD-45FC-955E-E6013B9C1DDE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "20 Halo", "20 Halo", "{82F49B98-8C19-4452-9D7E-6530AFBBE3BB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "25 Halie", "25 Halie", "{FE675B0D-393A-4D3B-B487-282220923532}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "80 System", "80 System", "{A2A2059B-16FB-43C1-9630-56EBF0328EC3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00 Shared", "00 Shared", "{01EE1DCC-200B-45E4-AB76-9D5F7EDD5EC0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -198,5 +210,10 @@ Global {79D68062-46C5-466D-9289-C033F7348485} = {A9D558E8-B0C7-4FF6-99D8-CB2BC6FEB7C7} {31D48401-77B2-44AF-B6D3-27AB67C10759} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} {9BDA0399-0CFD-42E8-8CF4-3DDE16122A82} = {04B18FFC-8EA0-4E9F-9E1B-478527B19AFA} + {67CA4591-0EFD-45FC-955E-E6013B9C1DDE} = {0005698B-5FB4-47C4-BD4C-2C81A20DCD7D} + {82F49B98-8C19-4452-9D7E-6530AFBBE3BB} = {0005698B-5FB4-47C4-BD4C-2C81A20DCD7D} + {FE675B0D-393A-4D3B-B487-282220923532} = {0005698B-5FB4-47C4-BD4C-2C81A20DCD7D} + {A2A2059B-16FB-43C1-9630-56EBF0328EC3} = {0005698B-5FB4-47C4-BD4C-2C81A20DCD7D} + {01EE1DCC-200B-45E4-AB76-9D5F7EDD5EC0} = {0005698B-5FB4-47C4-BD4C-2C81A20DCD7D} EndGlobalSection EndGlobal