예제 #1
0
        public static unsafe void Init()
        {
            var port = Serial.COM2;

            Serial.SetupPort(port);

            var path       = "os/App.HelloKernel.bin";
            var fileSize   = (uint)GetFileLenth(path);
            var target     = SysCalls.GetProcessIDForCommand(SysCallTarget.CreateMemoryProcess);
            var fileBuf    = SysCalls.RequestMessageBuffer((uint)fileSize, target);
            var handle     = OpenFile(path);
            var bufSize    = 3000u;
            var buf        = (byte *)RuntimeMemory.Allocate(bufSize);
            var gotBytes   = (uint)ReadFile(handle, buf, bufSize);
            var fileBufPos = 0u;

            while (gotBytes > 0)
            {
                //Console.WriteLine("got data");
                for (var i = 0; i < gotBytes; i++)
                {
                    ((byte *)fileBuf.Start)[fileBufPos + i] = buf[i];
                }
                fileBufPos += gotBytes;
                gotBytes    = (uint)ReadFile(handle, buf, bufSize);
            }
            RuntimeMemory.Free(buf);
            SysCalls.CreateMemoryProcess(fileBuf, fileSize);
        }
예제 #2
0
파일: Program.cs 프로젝트: djlw78/abanu
        private static void StartProc(string name)
        {
            var fileServiceProc = SysCalls.GetProcessIDForCommand(SysCallTarget.GetFileLength);
            var nameBuf         = SysCalls.RequestMessageBuffer(4096, fileServiceProc);
            var length          = SysCalls.GetFileLength(nameBuf, name);

            if (length < 0)
            {
                return;
            }

            Console.WriteLine("Loading App: " + name);
            Console.WriteLine("Length: " + length.ToString());

            var targetProcessStartProc = SysCalls.GetProcessIDForCommand(SysCallTarget.CreateMemoryProcess);
            var fileBuf = ApplicationRuntime.RequestMessageBuffer(length, targetProcessStartProc);

            var transferBuf = new byte[4096];

            using (var handle = File.Open(name))
            {
                int pos = 0;

                SysCalls.SetThreadPriority(30);
                while (true)
                {
                    var gotBytes = handle.Read(transferBuf, 0, transferBuf.Length);

                    if (gotBytes <= 0)
                    {
                        break;
                    }

                    fileBuf.Write(transferBuf, 0, pos, gotBytes);
                    pos += gotBytes;

                    //for (var i = 0; i < gotBytes; i++)
                    //{
                    //    fileBuf.SetByte(pos++, transferBuf[i]);
                    //}
                }
                SysCalls.SetThreadPriority(0);

                Console.WriteLine("CreateProc...");
                var procId = SysCalls.CreateMemoryProcess(fileBuf.Region, (uint)length);
                var cmdProcId_SetStandartInputOutput = SysCalls.GetProcessIDForCommand(SysCallTarget.SetStandartInputOutput);
                var buf2 = SysCalls.RequestMessageBuffer(4096, cmdProcId_SetStandartInputOutput);
                SysCalls.SetStandartInputOutput(procId, FileHandle.StandaradInput, "/tmp/tmp_fifo", buf2);

                SysCalls.StartProcess(procId);
            }
        }
예제 #3
0
        public static unsafe void StartProcess(string path)
        {
            if (SharedDisk == null)
            {
                return;
            }

            var fileSize = (uint)GetFileLenth(path);
            var target   = SysCalls.GetProcessIDForCommand(SysCallTarget.CreateMemoryProcess);
            var fileBuf  = SysCalls.RequestMessageBuffer((uint)fileSize, target);
            var handle   = OpenFile(path);
            var bufSize  = 128 * 1024u;
            //var bufSize = KMath.AlignValueCeil(fileSize, 512);
            var buf        = (byte *)RuntimeMemory.Allocate(bufSize);
            var gotBytes   = (uint)ReadFile(handle, buf, bufSize);
            var fileBufPos = 0u;

            //SysCalls.SetThreadPriority(30);
            while (gotBytes > 0)
            {
                //Console.WriteLine("got data");
                for (var i = 0; i < gotBytes; i++)
                {
                    ((byte *)fileBuf.Start)[fileBufPos + i] = buf[i];
                }
                fileBufPos += gotBytes;
                gotBytes    = (uint)ReadFile(handle, buf, bufSize);
            }
            //SysCalls.SetThreadPriority(0);
            RuntimeMemory.Free(buf);
            var cs = fileBuf.Checksum();

            Console.WriteLine(cs.ToString("x"));
            Console.WriteLine("Starting process ...");
            SysCalls.CreateMemoryProcess(fileBuf, fileSize);
        }