aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-25 22:53:01 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-25 22:53:01 -0300
commitf6dc86c6a097f305701af32e77a2d8995a4385cc (patch)
tree743c44b755d5df69783d040f45f76c92db06f53f
parent13214ffa43f65686a9a5a99ca1c78b6c405a34db (diff)
Implement SvcSetMemoryAttribute
-rw-r--r--ChocolArm64/Memory/AMemoryMgr.cs30
-rw-r--r--Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs1
-rw-r--r--Ryujinx.Core/OsHle/Svc/SvcMemory.cs10
3 files changed, 39 insertions, 2 deletions
diff --git a/ChocolArm64/Memory/AMemoryMgr.cs b/ChocolArm64/Memory/AMemoryMgr.cs
index 05284059..c8869e03 100644
--- a/ChocolArm64/Memory/AMemoryMgr.cs
+++ b/ChocolArm64/Memory/AMemoryMgr.cs
@@ -234,6 +234,36 @@ namespace ChocolArm64.Memory
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)
{
return GetPTEntry(Position).Perm.HasFlag(Perm);
diff --git a/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs b/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
index 6c5beeb3..c989cdd4 100644
--- a/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
+++ b/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
@@ -1,5 +1,4 @@
using Ryujinx.Core.OsHle.Ipc;
-using System;
using System.Collections.Generic;
using System.IO;
diff --git a/Ryujinx.Core/OsHle/Svc/SvcMemory.cs b/Ryujinx.Core/OsHle/Svc/SvcMemory.cs
index 7528f4e0..6ca27f16 100644
--- a/Ryujinx.Core/OsHle/Svc/SvcMemory.cs
+++ b/Ryujinx.Core/OsHle/Svc/SvcMemory.cs
@@ -23,7 +23,15 @@ namespace Ryujinx.Core.OsHle.Svc
int State0 = (int)ThreadState.X2;
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;
}