Hey All,
I wrote a few more commands. I also made a temp fix for the memory
corruption that is happening with the linked list: I made a fake command
and put it first in the list and then skip over it.
victim: this command is never shown.
cpuid: ditto
memdump: ditto
reboot: ditto
egg: see for yourself
--
Jonathan Dickinson
Index: Commands/BuiltIn/cpuid.cs
===================================================================
--- Commands/BuiltIn/cpuid.cs (revision 0)
+++ Commands/BuiltIn/cpuid.cs (revision 0)
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SharpOS.AOT.Attributes;
+using SharpOS.Foundation;
+using SharpOS.ADC;
+
+namespace SharpOS.Shell.Commands.BuiltIn
+{
+ public unsafe static class cpuid
+ {
+ public const string name = "cpuid";
+ public const string shortDescription = "Displays info about the cpu.";
+ public const string lblExecute = "COMMANDS.cpu.Execute";
+ public const string lblGetHelp = "COMMANDS.cpu.GetHelp";
+
+ [Label( lblExecute )]
+ public static void Execute( CommandExecutionContext* context )
+ {
+ // ARCHDEPENDS: X86
+ SharpOS.ADC.X86.CPU.WriteProcessorInfo( );
+ }
+
+ [Label( lblGetHelp )]
+ public static void GetHelp( CommandExecutionContext* context )
+ {
+ TextMode.WriteLine( "Syntax: " );
+ TextMode.WriteLine( " cpuid" );
+ TextMode.WriteLine( "" );
+ TextMode.WriteLine( "Gets information about the CPU." );
+ }
+
+ public static CommandTableEntry* CREATE( )
+ {
+ CommandTableEntry* entry = (CommandTableEntry*)
SharpOS.ADC.MemoryManager.Allocate( (uint) sizeof( CommandTableEntry ) );
+
+ entry->name = (CString8*) SharpOS.Stubs.CString( name );
+ entry->shortDescription = (CString8*) SharpOS.Stubs.CString(
shortDescription );
+ entry->func_Execute = (void*) SharpOS.Stubs.GetLabelAddress(
lblExecute );
+ entry->func_GetHelp = (void*) SharpOS.Stubs.GetLabelAddress(
lblGetHelp );
+ entry->nextEntry = null;
+
+ return entry;
+ }
+ }
+}
Index: Commands/BuiltIn/egg.cs
===================================================================
--- Commands/BuiltIn/egg.cs (revision 0)
+++ Commands/BuiltIn/egg.cs (revision 0)
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SharpOS.AOT.Attributes;
+using SharpOS.Foundation;
+using SharpOS.ADC;
+
+namespace SharpOS.Shell.Commands.BuiltIn
+{
+ public unsafe static class egg
+ {
+ public const string name = "egg";
+ public const string shortDescription = "The mandatory easter egg.";
+ public const string lblExecute = "COMMANDS.egg.Execute";
+ public const string lblGetHelp = "COMMANDS.egg.GetHelp";
+
+ [Label( lblExecute )]
+ public static void Execute( CommandExecutionContext* context )
+ {
+ TextMode.WriteLine( );
+
+ TextMode.WriteLine( " .=\"\"=." );
+ TextMode.WriteLine( " / _ _ \\" );
+ TextMode.WriteLine( " | d b |" );
+ TextMode.WriteLine( " \\ /\\ / ," );
+ TextMode.WriteLine( " ,/'-=\\/=-'\\, |\\ /\\/ \\/|
,_" );
+ TextMode.WriteLine( " / / \\ \\ ; \\/` '; ,
\\_'," );
+ TextMode.WriteLine( " | / \\ | \\ / " );
+ TextMode.WriteLine( " \\/ \\ / \\/ '. .'
/`." );
+ TextMode.WriteLine( " '. .' `~~` , /\\ `"
);
+ TextMode.WriteLine( " jgs _|`~~`|_ . `" );
+ TextMode.WriteLine( " /|\\ /|\\" );
+ TextMode.WriteLine( );
+ TextMode.WriteLine( "What is the egg?" );
+ TextMode.WriteLine( "The egg has you." );
+ }
+
+ [Label( lblGetHelp )]
+ public static void GetHelp( CommandExecutionContext* context )
+ {
+ TextMode.WriteLine( "Syntax: " );
+ TextMode.WriteLine( " egg" );
+ TextMode.WriteLine( "" );
+ TextMode.WriteLine( "And we a proud of it." );
+ }
+
+ public static CommandTableEntry* CREATE( )
+ {
+ CommandTableEntry* entry = (CommandTableEntry*)
SharpOS.ADC.MemoryManager.Allocate( (uint) sizeof( CommandTableEntry ) );
+
+ entry->name = (CString8*) SharpOS.Stubs.CString( name );
+ entry->shortDescription = (CString8*) SharpOS.Stubs.CString(
shortDescription );
+ entry->func_Execute = (void*) SharpOS.Stubs.GetLabelAddress(
lblExecute );
+ entry->func_GetHelp = (void*) SharpOS.Stubs.GetLabelAddress(
lblGetHelp );
+ entry->nextEntry = null;
+
+ return entry;
+ }
+ }
+}
Index: Commands/BuiltIn/memdump.cs
===================================================================
--- Commands/BuiltIn/memdump.cs (revision 0)
+++ Commands/BuiltIn/memdump.cs (revision 0)
@@ -0,0 +1,47 @@
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SharpOS.AOT.Attributes;
+using SharpOS.Foundation;
+using SharpOS.ADC;
+
+namespace SharpOS.Shell.Commands.BuiltIn
+{
+ public unsafe static class memdump
+ {
+ public const string name = "memdump";
+ public const string shortDescription = "Restarts the machine.";
+ public const string lblExecute = "COMMANDS.memdump.Execute";
+ public const string lblGetHelp = "COMMANDS.memdump.GetHelp";
+
+ [Label( lblExecute )]
+ public static void Execute( CommandExecutionContext* context )
+ {
+ ADC.MemoryManager.Dump( );
+ }
+
+ [Label( lblGetHelp )]
+ public static void GetHelp( CommandExecutionContext* context )
+ {
+ TextMode.WriteLine( "Syntax: " );
+ TextMode.WriteLine( " memdump" );
+ TextMode.WriteLine( "" );
+ TextMode.WriteLine( "Displays memory usage." );
+ }
+
+ public static CommandTableEntry* CREATE( )
+ {
+ CommandTableEntry* entry = (CommandTableEntry*)
SharpOS.ADC.MemoryManager.Allocate( (uint) sizeof( CommandTableEntry ) );
+
+ entry->name = (CString8*) SharpOS.Stubs.CString( name );
+ entry->shortDescription = (CString8*) SharpOS.Stubs.CString(
shortDescription );
+ entry->func_Execute = (void*) SharpOS.Stubs.GetLabelAddress(
lblExecute );
+ entry->func_GetHelp = (void*) SharpOS.Stubs.GetLabelAddress(
lblGetHelp );
+ entry->nextEntry = null;
+
+ return entry;
+ }
+ }
+}
Index: Commands/BuiltIn/reboot.cs
===================================================================
--- Commands/BuiltIn/reboot.cs (revision 0)
+++ Commands/BuiltIn/reboot.cs (revision 0)
@@ -0,0 +1,47 @@
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SharpOS.AOT.Attributes;
+using SharpOS.Foundation;
+using SharpOS.ADC;
+
+namespace SharpOS.Shell.Commands.BuiltIn
+{
+ public unsafe static class reboot
+ {
+ public const string name = "reboot";
+ public const string shortDescription = "Restarts the machine.";
+ public const string lblExecute = "COMMANDS.reboot.Execute";
+ public const string lblGetHelp = "COMMANDS.reboot.GetHelp";
+
+ [Label( lblExecute )]
+ public static void Execute( CommandExecutionContext* context )
+ {
+ Kernel.Reboot( );
+ }
+
+ [Label( lblGetHelp )]
+ public static void GetHelp( CommandExecutionContext* context )
+ {
+ TextMode.WriteLine( "Syntax: " );
+ TextMode.WriteLine( " reboot" );
+ TextMode.WriteLine( "" );
+ TextMode.WriteLine( "Restarts the machine." );
+ }
+
+ public static CommandTableEntry* CREATE( )
+ {
+ CommandTableEntry* entry = (CommandTableEntry*)
SharpOS.ADC.MemoryManager.Allocate( (uint) sizeof( CommandTableEntry ) );
+
+ entry->name = (CString8*) SharpOS.Stubs.CString( name );
+ entry->shortDescription = (CString8*) SharpOS.Stubs.CString(
shortDescription );
+ entry->func_Execute = (void*) SharpOS.Stubs.GetLabelAddress(
lblExecute );
+ entry->func_GetHelp = (void*) SharpOS.Stubs.GetLabelAddress(
lblGetHelp );
+ entry->nextEntry = null;
+
+ return entry;
+ }
+ }
+}
Index: Commands/BuiltIn/victim.cs
===================================================================
--- Commands/BuiltIn/victim.cs (revision 0)
+++ Commands/BuiltIn/victim.cs (revision 0)
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SharpOS.AOT.Attributes;
+using SharpOS.Foundation;
+using SharpOS.ADC;
+
+namespace SharpOS.Shell.Commands.BuiltIn
+{
+ public unsafe static class victim
+ {
+ private const string name = "victim";
+ private const string shortDescription = "This is a placeholder for a
bug.";
+ private const string lblExecute = "COMMANDS.victim.Execute";
+ private const string lblGetHelp = "COMMANDS.victim.GetHelp";
+
+ [Label( lblExecute )]
+ public static void Execute( CommandExecutionContext* context )
+ {
+
+ }
+
+ [Label( lblGetHelp )]
+ public static void GetHelp( CommandExecutionContext* context )
+ {
+
+ }
+
+ public static CommandTableEntry* CREATE( )
+ {
+ CommandTableEntry* entry = (CommandTableEntry*)
SharpOS.ADC.MemoryManager.Allocate( (uint) sizeof( CommandTableEntry ) );
+
+ entry->name = (CString8*) SharpOS.Stubs.CString( name );
+ entry->shortDescription = (CString8*) SharpOS.Stubs.CString(
shortDescription );
+ entry->func_Execute = (void*) SharpOS.Stubs.GetLabelAddress(
lblExecute );
+ entry->func_GetHelp = (void*) SharpOS.Stubs.GetLabelAddress(
lblGetHelp );
+
+ return entry;
+ }
+ }
+}
Index: Commands/CommandTableHeader.cs
===================================================================
--- Commands/CommandTableHeader.cs (revision 570)
+++ Commands/CommandTableHeader.cs (working copy)
@@ -269,11 +269,16 @@
//FIXME: For some reason, the first command on the list doesn't
register properly
//(NOTE: So don't put anything important there yet...)
+ header->AddEntry( BuiltIn.victim.CREATE( ) );
header->AddEntry(BuiltIn.halt.CREATE());
header->AddEntry(BuiltIn.cls.CREATE());
header->AddEntry(BuiltIn.commands.CREATE());
header->AddEntry(BuiltIn.help.CREATE());
header->AddEntry(BuiltIn.version.CREATE());
+ header->AddEntry( BuiltIn.cpuid.CREATE( ) );
+ header->AddEntry( BuiltIn.memdump.CREATE( ) );
+ header->AddEntry( BuiltIn.reboot.CREATE( ) );
+ header->AddEntry( BuiltIn.egg.CREATE( ) );
return header;
}
Index: Prompter.cs
===================================================================
--- Prompter.cs (revision 570)
+++ Prompter.cs (working copy)
@@ -136,7 +136,7 @@
{
Diagnostics.Assert(commandTable != null,
"Prompter::DisplayCommandList(CommandTableHeader*): Parameter 'commandTable' is
null");
- if (commandTable->firstEntry == null)
+ if (commandTable->firstEntry == null ||
commandTable->firstEntry->nextEntry == null)
{
ADC.TextMode.WriteLine("No commands to display; the commands
list is empty.");
return;
@@ -155,7 +155,7 @@
TextMode.WriteLine(colBLabel);
CommandTableEntry* currentEntry;
- for (currentEntry = commandTable->firstEntry;
+ for (currentEntry = commandTable->firstEntry->nextEntry;
currentEntry != null;
currentEntry = currentEntry->nextEntry)
{
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sharpos-developers