Exemplo n.º 1
0
        protected unsafe virtual void HandleMessage(IPCMessage msg)
        {
            SourceThread = msg.Source;
            if (msg.Type == Messages.Message.MESSAGE_RPC)
            {
                var rpc = msg as RPCMessage;

                var maddr = libsupcs.CastOperations.ReinterpretAs <ulong>(rpc.mptr);
                System.Diagnostics.Debugger.Log(0, null, "RPC call to " + maddr.ToString("X16") + " from " + msg.Source.name);

                CurrentMessage = rpc;
                void *ret = libsupcs.TysosMethod.InternalInvoke(rpc.mptr, rpc.args, rpc.rtype, rpc.flags);

                // ret is a RPCResult<T> object, we need to copy its result value (Box<T>)
                //  to that in the RPCMessage (which is the one the client is waiting
                //  on), then signal the Event
                var ret2 = libsupcs.CastOperations.ReinterpretAs <RPCResult <object> >(ret);
                (libsupcs.CastOperations.ReinterpretAs <RPCResult <object> >(rpc.result)).Result = ret2.Result;

                if (rpc.EventSetsOnReturn)
                {
                    rpc.result.Set();
                }

                System.Diagnostics.Debugger.Log(0, null, "RPC call to " + maddr.ToString("X16") + " finished");

                CurrentMessage = null;
            }
            else if (HandleGenericMessage(msg) == false)
            {
                System.Diagnostics.Debugger.Log(0, null, "unknown message type: " +
                                                msg.Type.ToString("X8") + "\n");
            }
            SourceThread = null;
        }
Exemplo n.º 2
0
        internal bool SendMessage(IPCMessage message)
        {
            if (!ready)
            {
                return(false);
            }

            return(rb.Enqueue((IntPtr)libsupcs.CastOperations.ReinterpretAsPointer(message)));
        }
Exemplo n.º 3
0
            public static bool SendMessage(Process dest, IPCMessage message)
            {
                if (dest == null)
                {
                    return(false);
                }
                if (dest.ipc == null)
                {
                    if (IPC.InitIPC(dest) == false)
                    {
                        return(false);
                    }
                }
                message.Source = Program.arch.CurrentCpu.CurrentThread;

                return(dest.ipc.SendMessage(message));
            }
Exemplo n.º 4
0
        public virtual void MessageLoop()
        {
            t = Syscalls.SchedulerFunctions.GetCurrentThread();
            System.Diagnostics.Debugger.Log(0, "ServerObject", "MessageLoop: in " + libsupcs.CastOperations.ReinterpretAsUlong(this).ToString("X") +
                                            " t set to " + libsupcs.CastOperations.ReinterpretAsUlong(t).ToString("X"));
            Syscalls.SchedulerFunctions.GetCurrentThread().owning_process.MessageServer = this;

            if (InitServer() == false)
            {
                System.Diagnostics.Debugger.Log(0, null, "InitServer failed");
                return;
            }

            foreach (string tag in Tags)
            {
                while (Syscalls.ProcessFunctions.GetVfs() == null)
                {
                    ;
                }
                var vfs = Syscalls.ProcessFunctions.GetVfs();

                vfs.RegisterTag(tag, MountPath);
            }

            System.Diagnostics.Debugger.Log(0, null, "entering message loop");

            while (true)
            {
                IPCMessage msg = null;
                do
                {
                    msg = Syscalls.IPCFunctions.ReadMessage();

                    if (msg != null)
                    {
                        HandleMessage(msg);
                    }
                } while (msg != null);

                BackgroundProc();

                Syscalls.SchedulerFunctions.Block();
            }
        }
Exemplo n.º 5
0
            public static bool SendMessage(Process dest, Messages.Message message, int type)
            {
                if (dest == null)
                {
                    return(false);
                }
                if (dest.ipc == null)
                {
                    if (IPC.InitIPC(dest) == false)
                    {
                        return(false);
                    }
                }

                IPCMessage msg = new IPCMessage();

                msg.Source  = Program.arch.CurrentCpu.CurrentThread;
                msg.Type    = type;
                msg.Message = message;

                return(dest.ipc.SendMessage(msg));
            }
Exemplo n.º 6
0
 /** <summary>Override in subclasses to handle additional message types</summary> */
 protected virtual bool HandleGenericMessage(IPCMessage msg)
 {
     return(false);
 }