Exemple #1
0
        static void Main(string[] args)
        {

            OptionParser options = new OptionParser();
            options.parse(args);
            if (options.getTest() || options.getFile() != null)
            {
                armsim.run(options);
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemple #2
0
        /*
         * 
         * Unused might be good in the future
        public static byte[] stringToByteArray(string input){

            byte[] bA = new byte[input.Length * sizeof(char)];

            char[] inputArray = input.ToCharArray ();
            System.Buffer.BlockCopy(inputArray, 0, bA, 0, bA.Length);
            return bA;
        }
        */

        public static int run(OptionParser options)
        {

            try
            {
                log = new StreamWriter("log.txt");
                log.WriteLine("Log: Start");

            
                if (options.getTest())
                {
                    TestRam.RunTests(log);
                    TestArmSim.RunTests(log);
                }

                log.WriteLine("Log: MemSize " + options.getMemSize());
                log.WriteLine("Log: File " + options.getFile());
                log.WriteLine("Log: Little Endian " + BitConverter.IsLittleEndian);


                ELFReader e = new ELFReader();

                byte[] elfArray = File.ReadAllBytes(options.getFile());

                e.ReadHeader(elfArray);



                log.WriteLine("ELF: Header Position " + e.elfHeader.e_phoff);
                log.WriteLine("ELF: Header Size " + e.elfHeader.e_ehsize);
                log.WriteLine("ELF: Entry Position " + e.elfHeader.e_entry.ToString("X4"));
                log.WriteLine("ELF: Number of program headers " + e.elfHeader.e_phnum);

                for (int i = 1; i <= e.elfHeader.e_phnum; i++)
                {
                    log.WriteLine("ELF: Program Header {0}, Offset = {1}, Size = {2}",
                                    i,
                                    e.elfHeader.e_phoff,
                                    e.elfHeader.e_phentsize);
                }

                //ignore the entry point for a loader
                //its for (executing)going into the ram after it's loaded

                ramSim ram = new ramSim(options.getMemSize());
                writeElfToRam(e, elfArray, ref ram);


                log.WriteLine("Log: Ram Hash " + ram.getHash());


                printArray(ram.getArray());

            }
            catch
            {

                log.WriteLine("Log: Something went wrong");

                log.Close();
                return -1;
            }

            //all is good in the world,the sky is blue, the tank is clean...THE TANK IS CLEAN!!
            log.WriteLine("Log: Program Finished");
            log.WriteLine("-----------------------------");
            log.Close();

            return 0;
        }