Exemplo n.º 1
0
        internal static VfsFile FindFile(string path)
        {
            for (var i = 0; i < Files.Count; i++)
            {
                if (Files[i].Path == path)
                {
                    return(Files[i]);
                }
            }

            if (InitHAL.PrimaryFS != null)
            {
                var node = InitHAL.PrimaryFS.Root.Lookup(path);
                if (node != null)
                {
                    var stream = (Stream)node.Open(FileAccess.Read, FileShare.Read);
                    var file   = new VfsFile
                    {
                        Path   = path,
                        Buffer = stream,
                        Length = (int)stream.Length,
                    };
                    Files.Add(file);
                    return(file);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public static unsafe void Main()
        {
            ApplicationRuntime.Init();

            Files     = new List <VfsFile>();
            OpenFiles = new List <OpenFile>();

            KeyBoardFifo = new VfsFile {
                Path = "/dev/keyboard", Buffer = new FifoFile()
            };
            Files.Add(KeyBoardFifo);
            Files.Add(new VfsFile {
                Path = "/dev/screen", Buffer = new FifoFile()
            });

            MessageManager.OnMessageReceived = MessageReceived;
            MessageManager.OnDispatchError   = OnDispatchError;

            SysCalls.RegisterService(SysCallTarget.OpenFile);
            SysCalls.RegisterService(SysCallTarget.CreateFifo);
            SysCalls.RegisterService(SysCallTarget.ReadFile);
            SysCalls.RegisterService(SysCallTarget.WriteFile);

            SysCalls.RegisterInterrupt(33);

            SysCalls.SetServiceStatus(ServiceStatus.Ready);

            while (true)
            {
                SysCalls.ThreadSleep(0);
            }
        }
Exemplo n.º 3
0
        public static unsafe void Cmd_CreateFiFo(SystemMessage *msg)
        {
            var path = NullTerminatedString.ToString((byte *)msg->Arg1);

            var fifo = new FifoFile()
            {
            };

            var vfsFile = new VfsFile
            {
                Path   = path,
                Buffer = fifo,
            };

            Files.Add(vfsFile);

            MessageManager.Send(new SystemMessage(SysCallTarget.ServiceReturn));
        }
Exemplo n.º 4
0
        public static void Setup()
        {
            Files     = new List <VfsFile>();
            OpenFiles = new List <OpenFile>();

            Files.Add(new VfsFile {
                Path = "/dev/null", Buffer = new NullStream()
            });

            KeyBoardFifo = new VfsFile {
                Path = "/dev/keyboard", Buffer = new FifoFile()
            };
            Files.Add(KeyBoardFifo);

            Files.Add(new VfsFile {
                Path = "/dev/console", Buffer = new FifoFile()
            });
        }
Exemplo n.º 5
0
        public static unsafe void Cmd_CreateMemoryFile(SystemMessage *msg)
        {
            var start  = msg->Arg1;
            var length = msg->Arg2;
            var data   = (char *)start;

            var path = new string(data);

            var fifo = new FifoFile()
            {
            };

            var vfsFile = new VfsFile
            {
                Path   = path,
                Buffer = fifo,
            };

            Files.Add(vfsFile);

            MessageManager.Send(new SystemMessage(SysCallTarget.ServiceReturn));
        }