diff options
| author | Mary <me@thog.eu> | 2021-05-05 23:44:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-05 23:44:26 +0200 |
| commit | b94dc01d4357c608d60383e85f709312294fd833 (patch) | |
| tree | 3b4fff544218ed538fd8160498eddb3eba794fc0 /Ryujinx.HLE/HOS/Ipc | |
| parent | eb056218a13fa145adcc9ecafd166b1b1f2caccb (diff) | |
SM instance & TIPC fixes (#2241)
This PR addresses the following issues:
- SM was previously instancied once and reused on all sessions. This
could cause inconsistency on the service initialization.
- TIPC replies were not matching what is generated on hardware.
Diffstat (limited to 'Ryujinx.HLE/HOS/Ipc')
| -rw-r--r-- | Ryujinx.HLE/HOS/Ipc/IpcMessage.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs b/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs index c99ad622..e5b9bf04 100644 --- a/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs +++ b/Ryujinx.HLE/HOS/Ipc/IpcMessage.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics; using System.IO; namespace Ryujinx.HLE.HOS.Ipc @@ -185,6 +186,53 @@ namespace Ryujinx.HLE.HOS.Ipc } } + public byte[] GetBytesTipc() + { + Debug.Assert(PtrBuff.Count == 0); + + using (MemoryStream ms = new MemoryStream()) + { + BinaryWriter writer = new BinaryWriter(ms); + + int word0; + int word1; + + word0 = (int)Type; + word0 |= (SendBuff.Count & 0xf) << 20; + word0 |= (ReceiveBuff.Count & 0xf) << 24; + word0 |= (ExchangeBuff.Count & 0xf) << 28; + + byte[] handleData = new byte[0]; + + if (HandleDesc != null) + { + handleData = HandleDesc.GetBytes(); + } + + int dataLength = RawData?.Length ?? 0; + + dataLength = ((dataLength + 3) & ~3) / 4; + + word1 = (dataLength & 0x3ff); + + if (HandleDesc != null) + { + word1 |= 1 << 31; + } + + writer.Write(word0); + writer.Write(word1); + writer.Write(handleData); + + if (RawData != null) + { + writer.Write(RawData); + } + + return ms.ToArray(); + } + } + private long GetPadSize16(long position) { if ((position & 0xf) != 0) |
