virtualSoC  0.6.2
baskett
vmcli.MainClass Class Reference

Static Public Member Functions

static void Main (string[] args)
 

Detailed Description

Member Function Documentation

◆ Main()

static void vmcli.MainClass.Main ( string []  args)
static
14  {
15  CommandLineArgs cmd = new CommandLineArgs();
16 
17 
18  cmd.RegisterArgument( "i", new OptionArgument( "test.bin", true ) { HelpMessage="The image file." } );
19  cmd.RegisterArgument( "r", new OptionArgument( "512b" ) { HelpMessage="Ram size. [> 0]" });
20  cmd.RegisterArgument( "t", new OptionArgument( "raw", true) { HelpMessage="Image type: gz,raw" } );
21  cmd.RegisterArgument( "o", new OptionArgument( "console", false) { HelpMessage="Debug output" } );
22  cmd.RegisterArgument( "c", new OptionArgument( "2") { HelpMessage = "Number of CPU Cores" });
23 
24  cmd.SetDefaultArgument( "i" );
26 
27  if( !cmd.Validate(args) )
28  {
29  cmd.PrintHelp();
30  return;
31  }
32  string imageFile;
33  string debugFile;
34  UInt32 ramSize =10;
35  uint numCores = 1;
36  try
37  {
38  imageFile = cmd.GetValue<string>( "i" );
39  ramSize = GetValueFromArg(cmd, "r" );
40  debugFile = cmd.GetValue<string>("o");
41  numCores = GetValueFromArg(cmd, "c");
42  }
43  catch {
44  cmd.PrintHelp();
45  return;
46  }
47 
48  if (debugFile != "console") {
49  Console.SetOut (new System.IO.StreamWriter (debugFile));
50  }
51 
52  VM.Instance.CreateVM (ramSize, (int)numCores);
53  FramebufferForm form = new FramebufferForm ();
54 
55  byte[] data = InputFactory.GetInputClass (cmd).LoadFromFile (imageFile);
56 
57  if (!VM.Instance.Start (data)) {
58  Console.WriteLine ("Not enough bytes to load this image.");
59  return;
60  }
61  form.Run ();
62  }
void RegisterHelpArgument(string name="help")
Registers a help argument that will display the help page for the program if set by the user...
Definition: CommandLineArgs.cs:321
Class for defining, validating and processing command line arguments.
Definition: CommandLineArgs.cs:204
void PrintHelp(string errorMessage=null)
Prints a help message describing the effects of all available options.
Definition: CommandLineArgs.cs:243
An argument that can have any value.
Definition: CommandLineArgs.cs:732
static VM Instance
Gibt die Singleton Instance zzrück
Definition: VM.cs:57
bool Start(byte[] data)
Startet die Virtualle Maschine
Definition: VM.cs:92
bool Validate(string[] args, OptionalOut< string[]> outErrors=null)
Processes a set of command line arguments.
Definition: CommandLineArgs.cs:355
void SetDefaultArgument(string argument)
Sets the default argument that will be filled when no argument name is given.
Definition: CommandLineArgs.cs:334
void CreateVM(UInt32 ramSize, int iNumCores)
Erstellt die Virtuale Maschine
Definition: VM.cs:72
void RegisterArgument(string name, Argument arg)
Registers a new argument.
Definition: CommandLineArgs.cs:312
Diese Klasse beschreibt die Virtualle Maschine und ist eine zusammenstellung der verwendete Komponent...
Definition: VM.cs:34

The documentation for this class was generated from the following file: