Hi

I add a Halt method to the IProcessor "interface" to freeze the processor on
idle time until the next interruption.
In X86, this method simply call STI/HLT to enable interruption and to enter
halt mode.

This method is infinitely called in the main loop (in EntryModule) to avoid
the CPU to stay at 100%.
We can now work on the host machine when SharpOS runs in background.

Cédric Rousseau
Index: Kernel/Core/ADC/Architecture.cs
===================================================================
--- Kernel/Core/ADC/Architecture.cs	(revision 855)
+++ Kernel/Core/ADC/Architecture.cs	(working copy)
@@ -67,7 +67,7 @@
 		
 		#region Processors
 		[AOTAttr.ADCStub]
-		public static int ProcessorCount ()
+		public static int GetProcessorCount ()
 		{
 			return 0;
 		}
Index: Kernel/Core/ADC/IProcessor.cs
===================================================================
--- Kernel/Core/ADC/IProcessor.cs	(revision 855)
+++ Kernel/Core/ADC/IProcessor.cs	(working copy)
@@ -4,6 +4,7 @@
 // Authors:
 //	William Lahti <[EMAIL PROTECTED]>
 //	Sander van Rossen <[EMAIL PROTECTED]>
+//	Cédric Rousseau <[EMAIL PROTECTED]>
 //
 // Licensed under the terms of the GNU GPL v3,
 //  with Classpath Linking Exception for Libraries
@@ -35,5 +36,7 @@
 		public abstract CString8*		ModelName		{ get; }
 		
 		public abstract ProcessorFeature[] Features		{ get; }
+
+		public abstract void Halt ();
 	}
 }
Index: Kernel/Core/ADC/X86/Processor.cs
===================================================================
--- Kernel/Core/ADC/X86/Processor.cs	(revision 855)
+++ Kernel/Core/ADC/X86/Processor.cs	(working copy)
@@ -4,6 +4,7 @@
 // Authors:
 //	Mircea-Cristian Racasan <[EMAIL PROTECTED]>
 //	Sander van Rossen <[EMAIL PROTECTED]>
+//	Cédric Rousseau <[EMAIL PROTECTED]>
 //
 // Licensed under the terms of the GNU GPL v3,
 //  with Classpath Linking Exception for Libraries
@@ -374,6 +375,12 @@
 		private uint					id				= 0;
 		public override uint			ID				{ get { return id; } }
 		#endregion
+
+		public override void Halt ()
+		{
+			Asm.STI ();
+			Asm.HLT ();
+		}
 	}
 }
 
Index: Kernel/Core/EntryModule.cs
===================================================================
--- Kernel/Core/EntryModule.cs	(revision 855)
+++ Kernel/Core/EntryModule.cs	(working copy)
@@ -6,6 +6,7 @@
 //	Sander van Rossen <[EMAIL PROTECTED]>
 //	William Lahti <[EMAIL PROTECTED]>
 //	Bruce Markham <[EMAIL PROTECTED]>
+//	Cédric Rousseau <[EMAIL PROTECTED]>
 //
 // Licensed under the terms of the GNU GPL v3,
 //  with Classpath Linking Exception for Libraries
@@ -164,7 +165,18 @@
 
 			SetKernelStage (KernelStage.Diagnostics);
 
-			while (stayInLoop);
+			// Infinite loop used to halt the processors
+			//FIXME We must know on each processor the current thread runs on. 
+			//      Halt all other procs, then halt the current one.
+			IProcessor[] procs = Architecture.GetProcessors ();
+			int procCount = Architecture.GetProcessorCount();
+			while (stayInLoop)
+			{
+				for (int i=0; i < procCount; i++)
+				{
+					procs [i].Halt ();
+				}
+			}
 		}
 
 		public static void DisplayBanner ()
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers

Reply via email to