فهرست منبع

Implement SvcSetMemoryAttribute

gdkchan 8 سال پیش
والد
کامیت
f6dc86c6a0
3فایلهای تغییر یافته به همراه39 افزوده شده و 2 حذف شده
  1. 30 0
      ChocolArm64/Memory/AMemoryMgr.cs
  2. 0 1
      Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
  3. 9 1
      Ryujinx.Core/OsHle/Svc/SvcMemory.cs

+ 30 - 0
ChocolArm64/Memory/AMemoryMgr.cs

@@ -234,6 +234,36 @@ namespace ChocolArm64.Memory
                 BaseEntry.Perm);
                 BaseEntry.Perm);
         }
         }
 
 
+        public void ClearAttrBit(long Position, long Size, int Bit)
+        {
+            while (Size > 0)
+            {
+                PTEntry Entry = GetPTEntry(Position);
+
+                Entry.Attr &= ~(1 << Bit);
+
+                SetPTEntry(Position, Entry);
+
+                Position += PageSize;
+                Size     -= PageSize;
+            }
+        }
+
+        public void SetAttrBit(long Position, long Size, int Bit)
+        {
+            while (Size > 0)
+            {
+                PTEntry Entry = GetPTEntry(Position);
+
+                Entry.Attr |= (1 << Bit);
+
+                SetPTEntry(Position, Entry);
+
+                Position += PageSize;
+                Size     -= PageSize;
+            }
+        }
+
         public bool HasPermission(long Position, AMemoryPerm Perm)
         public bool HasPermission(long Position, AMemoryPerm Perm)
         {
         {
             return GetPTEntry(Position).Perm.HasFlag(Perm);
             return GetPTEntry(Position).Perm.HasFlag(Perm);

+ 0 - 1
Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs

@@ -1,5 +1,4 @@
 using Ryujinx.Core.OsHle.Ipc;
 using Ryujinx.Core.OsHle.Ipc;
-using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 
 

+ 9 - 1
Ryujinx.Core/OsHle/Svc/SvcMemory.cs

@@ -23,7 +23,15 @@ namespace Ryujinx.Core.OsHle.Svc
             int  State0   =  (int)ThreadState.X2;
             int  State0   =  (int)ThreadState.X2;
             int  State1   =  (int)ThreadState.X3;
             int  State1   =  (int)ThreadState.X3;
 
 
-            //TODO
+            if ((State0 == 0 && State1 == 0) ||
+                (State0 == 8 && State1 == 0))
+            {
+                Memory.Manager.ClearAttrBit(Position, Size, 3);
+            }
+            else if (State0 == 8 && State1 == 8)
+            {
+                Memory.Manager.SetAttrBit(Position, Size, 3);
+            }
 
 
             ThreadState.X0 = (int)SvcResult.Success;
             ThreadState.X0 = (int)SvcResult.Success;
         }
         }