Implement a new physical memory manager and replace DeviceMemory (#856)
* Implement a new physical memory manager and replace DeviceMemory * Proper generic constraints * Fix debug build * Add memory tests * New CPU memory manager and general code cleanup * Remove host memory management from CPU project, use Ryujinx.Memory instead * Fix tests * Document exceptions on MemoryBlock * Fix leak on unix memory allocation * Proper disposal of some objects on tests * Fix JitCache not being set as initialized * GetRef without checks for 8-bits and 16-bits CAS * Add MemoryBlock destructor * Throw in separate method to improve codegen * Address PR feedback * QueryModified improvements * Fix memory write tracking not marking all pages as modified in some cases * Simplify MarkRegionAsModified * Remove XML doc for ghost param * Add back optimization to avoid useless buffer updates * Add Ryujinx.Cpu project, move MemoryManager there and remove MemoryBlockWrapper * Some nits * Do not perform address translation when size is 0 * Address PR feedback and format NativeInterface class * Remove ghost parameter description * Update Ryujinx.Cpu to .NET Core 3.1 * Address PR feedback * Fix build * Return a well defined value for GetPhysicalAddress with invalid VA, and do not return unmapped ranges as modified * Typo
This commit is contained in:
parent
1758424208
commit
f77694e4f7
126 changed files with 2176 additions and 2092 deletions
|
@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
{
|
||||
private Switch _device;
|
||||
|
||||
private long _physicalAddress;
|
||||
private ulong _physicalAddress;
|
||||
|
||||
private struct FontInfo
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
|
||||
private Dictionary<SharedFontType, FontInfo> _fontData;
|
||||
|
||||
public SharedFontManager(Switch device, long physicalAddress)
|
||||
public SharedFontManager(Switch device, ulong physicalAddress)
|
||||
{
|
||||
_physicalAddress = physicalAddress;
|
||||
_device = device;
|
||||
|
@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
{
|
||||
if (_fontData == null)
|
||||
{
|
||||
_device.Memory.FillWithZeros(_physicalAddress, Horizon.FontSize);
|
||||
_device.Memory.ZeroFill(_physicalAddress, Horizon.FontSize);
|
||||
|
||||
uint fontOffset = 0;
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
if (!string.IsNullOrWhiteSpace(fontPath))
|
||||
{
|
||||
byte[] data;
|
||||
|
||||
|
||||
using (IStorage ncaFileStream = new LocalStorage(fontPath, FileAccess.Read, FileMode.Open))
|
||||
{
|
||||
Nca nca = new Nca(_device.System.KeySet, ncaFileStream);
|
||||
|
@ -77,7 +77,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
|
||||
data = DecryptFont(fontFile.AsStream());
|
||||
}
|
||||
|
||||
|
||||
FontInfo info = new FontInfo((int)fontOffset, data.Length);
|
||||
|
||||
WriteMagicAndSize(_physicalAddress + fontOffset, data.Length);
|
||||
|
@ -88,7 +88,7 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
|
||||
for (; fontOffset - start < data.Length; fontOffset++)
|
||||
{
|
||||
_device.Memory.WriteByte(_physicalAddress + fontOffset, data[fontOffset - start]);
|
||||
_device.Memory.Write(_physicalAddress + fontOffset, data[fontOffset - start]);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
@ -129,15 +129,15 @@ namespace Ryujinx.HLE.HOS.Font
|
|||
}
|
||||
}
|
||||
|
||||
private void WriteMagicAndSize(long position, int size)
|
||||
private void WriteMagicAndSize(ulong address, int size)
|
||||
{
|
||||
const int decMagic = 0x18029a7f;
|
||||
const int key = 0x49621806;
|
||||
|
||||
int encryptedSize = BinaryPrimitives.ReverseEndianness(size ^ key);
|
||||
|
||||
_device.Memory.WriteInt32(position + 0, decMagic);
|
||||
_device.Memory.WriteInt32(position + 4, encryptedSize);
|
||||
_device.Memory.Write(address + 0, decMagic);
|
||||
_device.Memory.Write(address + 4, encryptedSize);
|
||||
}
|
||||
|
||||
public int GetFontSize(SharedFontType fontType)
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
using ARMeilleure.Memory;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
static class Homebrew
|
||||
{
|
||||
public const string TemporaryNroSuffix = ".ryu_tmp.nro";
|
||||
|
||||
// http://switchbrew.org/index.php?title=Homebrew_ABI
|
||||
public static void WriteHbAbiData(MemoryManager memory, long position, int mainThreadHandle, string switchPath)
|
||||
{
|
||||
// MainThreadHandle.
|
||||
WriteConfigEntry(memory, ref position, 1, 0, mainThreadHandle);
|
||||
|
||||
// NextLoadPath.
|
||||
WriteConfigEntry(memory, ref position, 2, 0, position + 0x200, position + 0x400);
|
||||
|
||||
// Argv.
|
||||
long argvPosition = position + 0xC00;
|
||||
|
||||
memory.WriteBytes(argvPosition, Encoding.ASCII.GetBytes(switchPath + "\0"));
|
||||
|
||||
WriteConfigEntry(memory, ref position, 5, 0, 0, argvPosition);
|
||||
|
||||
// AppletType.
|
||||
WriteConfigEntry(memory, ref position, 7);
|
||||
|
||||
// EndOfList.
|
||||
WriteConfigEntry(memory, ref position, 0);
|
||||
}
|
||||
|
||||
private static void WriteConfigEntry(
|
||||
MemoryManager memory,
|
||||
ref long position,
|
||||
int key,
|
||||
int flags = 0,
|
||||
long value0 = 0,
|
||||
long value1 = 0)
|
||||
{
|
||||
memory.WriteInt32(position + 0x00, key);
|
||||
memory.WriteInt32(position + 0x04, flags);
|
||||
memory.WriteInt64(position + 0x08, value0);
|
||||
memory.WriteInt64(position + 0x10, value1);
|
||||
|
||||
position += 0x18;
|
||||
}
|
||||
|
||||
public static string ReadHbAbiNextLoadPath(MemoryManager memory, long position)
|
||||
{
|
||||
string fileName = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
long key = memory.ReadInt64(position);
|
||||
|
||||
if (key == 2)
|
||||
{
|
||||
long value0 = memory.ReadInt64(position + 0x08);
|
||||
long value1 = memory.ReadInt64(position + 0x10);
|
||||
|
||||
fileName = MemoryHelper.ReadAsciiString(memory, value0, value1 - value0);
|
||||
|
||||
break;
|
||||
}
|
||||
else if (key == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
position += 0x18;
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -141,7 +141,7 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
public int GlobalAccessLogMode { get; set; }
|
||||
|
||||
internal long HidBaseAddress { get; private set; }
|
||||
internal ulong HidBaseAddress { get; private set; }
|
||||
|
||||
internal NvHostSyncpt HostSyncpoint { get; private set; }
|
||||
|
||||
|
@ -202,7 +202,7 @@ namespace Ryujinx.HLE.HOS
|
|||
ulong iirsPa = region.Address + HidSize + FontSize;
|
||||
ulong timePa = region.Address + HidSize + FontSize + IirsSize;
|
||||
|
||||
HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase);
|
||||
HidBaseAddress = hidPa - DramMemoryMap.DramBase;
|
||||
|
||||
KPageList hidPageList = new KPageList();
|
||||
KPageList fontPageList = new KPageList();
|
||||
|
@ -220,13 +220,13 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
KSharedMemory timeSharedMemory = new KSharedMemory(this, timePageList, 0, 0, MemoryPermission.Read);
|
||||
|
||||
TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, (long)(timePa - DramMemoryMap.DramBase), TimeSize);
|
||||
TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, timePa - DramMemoryMap.DramBase, TimeSize);
|
||||
|
||||
AppletState = new AppletStateMgr(this);
|
||||
|
||||
AppletState.SetFocus(true);
|
||||
|
||||
Font = new SharedFontManager(device, (long)(fontPa - DramMemoryMap.DramBase));
|
||||
Font = new SharedFontManager(device, fontPa - DramMemoryMap.DramBase);
|
||||
|
||||
IUserInterface.InitializePort(this);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
|
@ -103,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Ipc
|
|||
throw new NotImplementedException(request.Type.ToString());
|
||||
}
|
||||
|
||||
memory.WriteBytes(cmdPtr, response.GetBytes(cmdPtr));
|
||||
memory.Write((ulong)cmdPtr, response.GetBytes(cmdPtr));
|
||||
}
|
||||
|
||||
return KernelResult.Success;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using ARMeilleure.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
{
|
||||
|
@ -9,10 +9,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped((long)address) &&
|
||||
currentProcess.CpuMemory.IsMapped((long)address + 3))
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 3))
|
||||
{
|
||||
value = currentProcess.CpuMemory.ReadInt32((long)address);
|
||||
value = currentProcess.CpuMemory.Read<int>(address);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
|
||||
for (int index = 0; index < values.Length; index++, address += 4)
|
||||
{
|
||||
if (currentProcess.CpuMemory.IsMapped((long)address) &&
|
||||
currentProcess.CpuMemory.IsMapped((long)address + 3))
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 3))
|
||||
{
|
||||
values[index]= currentProcess.CpuMemory.ReadInt32((long)address);
|
||||
values[index]= currentProcess.CpuMemory.Read<int>(address);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,8 +46,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped((long)address) &&
|
||||
currentProcess.CpuMemory.IsMapped((long)address + size - 1))
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + (ulong)size - 1))
|
||||
{
|
||||
value = MemoryHelper.ReadAsciiString(currentProcess.CpuMemory, (long)address, size);
|
||||
|
||||
|
@ -63,10 +63,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped((long)address) &&
|
||||
currentProcess.CpuMemory.IsMapped((long)address + 3))
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 3))
|
||||
{
|
||||
currentProcess.CpuMemory.WriteInt32((long)address, value);
|
||||
currentProcess.CpuMemory.Write(address, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -78,10 +78,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped((long)address) &&
|
||||
currentProcess.CpuMemory.IsMapped((long)address + 7))
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 7))
|
||||
{
|
||||
currentProcess.CpuMemory.WriteInt64((long)address, value);
|
||||
currentProcess.CpuMemory.Write(address, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -322,8 +322,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
serverHeader.ReceiveListType,
|
||||
serverHeader.ReceiveListOffset);
|
||||
|
||||
serverProcess.CpuMemory.WriteUInt32((long)serverMsg.Address + 0, clientHeader.Word0);
|
||||
serverProcess.CpuMemory.WriteUInt32((long)serverMsg.Address + 4, clientHeader.Word1);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + 0, clientHeader.Word0);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + 4, clientHeader.Word1);
|
||||
|
||||
uint offset;
|
||||
|
||||
|
@ -337,13 +337,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
serverProcess.CpuMemory.WriteUInt32((long)serverMsg.Address + 8, clientHeader.Word2);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + 8, clientHeader.Word2);
|
||||
|
||||
offset = 3;
|
||||
|
||||
if (clientHeader.HasPid)
|
||||
{
|
||||
serverProcess.CpuMemory.WriteInt64((long)serverMsg.Address + offset * 4, clientProcess.Pid);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + offset * 4, clientProcess.Pid);
|
||||
|
||||
offset += 2;
|
||||
}
|
||||
|
@ -352,14 +352,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
int newHandle = 0;
|
||||
|
||||
int handle = System.Device.Memory.ReadInt32((long)clientMsg.DramAddress + offset * 4);
|
||||
int handle = System.Device.Memory.Read<int>(clientMsg.DramAddress + offset * 4);
|
||||
|
||||
if (clientResult == KernelResult.Success && handle != 0)
|
||||
{
|
||||
clientResult = GetCopyObjectHandle(clientThread, serverProcess, handle, out newHandle);
|
||||
}
|
||||
|
||||
serverProcess.CpuMemory.WriteInt32((long)serverMsg.Address + offset * 4, newHandle);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + offset * 4, newHandle);
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
int newHandle = 0;
|
||||
|
||||
int handle = System.Device.Memory.ReadInt32((long)clientMsg.DramAddress + offset * 4);
|
||||
int handle = System.Device.Memory.Read<int>(clientMsg.DramAddress + offset * 4);
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
|
@ -382,7 +382,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
}
|
||||
}
|
||||
|
||||
serverProcess.CpuMemory.WriteInt32((long)serverMsg.Address + offset * 4, newHandle);
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + offset * 4, newHandle);
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
for (int index = 0; index < clientHeader.PointerBuffersCount; index++)
|
||||
{
|
||||
ulong pointerDesc = System.Device.Memory.ReadUInt64((long)clientMsg.DramAddress + offset * 4);
|
||||
ulong pointerDesc = System.Device.Memory.Read<ulong>(clientMsg.DramAddress + offset * 4);
|
||||
|
||||
PointerBufferDesc descriptor = new PointerBufferDesc(pointerDesc);
|
||||
|
||||
|
@ -450,7 +450,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
descriptor.BufferAddress = 0;
|
||||
}
|
||||
|
||||
serverProcess.CpuMemory.WriteUInt64((long)serverMsg.Address + offset * 4, descriptor.Pack());
|
||||
serverProcess.CpuMemory.Write(serverMsg.Address + offset * 4, descriptor.Pack());
|
||||
|
||||
offset += 2;
|
||||
}
|
||||
|
@ -463,11 +463,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
for (int index = 0; index < totalBuffersCount; index++)
|
||||
{
|
||||
long clientDescAddress = (long)clientMsg.DramAddress + offset * 4;
|
||||
ulong clientDescAddress = clientMsg.DramAddress + offset * 4;
|
||||
|
||||
uint descWord0 = System.Device.Memory.ReadUInt32(clientDescAddress + 0);
|
||||
uint descWord1 = System.Device.Memory.ReadUInt32(clientDescAddress + 4);
|
||||
uint descWord2 = System.Device.Memory.ReadUInt32(clientDescAddress + 8);
|
||||
uint descWord0 = System.Device.Memory.Read<uint>(clientDescAddress + 0);
|
||||
uint descWord1 = System.Device.Memory.Read<uint>(clientDescAddress + 4);
|
||||
uint descWord2 = System.Device.Memory.Read<uint>(clientDescAddress + 8);
|
||||
|
||||
bool isSendDesc = index < clientHeader.SendBuffersCount;
|
||||
bool isExchangeDesc = index >= clientHeader.SendBuffersCount + clientHeader.ReceiveBuffersCount;
|
||||
|
@ -542,11 +542,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
descWord2 |= (uint)(dstAddress >> 34) & 0x3ffffffc;
|
||||
descWord2 |= (uint)(dstAddress >> 4) & 0xf0000000;
|
||||
|
||||
long serverDescAddress = (long)serverMsg.Address + offset * 4;
|
||||
ulong serverDescAddress = serverMsg.Address + offset * 4;
|
||||
|
||||
serverProcess.CpuMemory.WriteUInt32(serverDescAddress + 0, descWord0);
|
||||
serverProcess.CpuMemory.WriteUInt32(serverDescAddress + 4, descWord1);
|
||||
serverProcess.CpuMemory.WriteUInt32(serverDescAddress + 8, descWord2);
|
||||
serverProcess.CpuMemory.Write(serverDescAddress + 0, descWord0);
|
||||
serverProcess.CpuMemory.Write(serverDescAddress + 4, descWord1);
|
||||
serverProcess.CpuMemory.Write(serverDescAddress + 8, descWord2);
|
||||
|
||||
offset += 3;
|
||||
}
|
||||
|
@ -700,8 +700,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
}
|
||||
|
||||
// Copy header.
|
||||
System.Device.Memory.WriteUInt32((long)clientMsg.DramAddress + 0, serverHeader.Word0);
|
||||
System.Device.Memory.WriteUInt32((long)clientMsg.DramAddress + 4, serverHeader.Word1);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + 0, serverHeader.Word0);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + 4, serverHeader.Word1);
|
||||
|
||||
// Copy handles.
|
||||
uint offset;
|
||||
|
@ -710,11 +710,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
offset = 3;
|
||||
|
||||
System.Device.Memory.WriteUInt32((long)clientMsg.DramAddress + 8, serverHeader.Word2);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + 8, serverHeader.Word2);
|
||||
|
||||
if (serverHeader.HasPid)
|
||||
{
|
||||
System.Device.Memory.WriteInt64((long)clientMsg.DramAddress + offset * 4, serverProcess.Pid);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + offset * 4, serverProcess.Pid);
|
||||
|
||||
offset += 2;
|
||||
}
|
||||
|
@ -723,14 +723,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
int newHandle = 0;
|
||||
|
||||
int handle = serverProcess.CpuMemory.ReadInt32((long)serverMsg.Address + offset * 4);
|
||||
int handle = serverProcess.CpuMemory.Read<int>(serverMsg.Address + offset * 4);
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
GetCopyObjectHandle(serverThread, clientProcess, handle, out newHandle);
|
||||
}
|
||||
|
||||
System.Device.Memory.WriteInt32((long)clientMsg.DramAddress + offset * 4, newHandle);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + offset * 4, newHandle);
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
@ -739,7 +739,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
int newHandle = 0;
|
||||
|
||||
int handle = serverProcess.CpuMemory.ReadInt32((long)serverMsg.Address + offset * 4);
|
||||
int handle = serverProcess.CpuMemory.Read<int>(serverMsg.Address + offset * 4);
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
|
@ -753,7 +753,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
}
|
||||
}
|
||||
|
||||
System.Device.Memory.WriteInt32((long)clientMsg.DramAddress + offset * 4, newHandle);
|
||||
System.Device.Memory.Write(clientMsg.DramAddress + offset * 4, newHandle);
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
for (int index = 0; index < serverHeader.PointerBuffersCount; index++)
|
||||
{
|
||||
ulong pointerDesc = serverProcess.CpuMemory.ReadUInt64((long)serverMsg.Address + offset * 4);
|
||||
ulong pointerDesc = serverProcess.CpuMemory.Read<ulong>(serverMsg.Address + offset * 4);
|
||||
|
||||
PointerBufferDesc descriptor = new PointerBufferDesc(pointerDesc);
|
||||
|
||||
|
@ -819,11 +819,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
for (int index = 0; index < totalBuffersCount; index++)
|
||||
{
|
||||
long dstDescAddress = (long)clientMsg.DramAddress + offset * 4;
|
||||
ulong dstDescAddress = clientMsg.DramAddress + offset * 4;
|
||||
|
||||
System.Device.Memory.WriteUInt32(dstDescAddress + 0, 0);
|
||||
System.Device.Memory.WriteUInt32(dstDescAddress + 4, 0);
|
||||
System.Device.Memory.WriteUInt32(dstDescAddress + 8, 0);
|
||||
System.Device.Memory.Write(dstDescAddress + 0, 0);
|
||||
System.Device.Memory.Write(dstDescAddress + 4, 0);
|
||||
System.Device.Memory.Write(dstDescAddress + 8, 0);
|
||||
|
||||
offset += 3;
|
||||
}
|
||||
|
@ -878,9 +878,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
private MessageHeader GetClientMessageHeader(Message clientMsg)
|
||||
{
|
||||
uint word0 = System.Device.Memory.ReadUInt32((long)clientMsg.DramAddress + 0);
|
||||
uint word1 = System.Device.Memory.ReadUInt32((long)clientMsg.DramAddress + 4);
|
||||
uint word2 = System.Device.Memory.ReadUInt32((long)clientMsg.DramAddress + 8);
|
||||
uint word0 = System.Device.Memory.Read<uint>(clientMsg.DramAddress + 0);
|
||||
uint word1 = System.Device.Memory.Read<uint>(clientMsg.DramAddress + 4);
|
||||
uint word2 = System.Device.Memory.Read<uint>(clientMsg.DramAddress + 8);
|
||||
|
||||
return new MessageHeader(word0, word1, word2);
|
||||
}
|
||||
|
@ -889,9 +889,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
{
|
||||
KProcess currentProcess = System.Scheduler.GetCurrentProcess();
|
||||
|
||||
uint word0 = currentProcess.CpuMemory.ReadUInt32((long)serverMsg.Address + 0);
|
||||
uint word1 = currentProcess.CpuMemory.ReadUInt32((long)serverMsg.Address + 4);
|
||||
uint word2 = currentProcess.CpuMemory.ReadUInt32((long)serverMsg.Address + 8);
|
||||
uint word0 = currentProcess.CpuMemory.Read<uint>(serverMsg.Address + 0);
|
||||
uint word1 = currentProcess.CpuMemory.Read<uint>(serverMsg.Address + 4);
|
||||
uint word2 = currentProcess.CpuMemory.Read<uint>(serverMsg.Address + 8);
|
||||
|
||||
return new MessageHeader(word0, word1, word2);
|
||||
}
|
||||
|
@ -970,11 +970,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
ulong[] receiveList = new ulong[recvListSize];
|
||||
|
||||
long recvListAddress = (long)message.DramAddress + recvListOffset;
|
||||
ulong recvListAddress = message.DramAddress + recvListOffset;
|
||||
|
||||
for (int index = 0; index < recvListSize; index++)
|
||||
{
|
||||
receiveList[index] = System.Device.Memory.ReadUInt64(recvListAddress + index * 8);
|
||||
receiveList[index] = System.Device.Memory.Read<ulong>(recvListAddress + (ulong)index * 8);
|
||||
}
|
||||
|
||||
return receiveList;
|
||||
|
@ -1067,20 +1067,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
if (header.HasPid)
|
||||
{
|
||||
process.CpuMemory.WriteInt64((long)message.Address + offset * 4, 0);
|
||||
process.CpuMemory.Write(message.Address + offset * 4, 0L);
|
||||
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
for (int index = 0; index < totalHandeslCount; index++)
|
||||
{
|
||||
int handle = process.CpuMemory.ReadInt32((long)message.Address + offset * 4);
|
||||
int handle = process.CpuMemory.Read<int>(message.Address + offset * 4);
|
||||
|
||||
if (handle != 0)
|
||||
{
|
||||
process.HandleTable.CloseHandle(handle);
|
||||
|
||||
process.CpuMemory.WriteInt32((long)message.Address + offset * 4, 0);
|
||||
process.CpuMemory.Write(message.Address + offset * 4, 0);
|
||||
}
|
||||
|
||||
offset++;
|
||||
|
@ -1225,8 +1225,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
|
|||
|
||||
ulong address = clientProcess.MemoryManager.GetDramAddressFromVa(request.CustomCmdBuffAddr);
|
||||
|
||||
System.Device.Memory.WriteInt64((long)address + 0, 0);
|
||||
System.Device.Memory.WriteInt32((long)address + 8, (int)result);
|
||||
System.Device.Memory.Write<ulong>(address, 0);
|
||||
System.Device.Memory.Write(address + 8, (int)result);
|
||||
|
||||
clientProcess.MemoryManager.UnborrowIpcBuffer(
|
||||
request.CustomCmdBuffAddr,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using System;
|
||||
|
@ -1843,7 +1843,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong unusedSizeBefore = address - addressTruncated;
|
||||
|
||||
_system.Device.Memory.Set(dstFirstPagePa, 0, unusedSizeBefore);
|
||||
_system.Device.Memory.ZeroFill(dstFirstPagePa, unusedSizeBefore);
|
||||
|
||||
ulong copySize = addressRounded <= endAddr ? addressRounded - address : size;
|
||||
|
||||
|
@ -1862,7 +1862,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
if (unusedSizeAfter != 0)
|
||||
{
|
||||
_system.Device.Memory.Set(firstPageFillAddress, 0, unusedSizeAfter);
|
||||
_system.Device.Memory.ZeroFill(firstPageFillAddress, unusedSizeAfter);
|
||||
}
|
||||
|
||||
KPageList pages = new KPageList();
|
||||
|
@ -1922,7 +1922,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
unusedSizeAfter = PageSize;
|
||||
}
|
||||
|
||||
_system.Device.Memory.Set(lastPageFillAddr, 0, unusedSizeAfter);
|
||||
_system.Device.Memory.ZeroFill(lastPageFillAddr, unusedSizeAfter);
|
||||
|
||||
if (pages.AddRange(dstFirstPagePa, 1) != KernelResult.Success)
|
||||
{
|
||||
|
@ -3041,7 +3041,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong size = pagesCount * PageSize;
|
||||
|
||||
_cpuMemory.Map((long)dstVa, (long)(srcPa - DramMemoryMap.DramBase), (long)size);
|
||||
_cpuMemory.Map(dstVa, srcPa - DramMemoryMap.DramBase, size);
|
||||
|
||||
result = KernelResult.Success;
|
||||
|
||||
|
@ -3066,7 +3066,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong size = pagesCount * PageSize;
|
||||
|
||||
_cpuMemory.Unmap((long)dstVa, (long)size);
|
||||
_cpuMemory.Unmap(dstVa, size);
|
||||
|
||||
result = KernelResult.Success;
|
||||
|
||||
|
@ -3108,7 +3108,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
{
|
||||
ulong size = pageNode.PagesCount * PageSize;
|
||||
|
||||
_cpuMemory.Map((long)address, (long)(pageNode.Address - DramMemoryMap.DramBase), (long)size);
|
||||
_cpuMemory.Map(address, pageNode.Address - DramMemoryMap.DramBase, size);
|
||||
|
||||
address += size;
|
||||
}
|
||||
|
@ -3118,12 +3118,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|||
|
||||
public ulong GetDramAddressFromVa(ulong va)
|
||||
{
|
||||
return (ulong)_cpuMemory.GetPhysicalAddress((long)va);
|
||||
return _cpuMemory.GetPhysicalAddress(va);
|
||||
}
|
||||
|
||||
public bool ConvertVaToPa(ulong va, out ulong pa)
|
||||
{
|
||||
pa = DramMemoryMap.DramBase + (ulong)_cpuMemory.GetPhysicalAddress((long)va);
|
||||
pa = DramMemoryMap.DramBase + _cpuMemory.GetPhysicalAddress(va);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Diagnostics.Demangler;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.HLE.Loaders.Elf;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -20,11 +17,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
|
||||
private class Image
|
||||
{
|
||||
public long BaseAddress { get; private set; }
|
||||
public ulong BaseAddress { get; }
|
||||
|
||||
public ElfSymbol[] Symbols { get; private set; }
|
||||
public ElfSymbol[] Symbols { get; }
|
||||
|
||||
public Image(long baseAddress, ElfSymbol[] symbols)
|
||||
public Image(ulong baseAddress, ElfSymbol[] symbols)
|
||||
{
|
||||
BaseAddress = baseAddress;
|
||||
Symbols = symbols;
|
||||
|
@ -48,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
|
||||
StringBuilder trace = new StringBuilder();
|
||||
|
||||
void AppendTrace(long address)
|
||||
void AppendTrace(ulong address)
|
||||
{
|
||||
Image image = GetImage(address, out int imageIndex);
|
||||
|
||||
|
@ -63,7 +60,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
|
||||
if (image != null)
|
||||
{
|
||||
long offset = address - image.BaseAddress;
|
||||
ulong offset = address - image.BaseAddress;
|
||||
|
||||
string imageName = GetGuessedNsoNameFromIndex(imageIndex);
|
||||
|
||||
|
@ -79,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
|
||||
if (context.IsAarch32)
|
||||
{
|
||||
long framePointer = (long)context.GetX(11);
|
||||
ulong framePointer = context.GetX(11);
|
||||
|
||||
while (framePointer != 0)
|
||||
{
|
||||
|
@ -90,14 +87,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
break;
|
||||
}
|
||||
|
||||
AppendTrace(_owner.CpuMemory.ReadInt32(framePointer + 4));
|
||||
AppendTrace(_owner.CpuMemory.Read<uint>(framePointer + 4));
|
||||
|
||||
framePointer = _owner.CpuMemory.ReadInt32(framePointer);
|
||||
framePointer = _owner.CpuMemory.Read<uint>(framePointer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
long framePointer = (long)context.GetX(29);
|
||||
ulong framePointer = context.GetX(29);
|
||||
|
||||
while (framePointer != 0)
|
||||
{
|
||||
|
@ -108,16 +105,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
break;
|
||||
}
|
||||
|
||||
AppendTrace(_owner.CpuMemory.ReadInt64(framePointer + 8));
|
||||
AppendTrace(_owner.CpuMemory.Read<ulong>(framePointer + 8));
|
||||
|
||||
framePointer = _owner.CpuMemory.ReadInt64(framePointer);
|
||||
framePointer = _owner.CpuMemory.Read<ulong>(framePointer);
|
||||
}
|
||||
}
|
||||
|
||||
return trace.ToString();
|
||||
}
|
||||
|
||||
private bool TryGetSubName(Image image, long address, out string name)
|
||||
private bool TryGetSubName(Image image, ulong address, out string name)
|
||||
{
|
||||
address -= image.BaseAddress;
|
||||
|
||||
|
@ -156,13 +153,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
return false;
|
||||
}
|
||||
|
||||
private Image GetImage(long address, out int index)
|
||||
private Image GetImage(ulong address, out int index)
|
||||
{
|
||||
lock (_images)
|
||||
{
|
||||
for (index = _images.Count - 1; index >= 0; index--)
|
||||
{
|
||||
if ((ulong)address >= (ulong)_images[index].BaseAddress)
|
||||
if (address >= _images[index].BaseAddress)
|
||||
{
|
||||
return _images[index];
|
||||
}
|
||||
|
@ -229,7 +226,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
|
||||
if (info.State == MemoryState.CodeStatic && info.Permission == MemoryPermission.ReadAndExecute)
|
||||
{
|
||||
LoadMod0Symbols(_owner.CpuMemory, (long)info.Address);
|
||||
LoadMod0Symbols(_owner.CpuMemory, info.Address);
|
||||
}
|
||||
|
||||
oldAddress = address;
|
||||
|
@ -238,54 +235,53 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
}
|
||||
}
|
||||
|
||||
private void LoadMod0Symbols(MemoryManager memory, long textOffset)
|
||||
private void LoadMod0Symbols(MemoryManager memory, ulong textOffset)
|
||||
{
|
||||
long mod0Offset = textOffset + memory.ReadUInt32(textOffset + 4);
|
||||
ulong mod0Offset = textOffset + memory.Read<uint>(textOffset + 4);
|
||||
|
||||
if (mod0Offset < textOffset || !memory.IsMapped(mod0Offset) || (mod0Offset & 3) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<ElfDynamicTag, long> dynamic = new Dictionary<ElfDynamicTag, long>();
|
||||
Dictionary<ElfDynamicTag, ulong> dynamic = new Dictionary<ElfDynamicTag, ulong>();
|
||||
|
||||
int mod0Magic = memory.ReadInt32(mod0Offset + 0x0);
|
||||
int mod0Magic = memory.Read<int>(mod0Offset + 0x0);
|
||||
|
||||
if (mod0Magic != Mod0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long dynamicOffset = memory.ReadInt32(mod0Offset + 0x4) + mod0Offset;
|
||||
long bssStartOffset = memory.ReadInt32(mod0Offset + 0x8) + mod0Offset;
|
||||
long bssEndOffset = memory.ReadInt32(mod0Offset + 0xc) + mod0Offset;
|
||||
long ehHdrStartOffset = memory.ReadInt32(mod0Offset + 0x10) + mod0Offset;
|
||||
long ehHdrEndOffset = memory.ReadInt32(mod0Offset + 0x14) + mod0Offset;
|
||||
long modObjOffset = memory.ReadInt32(mod0Offset + 0x18) + mod0Offset;
|
||||
ulong dynamicOffset = memory.Read<uint>(mod0Offset + 0x4) + mod0Offset;
|
||||
ulong bssStartOffset = memory.Read<uint>(mod0Offset + 0x8) + mod0Offset;
|
||||
ulong bssEndOffset = memory.Read<uint>(mod0Offset + 0xc) + mod0Offset;
|
||||
ulong ehHdrStartOffset = memory.Read<uint>(mod0Offset + 0x10) + mod0Offset;
|
||||
ulong ehHdrEndOffset = memory.Read<uint>(mod0Offset + 0x14) + mod0Offset;
|
||||
ulong modObjOffset = memory.Read<uint>(mod0Offset + 0x18) + mod0Offset;
|
||||
|
||||
bool isAArch32 = memory.ReadUInt64(dynamicOffset) > 0xFFFFFFFF || memory.ReadUInt64(dynamicOffset + 0x10) > 0xFFFFFFFF;
|
||||
bool isAArch32 = memory.Read<ulong>(dynamicOffset) > 0xFFFFFFFF || memory.Read<ulong>(dynamicOffset + 0x10) > 0xFFFFFFFF;
|
||||
|
||||
while (true)
|
||||
{
|
||||
long tagVal;
|
||||
long value;
|
||||
ulong tagVal;
|
||||
ulong value;
|
||||
|
||||
if (isAArch32)
|
||||
{
|
||||
tagVal = memory.ReadInt32(dynamicOffset + 0);
|
||||
value = memory.ReadInt32(dynamicOffset + 4);
|
||||
tagVal = memory.Read<uint>(dynamicOffset + 0);
|
||||
value = memory.Read<uint>(dynamicOffset + 4);
|
||||
|
||||
dynamicOffset += 0x8;
|
||||
}
|
||||
else
|
||||
{
|
||||
tagVal = memory.ReadInt64(dynamicOffset + 0);
|
||||
value = memory.ReadInt64(dynamicOffset + 8);
|
||||
tagVal = memory.Read<ulong>(dynamicOffset + 0);
|
||||
value = memory.Read<ulong>(dynamicOffset + 8);
|
||||
|
||||
dynamicOffset += 0x10;
|
||||
}
|
||||
|
||||
|
||||
ElfDynamicTag tag = (ElfDynamicTag)tagVal;
|
||||
|
||||
if (tag == ElfDynamicTag.DT_NULL)
|
||||
|
@ -296,19 +292,19 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
dynamic[tag] = value;
|
||||
}
|
||||
|
||||
if (!dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out long strTab) ||
|
||||
!dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out long symTab) ||
|
||||
!dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out long symEntSize))
|
||||
if (!dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out ulong strTab) ||
|
||||
!dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out ulong symTab) ||
|
||||
!dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out ulong symEntSize))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long strTblAddr = textOffset + strTab;
|
||||
long symTblAddr = textOffset + symTab;
|
||||
ulong strTblAddr = textOffset + strTab;
|
||||
ulong symTblAddr = textOffset + symTab;
|
||||
|
||||
List<ElfSymbol> symbols = new List<ElfSymbol>();
|
||||
|
||||
while ((ulong)symTblAddr < (ulong)strTblAddr)
|
||||
while (symTblAddr < strTblAddr)
|
||||
{
|
||||
ElfSymbol sym = isAArch32 ? GetSymbol32(memory, symTblAddr, strTblAddr) : GetSymbol64(memory, symTblAddr, strTblAddr);
|
||||
|
||||
|
@ -323,42 +319,36 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
}
|
||||
}
|
||||
|
||||
private ElfSymbol GetSymbol64(MemoryManager memory, long address, long strTblAddr)
|
||||
private ElfSymbol GetSymbol64(MemoryManager memory, ulong address, ulong strTblAddr)
|
||||
{
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(memory.ReadBytes(address, Unsafe.SizeOf<ElfSymbol64>()))))
|
||||
ElfSymbol64 sym = memory.Read<ElfSymbol64>(address);
|
||||
|
||||
uint nameIndex = sym.NameOffset;
|
||||
|
||||
string name = string.Empty;
|
||||
|
||||
for (int chr; (chr = memory.Read<byte>(strTblAddr + nameIndex++)) != 0;)
|
||||
{
|
||||
ElfSymbol64 sym = inputStream.ReadStruct<ElfSymbol64>();
|
||||
|
||||
uint nameIndex = sym.NameOffset;
|
||||
|
||||
string name = string.Empty;
|
||||
|
||||
for (int chr; (chr = memory.ReadByte(strTblAddr + nameIndex++)) != 0;)
|
||||
{
|
||||
name += (char)chr;
|
||||
}
|
||||
|
||||
return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size);
|
||||
name += (char)chr;
|
||||
}
|
||||
|
||||
return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size);
|
||||
}
|
||||
|
||||
private ElfSymbol GetSymbol32(MemoryManager memory, long address, long strTblAddr)
|
||||
private ElfSymbol GetSymbol32(MemoryManager memory, ulong address, ulong strTblAddr)
|
||||
{
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(memory.ReadBytes(address, Unsafe.SizeOf<ElfSymbol32>()))))
|
||||
ElfSymbol32 sym = memory.Read<ElfSymbol32>(address);
|
||||
|
||||
uint nameIndex = sym.NameOffset;
|
||||
|
||||
string name = string.Empty;
|
||||
|
||||
for (int chr; (chr = memory.Read<byte>(strTblAddr + nameIndex++)) != 0;)
|
||||
{
|
||||
ElfSymbol32 sym = inputStream.ReadStruct<ElfSymbol32>();
|
||||
|
||||
uint nameIndex = sym.NameOffset;
|
||||
|
||||
string name = string.Empty;
|
||||
|
||||
for (int chr; (chr = memory.ReadByte(strTblAddr + nameIndex++)) != 0;)
|
||||
{
|
||||
name += (char)chr;
|
||||
}
|
||||
|
||||
return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size);
|
||||
name += (char)chr;
|
||||
}
|
||||
|
||||
return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using ARMeilleure.State;
|
||||
using ARMeilleure.Translation;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.Exceptions;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
|
@ -79,8 +78,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
public bool IsPaused { get; private set; }
|
||||
|
||||
public MemoryManager CpuMemory { get; private set; }
|
||||
|
||||
public Translator Translator { get; private set; }
|
||||
public CpuContext CpuContext { get; private set; }
|
||||
|
||||
private SvcHandler _svcHandler;
|
||||
|
||||
|
@ -1109,11 +1107,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||
default: throw new ArgumentException(nameof(addrSpaceType));
|
||||
}
|
||||
|
||||
bool useFlatPageTable = memRegion == MemoryRegion.Application;
|
||||
|
||||
CpuMemory = new MemoryManager(_system.Device.Memory.RamPointer, addrSpaceBits, useFlatPageTable);
|
||||
|
||||
Translator = new Translator(CpuMemory);
|
||||
CpuMemory = new MemoryManager(_system.Device.Memory, 1UL << addrSpaceBits);
|
||||
CpuContext = new CpuContext(CpuMemory);
|
||||
|
||||
// TODO: This should eventually be removed.
|
||||
// The GPU shouldn't depend on the CPU memory manager at all.
|
||||
|
|
|
@ -108,7 +108,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
|||
|
||||
private KernelResult SendSyncRequest(ulong messagePtr, ulong size, int handle)
|
||||
{
|
||||
byte[] messageData = _process.CpuMemory.ReadBytes((long)messagePtr, (long)size);
|
||||
byte[] messageData = new byte[size];
|
||||
|
||||
_process.CpuMemory.Read(messagePtr, messageData);
|
||||
|
||||
KClientSession clientSession = _process.HandleTable.GetObject<KClientSession>(handle);
|
||||
|
||||
|
|
|
@ -191,14 +191,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
|||
{
|
||||
KMemoryInfo blkInfo = _process.MemoryManager.QueryMemory(position);
|
||||
|
||||
_process.CpuMemory.WriteUInt64((long)infoPtr + 0x00, blkInfo.Address);
|
||||
_process.CpuMemory.WriteUInt64((long)infoPtr + 0x08, blkInfo.Size);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x10, (int)blkInfo.State & 0xff);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x14, (int)blkInfo.Attribute);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x18, (int)blkInfo.Permission);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x1c, blkInfo.IpcRefCount);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x20, blkInfo.DeviceRefCount);
|
||||
_process.CpuMemory.WriteInt32 ((long)infoPtr + 0x24, 0);
|
||||
_process.CpuMemory.Write(infoPtr + 0x00, blkInfo.Address);
|
||||
_process.CpuMemory.Write(infoPtr + 0x08, blkInfo.Size);
|
||||
_process.CpuMemory.Write(infoPtr + 0x10, (int)blkInfo.State & 0xff);
|
||||
_process.CpuMemory.Write(infoPtr + 0x14, (int)blkInfo.Attribute);
|
||||
_process.CpuMemory.Write(infoPtr + 0x18, (int)blkInfo.Permission);
|
||||
_process.CpuMemory.Write(infoPtr + 0x1c, blkInfo.IpcRefCount);
|
||||
_process.CpuMemory.Write(infoPtr + 0x20, blkInfo.DeviceRefCount);
|
||||
_process.CpuMemory.Write(infoPtr + 0x24, 0);
|
||||
|
||||
pageInfo = 0;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.Exceptions;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Ipc;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
|
@ -432,79 +432,79 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
|||
|
||||
MemoryManager memory = currentProcess.CpuMemory;
|
||||
|
||||
memory.WriteUInt64((long)address + 0x0, thread.Context.GetX(0));
|
||||
memory.WriteUInt64((long)address + 0x8, thread.Context.GetX(1));
|
||||
memory.WriteUInt64((long)address + 0x10, thread.Context.GetX(2));
|
||||
memory.WriteUInt64((long)address + 0x18, thread.Context.GetX(3));
|
||||
memory.WriteUInt64((long)address + 0x20, thread.Context.GetX(4));
|
||||
memory.WriteUInt64((long)address + 0x28, thread.Context.GetX(5));
|
||||
memory.WriteUInt64((long)address + 0x30, thread.Context.GetX(6));
|
||||
memory.WriteUInt64((long)address + 0x38, thread.Context.GetX(7));
|
||||
memory.WriteUInt64((long)address + 0x40, thread.Context.GetX(8));
|
||||
memory.WriteUInt64((long)address + 0x48, thread.Context.GetX(9));
|
||||
memory.WriteUInt64((long)address + 0x50, thread.Context.GetX(10));
|
||||
memory.WriteUInt64((long)address + 0x58, thread.Context.GetX(11));
|
||||
memory.WriteUInt64((long)address + 0x60, thread.Context.GetX(12));
|
||||
memory.WriteUInt64((long)address + 0x68, thread.Context.GetX(13));
|
||||
memory.WriteUInt64((long)address + 0x70, thread.Context.GetX(14));
|
||||
memory.WriteUInt64((long)address + 0x78, thread.Context.GetX(15));
|
||||
memory.WriteUInt64((long)address + 0x80, thread.Context.GetX(16));
|
||||
memory.WriteUInt64((long)address + 0x88, thread.Context.GetX(17));
|
||||
memory.WriteUInt64((long)address + 0x90, thread.Context.GetX(18));
|
||||
memory.WriteUInt64((long)address + 0x98, thread.Context.GetX(19));
|
||||
memory.WriteUInt64((long)address + 0xa0, thread.Context.GetX(20));
|
||||
memory.WriteUInt64((long)address + 0xa8, thread.Context.GetX(21));
|
||||
memory.WriteUInt64((long)address + 0xb0, thread.Context.GetX(22));
|
||||
memory.WriteUInt64((long)address + 0xb8, thread.Context.GetX(23));
|
||||
memory.WriteUInt64((long)address + 0xc0, thread.Context.GetX(24));
|
||||
memory.WriteUInt64((long)address + 0xc8, thread.Context.GetX(25));
|
||||
memory.WriteUInt64((long)address + 0xd0, thread.Context.GetX(26));
|
||||
memory.WriteUInt64((long)address + 0xd8, thread.Context.GetX(27));
|
||||
memory.WriteUInt64((long)address + 0xe0, thread.Context.GetX(28));
|
||||
memory.WriteUInt64((long)address + 0xe8, thread.Context.GetX(29));
|
||||
memory.WriteUInt64((long)address + 0xf0, thread.Context.GetX(30));
|
||||
memory.WriteUInt64((long)address + 0xf8, thread.Context.GetX(31));
|
||||
memory.Write(address + 0x0, thread.Context.GetX(0));
|
||||
memory.Write(address + 0x8, thread.Context.GetX(1));
|
||||
memory.Write(address + 0x10, thread.Context.GetX(2));
|
||||
memory.Write(address + 0x18, thread.Context.GetX(3));
|
||||
memory.Write(address + 0x20, thread.Context.GetX(4));
|
||||
memory.Write(address + 0x28, thread.Context.GetX(5));
|
||||
memory.Write(address + 0x30, thread.Context.GetX(6));
|
||||
memory.Write(address + 0x38, thread.Context.GetX(7));
|
||||
memory.Write(address + 0x40, thread.Context.GetX(8));
|
||||
memory.Write(address + 0x48, thread.Context.GetX(9));
|
||||
memory.Write(address + 0x50, thread.Context.GetX(10));
|
||||
memory.Write(address + 0x58, thread.Context.GetX(11));
|
||||
memory.Write(address + 0x60, thread.Context.GetX(12));
|
||||
memory.Write(address + 0x68, thread.Context.GetX(13));
|
||||
memory.Write(address + 0x70, thread.Context.GetX(14));
|
||||
memory.Write(address + 0x78, thread.Context.GetX(15));
|
||||
memory.Write(address + 0x80, thread.Context.GetX(16));
|
||||
memory.Write(address + 0x88, thread.Context.GetX(17));
|
||||
memory.Write(address + 0x90, thread.Context.GetX(18));
|
||||
memory.Write(address + 0x98, thread.Context.GetX(19));
|
||||
memory.Write(address + 0xa0, thread.Context.GetX(20));
|
||||
memory.Write(address + 0xa8, thread.Context.GetX(21));
|
||||
memory.Write(address + 0xb0, thread.Context.GetX(22));
|
||||
memory.Write(address + 0xb8, thread.Context.GetX(23));
|
||||
memory.Write(address + 0xc0, thread.Context.GetX(24));
|
||||
memory.Write(address + 0xc8, thread.Context.GetX(25));
|
||||
memory.Write(address + 0xd0, thread.Context.GetX(26));
|
||||
memory.Write(address + 0xd8, thread.Context.GetX(27));
|
||||
memory.Write(address + 0xe0, thread.Context.GetX(28));
|
||||
memory.Write(address + 0xe8, thread.Context.GetX(29));
|
||||
memory.Write(address + 0xf0, thread.Context.GetX(30));
|
||||
memory.Write(address + 0xf8, thread.Context.GetX(31));
|
||||
|
||||
memory.WriteInt64((long)address + 0x100, thread.LastPc);
|
||||
memory.Write(address + 0x100, thread.LastPc);
|
||||
|
||||
memory.WriteUInt64((long)address + 0x108, (ulong)GetPsr(thread.Context));
|
||||
memory.Write(address + 0x108, (ulong)GetPsr(thread.Context));
|
||||
|
||||
memory.WriteVector128((long)address + 0x110, thread.Context.GetV(0));
|
||||
memory.WriteVector128((long)address + 0x120, thread.Context.GetV(1));
|
||||
memory.WriteVector128((long)address + 0x130, thread.Context.GetV(2));
|
||||
memory.WriteVector128((long)address + 0x140, thread.Context.GetV(3));
|
||||
memory.WriteVector128((long)address + 0x150, thread.Context.GetV(4));
|
||||
memory.WriteVector128((long)address + 0x160, thread.Context.GetV(5));
|
||||
memory.WriteVector128((long)address + 0x170, thread.Context.GetV(6));
|
||||
memory.WriteVector128((long)address + 0x180, thread.Context.GetV(7));
|
||||
memory.WriteVector128((long)address + 0x190, thread.Context.GetV(8));
|
||||
memory.WriteVector128((long)address + 0x1a0, thread.Context.GetV(9));
|
||||
memory.WriteVector128((long)address + 0x1b0, thread.Context.GetV(10));
|
||||
memory.WriteVector128((long)address + 0x1c0, thread.Context.GetV(11));
|
||||
memory.WriteVector128((long)address + 0x1d0, thread.Context.GetV(12));
|
||||
memory.WriteVector128((long)address + 0x1e0, thread.Context.GetV(13));
|
||||
memory.WriteVector128((long)address + 0x1f0, thread.Context.GetV(14));
|
||||
memory.WriteVector128((long)address + 0x200, thread.Context.GetV(15));
|
||||
memory.WriteVector128((long)address + 0x210, thread.Context.GetV(16));
|
||||
memory.WriteVector128((long)address + 0x220, thread.Context.GetV(17));
|
||||
memory.WriteVector128((long)address + 0x230, thread.Context.GetV(18));
|
||||
memory.WriteVector128((long)address + 0x240, thread.Context.GetV(19));
|
||||
memory.WriteVector128((long)address + 0x250, thread.Context.GetV(20));
|
||||
memory.WriteVector128((long)address + 0x260, thread.Context.GetV(21));
|
||||
memory.WriteVector128((long)address + 0x270, thread.Context.GetV(22));
|
||||
memory.WriteVector128((long)address + 0x280, thread.Context.GetV(23));
|
||||
memory.WriteVector128((long)address + 0x290, thread.Context.GetV(24));
|
||||
memory.WriteVector128((long)address + 0x2a0, thread.Context.GetV(25));
|
||||
memory.WriteVector128((long)address + 0x2b0, thread.Context.GetV(26));
|
||||
memory.WriteVector128((long)address + 0x2c0, thread.Context.GetV(27));
|
||||
memory.WriteVector128((long)address + 0x2d0, thread.Context.GetV(28));
|
||||
memory.WriteVector128((long)address + 0x2e0, thread.Context.GetV(29));
|
||||
memory.WriteVector128((long)address + 0x2f0, thread.Context.GetV(30));
|
||||
memory.WriteVector128((long)address + 0x300, thread.Context.GetV(31));
|
||||
memory.Write(address + 0x110, thread.Context.GetV(0));
|
||||
memory.Write(address + 0x120, thread.Context.GetV(1));
|
||||
memory.Write(address + 0x130, thread.Context.GetV(2));
|
||||
memory.Write(address + 0x140, thread.Context.GetV(3));
|
||||
memory.Write(address + 0x150, thread.Context.GetV(4));
|
||||
memory.Write(address + 0x160, thread.Context.GetV(5));
|
||||
memory.Write(address + 0x170, thread.Context.GetV(6));
|
||||
memory.Write(address + 0x180, thread.Context.GetV(7));
|
||||
memory.Write(address + 0x190, thread.Context.GetV(8));
|
||||
memory.Write(address + 0x1a0, thread.Context.GetV(9));
|
||||
memory.Write(address + 0x1b0, thread.Context.GetV(10));
|
||||
memory.Write(address + 0x1c0, thread.Context.GetV(11));
|
||||
memory.Write(address + 0x1d0, thread.Context.GetV(12));
|
||||
memory.Write(address + 0x1e0, thread.Context.GetV(13));
|
||||
memory.Write(address + 0x1f0, thread.Context.GetV(14));
|
||||
memory.Write(address + 0x200, thread.Context.GetV(15));
|
||||
memory.Write(address + 0x210, thread.Context.GetV(16));
|
||||
memory.Write(address + 0x220, thread.Context.GetV(17));
|
||||
memory.Write(address + 0x230, thread.Context.GetV(18));
|
||||
memory.Write(address + 0x240, thread.Context.GetV(19));
|
||||
memory.Write(address + 0x250, thread.Context.GetV(20));
|
||||
memory.Write(address + 0x260, thread.Context.GetV(21));
|
||||
memory.Write(address + 0x270, thread.Context.GetV(22));
|
||||
memory.Write(address + 0x280, thread.Context.GetV(23));
|
||||
memory.Write(address + 0x290, thread.Context.GetV(24));
|
||||
memory.Write(address + 0x2a0, thread.Context.GetV(25));
|
||||
memory.Write(address + 0x2b0, thread.Context.GetV(26));
|
||||
memory.Write(address + 0x2c0, thread.Context.GetV(27));
|
||||
memory.Write(address + 0x2d0, thread.Context.GetV(28));
|
||||
memory.Write(address + 0x2e0, thread.Context.GetV(29));
|
||||
memory.Write(address + 0x2f0, thread.Context.GetV(30));
|
||||
memory.Write(address + 0x300, thread.Context.GetV(31));
|
||||
|
||||
memory.WriteInt32((long)address + 0x310, (int)thread.Context.Fpcr);
|
||||
memory.WriteInt32((long)address + 0x314, (int)thread.Context.Fpsr);
|
||||
memory.WriteInt64((long)address + 0x318, thread.Context.Tpidr);
|
||||
memory.Write(address + 0x310, (int)thread.Context.Fpcr);
|
||||
memory.Write(address + 0x314, (int)thread.Context.Fpsr);
|
||||
memory.Write(address + 0x318, thread.Context.Tpidr);
|
||||
|
||||
return KernelResult.Success;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
|||
|
||||
for (int index = 0; index < handlesCount; index++)
|
||||
{
|
||||
int handle = _process.CpuMemory.ReadInt32((long)handlesPtr + index * 4);
|
||||
int handle = _process.CpuMemory.Read<int>(handlesPtr + (ulong)index * 4);
|
||||
|
||||
KSynchronizationObject syncObj = _process.HandleTable.GetObject<KSynchronizationObject>(handle);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ using Ryujinx.HLE.HOS.Kernel.Common;
|
|||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
{
|
||||
|
@ -228,18 +229,22 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (!currentProcess.CpuMemory.IsMapped(address))
|
||||
{
|
||||
// Invalid address.
|
||||
requester.SignaledObj = null;
|
||||
requester.ObjSyncResult = KernelResult.InvalidMemState;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
ref int mutexRef = ref currentProcess.CpuMemory.GetRef<int>(address);
|
||||
|
||||
int mutexValue, newMutexValue;
|
||||
|
||||
do
|
||||
{
|
||||
if (!KernelTransfer.UserToKernelInt32(_system, address, out mutexValue))
|
||||
{
|
||||
// Invalid address.
|
||||
requester.SignaledObj = null;
|
||||
requester.ObjSyncResult = KernelResult.InvalidMemState;
|
||||
|
||||
return null;
|
||||
}
|
||||
mutexValue = mutexRef;
|
||||
|
||||
if (mutexValue != 0)
|
||||
{
|
||||
|
@ -252,7 +257,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
newMutexValue = requester.ThreadHandleForUserMutex;
|
||||
}
|
||||
}
|
||||
while (!currentProcess.CpuMemory.AtomicCompareExchangeInt32((long)address, mutexValue, newMutexValue));
|
||||
while (Interlocked.CompareExchange(ref mutexRef, newMutexValue, mutexValue) != mutexValue);
|
||||
|
||||
if (mutexValue == 0)
|
||||
{
|
||||
|
@ -389,7 +394,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
if (shouldDecrement)
|
||||
{
|
||||
currentValue = currentProcess.CpuMemory.AtomicDecrementInt32((long)address) + 1;
|
||||
currentValue = Interlocked.Decrement(ref currentProcess.CpuMemory.GetRef<int>(address)) + 1;
|
||||
}
|
||||
|
||||
if (currentValue < value)
|
||||
|
@ -480,16 +485,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (!currentProcess.CpuMemory.IsMapped(address))
|
||||
{
|
||||
_system.CriticalSection.Leave();
|
||||
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
ref int valueRef = ref currentProcess.CpuMemory.GetRef<int>(address);
|
||||
|
||||
int currentValue;
|
||||
|
||||
do
|
||||
{
|
||||
if (!KernelTransfer.UserToKernelInt32(_system, address, out currentValue))
|
||||
{
|
||||
_system.CriticalSection.Leave();
|
||||
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
currentValue = valueRef;
|
||||
|
||||
if (currentValue != value)
|
||||
{
|
||||
|
@ -498,7 +507,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
return KernelResult.InvalidState;
|
||||
}
|
||||
}
|
||||
while (!currentProcess.CpuMemory.AtomicCompareExchangeInt32((long)address, currentValue, currentValue + 1));
|
||||
while (Interlocked.CompareExchange(ref valueRef, currentValue + 1, currentValue) != currentValue);
|
||||
|
||||
WakeArbiterThreads(address, count);
|
||||
|
||||
|
@ -537,16 +546,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (!currentProcess.CpuMemory.IsMapped(address))
|
||||
{
|
||||
_system.CriticalSection.Leave();
|
||||
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
|
||||
ref int valueRef = ref currentProcess.CpuMemory.GetRef<int>(address);
|
||||
|
||||
int currentValue;
|
||||
|
||||
do
|
||||
{
|
||||
if (!KernelTransfer.UserToKernelInt32(_system, address, out currentValue))
|
||||
{
|
||||
_system.CriticalSection.Leave();
|
||||
|
||||
return KernelResult.InvalidMemState;
|
||||
}
|
||||
currentValue = valueRef;
|
||||
|
||||
if (currentValue != value)
|
||||
{
|
||||
|
@ -555,7 +568,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
return KernelResult.InvalidState;
|
||||
}
|
||||
}
|
||||
while (!currentProcess.CpuMemory.AtomicCompareExchangeInt32((long)address, currentValue, currentValue + offset));
|
||||
while (Interlocked.CompareExchange(ref valueRef, currentValue + offset, currentValue) != currentValue);
|
||||
|
||||
WakeArbiterThreads(address, count);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using System;
|
||||
|
@ -163,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
HostThread = new Thread(customHostThreadStart ?? (() => ThreadStart(entrypoint)));
|
||||
|
||||
Context = new ARMeilleure.State.ExecutionContext();
|
||||
Context = CpuContext.CreateExecutionContext();
|
||||
|
||||
bool isAarch32 = (Owner.MmuFlags & 1) == 0;
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
|
||||
private void ThreadStart(ulong entrypoint)
|
||||
{
|
||||
Owner.Translator.Execute(Context, entrypoint);
|
||||
Owner.CpuContext.Execute(Context, entrypoint);
|
||||
|
||||
ThreadExit();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using LibHac;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
|
@ -270,9 +269,9 @@ namespace Ryujinx.HLE.HOS
|
|||
end = bssStart + (ulong)image.BssSize;
|
||||
}
|
||||
|
||||
process.CpuMemory.WriteBytes((long)textStart, image.Text);
|
||||
process.CpuMemory.WriteBytes((long)roStart, image.Ro);
|
||||
process.CpuMemory.WriteBytes((long)dataStart, image.Data);
|
||||
process.CpuMemory.Write(textStart, image.Text);
|
||||
process.CpuMemory.Write(roStart, image.Ro);
|
||||
process.CpuMemory.Write(dataStart, image.Data);
|
||||
|
||||
MemoryHelper.FillWithZeros(process.CpuMemory, (long)bssStart, image.BssSize);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Services.Arp;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -75,8 +75,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||
break;
|
||||
}
|
||||
|
||||
context.Memory.WriteInt64(outputPosition + (long)offset, userProfile.UserId.High);
|
||||
context.Memory.WriteInt64(outputPosition + (long)offset + 8, userProfile.UserId.Low);
|
||||
context.Memory.Write((ulong)outputPosition + offset, userProfile.UserId.High);
|
||||
context.Memory.Write((ulong)outputPosition + offset + 8, userProfile.UserId.Low);
|
||||
|
||||
offset += 0x10;
|
||||
}
|
||||
|
@ -240,7 +240,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||
return ResultCode.InvalidInputBufferSize;
|
||||
}
|
||||
|
||||
byte[] thumbnailBuffer = context.Memory.ReadBytes(inputPosition, inputSize);
|
||||
byte[] thumbnailBuffer = new byte[inputSize];
|
||||
|
||||
context.Memory.Read((ulong)inputPosition, thumbnailBuffer);
|
||||
|
||||
// TODO: Store thumbnailBuffer somewhere, in save data 0x8000000000000010 ?
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
@ -28,9 +28,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||
|
||||
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
|
||||
|
||||
context.Memory.WriteInt32(position, 0);
|
||||
context.Memory.WriteInt32(position + 4, 1);
|
||||
context.Memory.WriteInt64(position + 8, 1);
|
||||
context.Memory.Write((ulong)position, 0);
|
||||
context.Memory.Write((ulong)position + 4, 1);
|
||||
context.Memory.Write((ulong)position + 8, 1L);
|
||||
|
||||
return GetBase(context);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
|||
|
||||
_profilePictureStream.Read(profilePictureData, 0, profilePictureData.Length);
|
||||
|
||||
context.Memory.WriteBytes(bufferPosition, profilePictureData);
|
||||
context.Memory.Write((ulong)bufferPosition, profilePictureData);
|
||||
|
||||
context.ResponseData.Write(_profilePictureStream.Length);
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
|
|||
size = maxSize;
|
||||
}
|
||||
|
||||
byte[] data = context.Memory.ReadBytes(position, size);
|
||||
byte[] data = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, data);
|
||||
|
||||
Buffer.BlockCopy(data, 0, _storage.Data, (int)writePosition, (int)size);
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE
|
|||
|
||||
Buffer.BlockCopy(_storage.Data, (int)readPosition, data, 0, (int)size);
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
context.Memory.Write((ulong)position, data);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
|
@ -106,9 +106,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager
|
|||
context.Memory,
|
||||
position);
|
||||
|
||||
byte[] buffer = context.Memory.ReadBytes(
|
||||
data.SampleBufferPtr,
|
||||
data.SampleBufferSize);
|
||||
byte[] buffer = new byte[data.SampleBufferSize];
|
||||
|
||||
context.Memory.Read((ulong)data.SampleBufferPtr, buffer);
|
||||
|
||||
_audioOut.AppendBuffer(_track, tag, buffer);
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager
|
|||
tag = releasedBuffers[index];
|
||||
}
|
||||
|
||||
context.Memory.WriteInt64(position + index * 8, tag);
|
||||
context.Memory.Write((ulong)(position + index * 8), tag);
|
||||
}
|
||||
|
||||
context.ResponseData.Write(releasedBuffers.Length);
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
break;
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(position, buffer);
|
||||
context.Memory.Write((ulong)position, buffer);
|
||||
|
||||
position += buffer.Length;
|
||||
}
|
||||
|
@ -61,7 +61,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
long position = context.Request.SendBuff[0].Position;
|
||||
long size = context.Request.SendBuff[0].Size;
|
||||
|
||||
byte[] deviceNameBuffer = context.Memory.ReadBytes(position, size);
|
||||
byte[] deviceNameBuffer = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, deviceNameBuffer);
|
||||
|
||||
string deviceName = Encoding.ASCII.GetString(deviceNameBuffer);
|
||||
|
||||
|
@ -83,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
|
||||
if ((ulong)deviceNameBuffer.Length <= (ulong)size)
|
||||
{
|
||||
context.Memory.WriteBytes(position, deviceNameBuffer);
|
||||
context.Memory.Write((ulong)position, deviceNameBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -143,7 +145,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
break;
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(position, buffer);
|
||||
context.Memory.Write((ulong)position, buffer);
|
||||
|
||||
position += buffer.Length;
|
||||
}
|
||||
|
@ -159,7 +161,9 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
|
||||
(long position, long size) = context.Request.GetBufferType0x21();
|
||||
|
||||
byte[] deviceNameBuffer = context.Memory.ReadBytes(position, size);
|
||||
byte[] deviceNameBuffer = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, deviceNameBuffer);
|
||||
|
||||
string deviceName = Encoding.UTF8.GetString(deviceNameBuffer);
|
||||
|
||||
|
@ -191,7 +195,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
|
||||
if ((ulong)deviceNameBuffer.Length <= (ulong)size)
|
||||
{
|
||||
context.Memory.WriteBytes(position, deviceNameBuffer);
|
||||
context.Memory.Write((ulong)position, deviceNameBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Audio.Adpcm;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
|
@ -333,7 +333,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
|
||||
for (int offset = 0; offset < size; offset += 2)
|
||||
{
|
||||
context.Coefficients[offset >> 1] = _memory.ReadInt16(position + offset);
|
||||
context.Coefficients[offset >> 1] = _memory.Read<short>((ulong)(position + offset));
|
||||
}
|
||||
|
||||
return context;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Audio.Adpcm;
|
||||
using Ryujinx.Cpu;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
||||
|
@ -146,7 +146,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
{
|
||||
for (int index = 0; index < samplesCount; index++)
|
||||
{
|
||||
short sample = memory.ReadInt16(wb.Position + index * 2);
|
||||
short sample = memory.Read<short>((ulong)(wb.Position + index * 2));
|
||||
|
||||
_samples[index * 2 + 0] = sample;
|
||||
_samples[index * 2 + 1] = sample;
|
||||
|
@ -156,13 +156,15 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
|
|||
{
|
||||
for (int index = 0; index < samplesCount * 2; index++)
|
||||
{
|
||||
_samples[index] = memory.ReadInt16(wb.Position + index * 2);
|
||||
_samples[index] = memory.Read<short>((ulong)(wb.Position + index * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (SampleFormat == SampleFormat.Adpcm)
|
||||
{
|
||||
byte[] buffer = memory.ReadBytes(wb.Position, wb.Size);
|
||||
byte[] buffer = new byte[wb.Size];
|
||||
|
||||
memory.Read((ulong)wb.Position, buffer);
|
||||
|
||||
_samples = AdpcmDecoder.Decode(buffer, AdpcmCtx);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,11 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
long outputPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long outputSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(context.Memory.ReadBytes(inPosition, inSize))))
|
||||
byte[] buffer = new byte[inSize];
|
||||
|
||||
context.Memory.Read((ulong)inPosition, buffer);
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(buffer)))
|
||||
{
|
||||
result = DecodeInterleavedInternal(inputStream, out short[] outPcmData, outputSize, out uint outConsumed, out int outSamples);
|
||||
|
||||
|
@ -119,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
{
|
||||
byte[] pcmDataBytes = new byte[outPcmData.Length * sizeof(short)];
|
||||
Buffer.BlockCopy(outPcmData, 0, pcmDataBytes, 0, pcmDataBytes.Length);
|
||||
context.Memory.WriteBytes(outputPosition, pcmDataBytes);
|
||||
context.Memory.Write((ulong)outputPosition, pcmDataBytes);
|
||||
|
||||
context.ResponseData.Write(outConsumed);
|
||||
context.ResponseData.Write(outSamples);
|
||||
|
@ -140,7 +144,11 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
long outputPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long outputSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(context.Memory.ReadBytes(inPosition, inSize))))
|
||||
byte[] buffer = new byte[inSize];
|
||||
|
||||
context.Memory.Read((ulong)inPosition, buffer);
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(buffer)))
|
||||
{
|
||||
result = DecodeInterleavedInternal(inputStream, out short[] outPcmData, outputSize, out uint outConsumed, out int outSamples);
|
||||
|
||||
|
@ -148,7 +156,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
{
|
||||
byte[] pcmDataBytes = new byte[outPcmData.Length * sizeof(short)];
|
||||
Buffer.BlockCopy(outPcmData, 0, pcmDataBytes, 0, pcmDataBytes.Length);
|
||||
context.Memory.WriteBytes(outputPosition, pcmDataBytes);
|
||||
context.Memory.Write((ulong)outputPosition, pcmDataBytes);
|
||||
|
||||
context.ResponseData.Write(outConsumed);
|
||||
context.ResponseData.Write(outSamples);
|
||||
|
@ -174,7 +182,11 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
long outputPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long outputSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(context.Memory.ReadBytes(inPosition, inSize))))
|
||||
byte[] buffer = new byte[inSize];
|
||||
|
||||
context.Memory.Read((ulong)inPosition, buffer);
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(buffer)))
|
||||
{
|
||||
result = DecodeInterleavedInternal(inputStream, out short[] outPcmData, outputSize, out uint outConsumed, out int outSamples);
|
||||
|
||||
|
@ -182,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
{
|
||||
byte[] pcmDataBytes = new byte[outPcmData.Length * sizeof(short)];
|
||||
Buffer.BlockCopy(outPcmData, 0, pcmDataBytes, 0, pcmDataBytes.Length);
|
||||
context.Memory.WriteBytes(outputPosition, pcmDataBytes);
|
||||
context.Memory.Write((ulong)outputPosition, pcmDataBytes);
|
||||
|
||||
context.ResponseData.Write(outConsumed);
|
||||
context.ResponseData.Write(outSamples);
|
||||
|
@ -208,7 +220,11 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
long outputPosition = context.Request.ReceiveBuff[0].Position;
|
||||
long outputSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(context.Memory.ReadBytes(inPosition, inSize))))
|
||||
byte[] buffer = new byte[inSize];
|
||||
|
||||
context.Memory.Read((ulong)inPosition, buffer);
|
||||
|
||||
using (BinaryReader inputStream = new BinaryReader(new MemoryStream(buffer)))
|
||||
{
|
||||
result = DecodeInterleavedInternal(inputStream, out short[] outPcmData, outputSize, out uint outConsumed, out int outSamples);
|
||||
|
||||
|
@ -216,7 +232,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager
|
|||
{
|
||||
byte[] pcmDataBytes = new byte[outPcmData.Length * sizeof(short)];
|
||||
Buffer.BlockCopy(outPcmData, 0, pcmDataBytes, 0, pcmDataBytes.Length);
|
||||
context.Memory.WriteBytes(outputPosition, pcmDataBytes);
|
||||
context.Memory.Write((ulong)outputPosition, pcmDataBytes);
|
||||
|
||||
context.ResponseData.Write(outConsumed);
|
||||
context.ResponseData.Write(outSamples);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Audio.AudioOutManager;
|
||||
using System.Text;
|
||||
|
@ -72,7 +72,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
|
|||
|
||||
if ((ulong)deviceNameBuffer.Length <= (ulong)size)
|
||||
{
|
||||
context.Memory.WriteBytes(position, deviceNameBuffer);
|
||||
context.Memory.Write((ulong)position, deviceNameBuffer);
|
||||
|
||||
nameCount++;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio
|
|||
|
||||
if ((ulong)deviceNameBuffer.Length <= (ulong)receiveSize)
|
||||
{
|
||||
context.Memory.WriteBytes(receivePosition, deviceNameBuffer);
|
||||
context.Memory.Write((ulong)receivePosition, deviceNameBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|||
|
||||
Result result = _base.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(data));
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
context.Memory.Write((ulong)position, data);
|
||||
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|||
|
||||
Result result = _base.Read(out long bytesRead, offset, data);
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
context.Memory.Write((ulong)position, data);
|
||||
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|||
using (BinaryWriter bufferWriter = new BinaryWriter(memory))
|
||||
{
|
||||
bufferWriter.WriteStruct(deliveryCacheProgress);
|
||||
context.Memory.WriteBytes(ipcDesc.Position, memory.ToArray());
|
||||
context.Memory.Write((ulong)ipcDesc.Position, memory.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|||
|
||||
Result result = _base.EnumerateDeliveryCacheDirectory(out int count, MemoryMarshal.Cast<byte, DirectoryName>(data));
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
context.Memory.Write((ulong)position, data);
|
||||
|
||||
context.ResponseData.Write(count);
|
||||
|
||||
|
|
|
@ -166,7 +166,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
|
|||
long position = context.Request.PtrBuff[0].Position;
|
||||
long size = context.Request.PtrBuff[0].Size;
|
||||
|
||||
byte[] bufferContent = context.Memory.ReadBytes(position, size);
|
||||
byte[] bufferContent = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, bufferContent);
|
||||
|
||||
if (uuid.IsNull)
|
||||
{
|
||||
|
|
|
@ -119,7 +119,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
long position = context.Request.PtrBuff[index].Position;
|
||||
long size = context.Request.PtrBuff[index].Size;
|
||||
|
||||
byte[] pathBytes = context.Memory.ReadBytes(position, size);
|
||||
byte[] pathBytes = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, pathBytes);
|
||||
|
||||
return FsPath.FromSpan(out path, pathBytes);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
|
||||
Result result = _baseDirectory.Read(out long entriesRead, entries);
|
||||
|
||||
context.Memory.WriteBytes(bufferPosition, entriesBytes);
|
||||
context.Memory.Write((ulong)bufferPosition, entriesBytes);
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
|
||||
Result result = _baseFile.Read(out long bytesRead, offset, data, readOption);
|
||||
|
||||
context.Memory.WriteBytes(position, data);
|
||||
context.Memory.Write((ulong)position, data);
|
||||
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
|
@ -48,7 +48,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
long offset = context.RequestData.ReadInt64();
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
byte[] data = context.Memory.ReadBytes(position, size);
|
||||
byte[] data = new byte[size];
|
||||
|
||||
context.Memory.Read((ulong)position, data);
|
||||
|
||||
return (ResultCode)_baseFile.Write(offset, data, writeOption).Value;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
|||
|
||||
Result result = _baseStorage.Read(offset, data);
|
||||
|
||||
context.Memory.WriteBytes(buffDesc.Position, data);
|
||||
context.Memory.Write((ulong)buffDesc.Position, data);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
|||
|
||||
Result result = _baseFileSystemProxy.FindSaveDataWithFilter(out long count, infoBuffer, spaceId, ref filter);
|
||||
|
||||
context.Memory.WriteBytes(bufferPosition, infoBuffer);
|
||||
context.Memory.Write((ulong)bufferPosition, infoBuffer);
|
||||
context.ResponseData.Write(count);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
|||
|
||||
Result result = _baseReader.ReadSaveDataInfo(out long readCount, infoBuffer);
|
||||
|
||||
context.Memory.WriteBytes(bufferPosition, infoBuffer);
|
||||
context.Memory.Write((ulong)bufferPosition, infoBuffer);
|
||||
context.ResponseData.Write(readCount);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
|
|
|
@ -7,9 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||
public class Hid
|
||||
{
|
||||
private readonly Switch _device;
|
||||
private readonly long _hidMemoryAddress;
|
||||
|
||||
internal ref HidSharedMemory SharedMemory => ref _device.Memory.GetStructRef<HidSharedMemory>(_hidMemoryAddress);
|
||||
private readonly ulong _hidMemoryAddress;
|
||||
|
||||
internal ref HidSharedMemory SharedMemory => ref _device.Memory.GetRef<HidSharedMemory>(_hidMemoryAddress);
|
||||
|
||||
internal const int SharedMemEntryCount = 17;
|
||||
|
||||
public DebugPadDevice DebugPad;
|
||||
|
@ -46,12 +48,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||
}
|
||||
}
|
||||
|
||||
public Hid(in Switch device, long sharedHidMemoryAddress)
|
||||
public Hid(in Switch device, ulong sharedHidMemoryAddress)
|
||||
{
|
||||
_device = device;
|
||||
_hidMemoryAddress = sharedHidMemoryAddress;
|
||||
|
||||
device.Memory.FillWithZeros(sharedHidMemoryAddress, Horizon.HidSize);
|
||||
device.Memory.ZeroFill(sharedHidMemoryAddress, Horizon.HidSize);
|
||||
}
|
||||
|
||||
public void InitDevices()
|
||||
|
|
|
@ -580,7 +580,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||
|
||||
for (int i = 0; i < arraySize; ++i)
|
||||
{
|
||||
supportedPlayerIds[i] = (NpadIdType)context.Memory.ReadInt32(context.Request.PtrBuff[0].Position + i * 4);
|
||||
supportedPlayerIds[i] = context.Memory.Read<NpadIdType>((ulong)(context.Request.PtrBuff[0].Position + i * 4));
|
||||
}
|
||||
|
||||
Logger.PrintStub(LogClass.ServiceHid, $"{arraySize} " + string.Join(",", supportedPlayerIds));
|
||||
|
@ -980,13 +980,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||
{
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
|
||||
byte[] vibrationDeviceHandleBuffer = context.Memory.ReadBytes(
|
||||
context.Request.PtrBuff[0].Position,
|
||||
context.Request.PtrBuff[0].Size);
|
||||
byte[] vibrationDeviceHandleBuffer = new byte[context.Request.PtrBuff[0].Size];
|
||||
|
||||
byte[] vibrationValueBuffer = context.Memory.ReadBytes(
|
||||
context.Request.PtrBuff[1].Position,
|
||||
context.Request.PtrBuff[1].Size);
|
||||
context.Memory.Read((ulong)context.Request.PtrBuff[0].Position, vibrationDeviceHandleBuffer);
|
||||
|
||||
byte[] vibrationValueBuffer = new byte[context.Request.PtrBuff[1].Size];
|
||||
|
||||
context.Memory.Read((ulong)context.Request.PtrBuff[1].Position, vibrationValueBuffer);
|
||||
|
||||
// TODO: Read all handles and values from buffer.
|
||||
|
||||
|
|
|
@ -33,7 +33,10 @@ namespace Ryujinx.HLE.HOS.Services.Lm.LogService
|
|||
public ResultCode Log(ServiceCtx context)
|
||||
{
|
||||
(long bufPos, long bufSize) = context.Request.GetBufferType0x21();
|
||||
byte[] logBuffer = context.Memory.ReadBytes(bufPos, bufSize);
|
||||
|
||||
byte[] logBuffer = new byte[bufSize];
|
||||
|
||||
context.Memory.Read((ulong)bufPos, logBuffer);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(logBuffer))
|
||||
{
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService
|
|||
|
||||
ResultCode result = Export(data);
|
||||
|
||||
context.Memory.WriteBytes(outputBuffer.Position, data.ToArray());
|
||||
context.Memory.Write((ulong)outputBuffer.Position, data.ToArray());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -350,7 +350,9 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService
|
|||
}
|
||||
else
|
||||
{
|
||||
rawData = context.Memory.ReadBytes(ipcBuff.Position, ipcBuff.Size);
|
||||
rawData = new byte[ipcBuff.Size];
|
||||
|
||||
context.Memory.Read((ulong)ipcBuff.Position, rawData);
|
||||
}
|
||||
|
||||
return new Span<byte>(rawData);
|
||||
|
@ -365,7 +367,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.StaticService
|
|||
{
|
||||
Span<byte> rawData = MemoryMarshal.Cast<T, byte>(span);
|
||||
|
||||
context.Memory.WriteBytes(ipcBuff.Position, rawData.ToArray());
|
||||
context.Memory.Write((ulong)ipcBuff.Position, rawData);
|
||||
}
|
||||
|
||||
protected abstract bool IsUpdated(SourceFlag flag);
|
||||
|
|
|
@ -233,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.Ncm.Lr.LocationResolverManager
|
|||
|
||||
byte[] contentPathBuffer = Encoding.UTF8.GetBytes(contentPath);
|
||||
|
||||
context.Memory.WriteBytes(position, contentPathBuffer);
|
||||
context.Memory.Write((ulong)position, contentPathBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -31,7 +31,9 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
|||
long inputPosition = context.Request.SendBuff[0].Position;
|
||||
long inputSize = context.Request.SendBuff[0].Size;
|
||||
|
||||
byte[] unknownBuffer = context.Memory.ReadBytes(inputPosition, inputSize);
|
||||
byte[] unknownBuffer = new byte[inputSize];
|
||||
|
||||
context.Memory.Read((ulong)inputPosition, unknownBuffer);
|
||||
|
||||
// NOTE: appletResourceUserId, mcuVersionData and the buffer are stored inside an internal struct.
|
||||
// The buffer seems to contains entries with a size of 0x40 bytes each.
|
||||
|
@ -89,7 +91,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
|||
|
||||
for (int i = 0; i < _devices.Count; i++)
|
||||
{
|
||||
context.Memory.WriteUInt32(outputPosition + (i * sizeof(long)), (uint)_devices[i].Handle);
|
||||
context.Memory.Write((ulong)(outputPosition + (i * sizeof(long))), (uint)_devices[i].Handle);
|
||||
}
|
||||
|
||||
context.ResponseData.Write(_devices.Count);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|||
long position = context.Request.RecvListBuff[0].Position;
|
||||
long size = context.Request.RecvListBuff[0].Size;
|
||||
|
||||
context.Memory.WriteInt32(position, _generalServiceDetail.ClientId);
|
||||
context.Memory.Write((ulong)position, _generalServiceDetail.ClientId);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|||
long position = context.Request.PtrBuff[0].Position;
|
||||
long size = context.Request.PtrBuff[0].Size;
|
||||
|
||||
int clientId = context.Memory.ReadInt32(position);
|
||||
int clientId = context.Memory.Read<int>((ulong)position);
|
||||
|
||||
context.ResponseData.Write(GeneralServiceManager.Get(clientId).IsAnyInternetRequestAccepted);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
byte[] nacpData = context.Device.System.ControlData.ByteSpan.ToArray();
|
||||
|
||||
context.Memory.WriteBytes(position, nacpData);
|
||||
context.Memory.Write((ulong)position, nacpData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
byte[] nacpData = context.Device.System.ControlData.ByteSpan.ToArray();
|
||||
|
||||
context.Memory.WriteBytes(position, nacpData);
|
||||
context.Memory.Write((ulong)position, nacpData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.Exceptions;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
|
@ -102,7 +102,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
byte[] outputData = new byte[outputDataSize];
|
||||
|
||||
byte[] temp = context.Memory.ReadBytes(inputDataPosition, inputDataSize);
|
||||
byte[] temp = new byte[inputDataSize];
|
||||
|
||||
context.Memory.Read((ulong)inputDataPosition, temp);
|
||||
|
||||
Buffer.BlockCopy(temp, 0, outputData, 0, temp.Length);
|
||||
|
||||
|
@ -116,7 +118,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
}
|
||||
else
|
||||
{
|
||||
arguments = new Span<byte>(context.Memory.ReadBytes(inputDataPosition, inputDataSize));
|
||||
byte[] temp = new byte[inputDataSize];
|
||||
|
||||
context.Memory.Read((ulong)inputDataPosition, temp);
|
||||
|
||||
arguments = new Span<byte>(temp);
|
||||
}
|
||||
|
||||
return NvResult.Success;
|
||||
|
@ -266,7 +272,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +441,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
errorCode = GetIoctlArgument(context, ioctlCommand, out Span<byte> arguments);
|
||||
|
||||
Span<byte> inlineInBuffer = new Span<byte>(context.Memory.ReadBytes(inlineInBufferPosition, inlineInBufferSize));
|
||||
byte[] temp = new byte[inlineInBufferSize];
|
||||
|
||||
context.Memory.Read((ulong)inlineInBufferPosition, temp);
|
||||
|
||||
Span<byte> inlineInBuffer = new Span<byte>(temp);
|
||||
|
||||
if (errorCode == NvResult.Success)
|
||||
{
|
||||
|
@ -454,7 +464,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +490,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
errorCode = GetIoctlArgument(context, ioctlCommand, out Span<byte> arguments);
|
||||
|
||||
Span<byte> inlineOutBuffer = new Span<byte>(context.Memory.ReadBytes(inlineOutBufferPosition, inlineOutBufferSize));
|
||||
byte[] temp = new byte[inlineOutBufferSize];
|
||||
|
||||
context.Memory.Read((ulong)inlineOutBufferPosition, temp);
|
||||
|
||||
Span<byte> inlineOutBuffer = new Span<byte>(temp);
|
||||
|
||||
if (errorCode == NvResult.Success)
|
||||
{
|
||||
|
@ -499,8 +513,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
context.Memory.WriteBytes(inlineOutBufferPosition, inlineOutBuffer.ToArray());
|
||||
context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
context.Memory.Write((ulong)inlineOutBufferPosition, inlineOutBuffer.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private Switch _device;
|
||||
|
||||
private ARMeilleure.Memory.MemoryManager _memory;
|
||||
private Cpu.MemoryManager _memory;
|
||||
|
||||
public enum ResourcePolicy
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
for (int offset = 0; offset < commandBufferData.Length; offset++)
|
||||
{
|
||||
commandBufferData[offset] = _memory.ReadInt32(map.Address + commandBufferEntry.Offset + offset * 4);
|
||||
commandBufferData[offset] = _memory.Read<int>((ulong)(map.Address + commandBufferEntry.Offset + offset * 4));
|
||||
}
|
||||
|
||||
// TODO: Submit command to engines.
|
||||
|
|
|
@ -95,7 +95,9 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
|
|||
return ResultCode.InvalidBufferSize;
|
||||
}
|
||||
|
||||
byte[] inputBuffer = context.Memory.ReadBytes(inputPosition, inputSize);
|
||||
byte[] inputBuffer = new byte[inputSize];
|
||||
|
||||
context.Memory.Read((ulong)inputPosition, inputBuffer);
|
||||
|
||||
Logger.PrintInfo(LogClass.ServicePrepo, ReadReportBuffer(inputBuffer, gameRoom, userId));
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
|
@ -69,7 +68,11 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
|||
|
||||
for (int i = 0; i < header.HashCount; i++)
|
||||
{
|
||||
hashes.Add(context.Memory.ReadBytes(nrrAddress + header.HashOffset + (i * 0x20), 0x20));
|
||||
byte[] temp = new byte[0x20];
|
||||
|
||||
context.Memory.Read((ulong)(nrrAddress + header.HashOffset + (i * 0x20)), temp);
|
||||
|
||||
hashes.Add(temp);
|
||||
}
|
||||
|
||||
nrrInfo = new NrrInfo(nrrAddress, header, hashes);
|
||||
|
@ -127,15 +130,18 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
|||
return ResultCode.InvalidAddress;
|
||||
}
|
||||
|
||||
uint magic = context.Memory.ReadUInt32((long)nroAddress + 0x10);
|
||||
uint nroFileSize = context.Memory.ReadUInt32((long)nroAddress + 0x18);
|
||||
uint magic = context.Memory.Read<uint>(nroAddress + 0x10);
|
||||
uint nroFileSize = context.Memory.Read<uint>(nroAddress + 0x18);
|
||||
|
||||
if (magic != NroMagic || nroSize != nroFileSize)
|
||||
{
|
||||
return ResultCode.InvalidNro;
|
||||
}
|
||||
|
||||
byte[] nroData = context.Memory.ReadBytes((long)nroAddress, (long)nroSize);
|
||||
byte[] nroData = new byte[nroSize];
|
||||
|
||||
context.Memory.Read(nroAddress, nroData);
|
||||
|
||||
byte[] nroHash = null;
|
||||
|
||||
MemoryStream stream = new MemoryStream(nroData);
|
||||
|
@ -319,9 +325,9 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
|||
|
||||
ulong bssEnd = BitUtils.AlignUp(bssStart + (ulong)relocatableObject.BssSize, KMemoryManager.PageSize);
|
||||
|
||||
process.CpuMemory.WriteBytes((long)textStart, relocatableObject.Text);
|
||||
process.CpuMemory.WriteBytes((long)roStart, relocatableObject.Ro);
|
||||
process.CpuMemory.WriteBytes((long)dataStart, relocatableObject.Data);
|
||||
process.CpuMemory.Write(textStart, relocatableObject.Text);
|
||||
process.CpuMemory.Write(roStart, relocatableObject.Ro);
|
||||
process.CpuMemory.Write(dataStart, relocatableObject.Data);
|
||||
|
||||
MemoryHelper.FillWithZeros(process.CpuMemory, (long)bssStart, (int)(bssEnd - bssStart));
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService.Types;
|
||||
using System;
|
||||
|
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService
|
|||
|
||||
for (int i = 0; i < inputSize / sizeof(ulong); i++)
|
||||
{
|
||||
titleIds.Add(BitConverter.ToUInt64(context.Memory.ReadBytes(inputPosition, inputSize), 0));
|
||||
titleIds.Add(context.Memory.Read<ulong>((ulong)inputPosition));
|
||||
}
|
||||
|
||||
if (queryCapability == PlayLogQueryCapability.WhiteList)
|
||||
|
|
|
@ -116,11 +116,9 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
|
|||
return false;
|
||||
}
|
||||
|
||||
context.Memory.WriteInt32(typesPosition + offset, (int)fontType);
|
||||
|
||||
context.Memory.WriteInt32(offsetsPosition + offset, context.Device.System.Font.GetSharedMemoryAddressOffset(fontType));
|
||||
|
||||
context.Memory.WriteInt32(fontSizeBufferPosition + offset, context.Device.System.Font.GetFontSize(fontType));
|
||||
context.Memory.Write((ulong)(typesPosition + offset), (int)fontType);
|
||||
context.Memory.Write((ulong)(offsetsPosition + offset), context.Device.System.Font.GetSharedMemoryAddressOffset(fontType));
|
||||
context.Memory.Write((ulong)(fontSizeBufferPosition + offset), context.Device.System.Font.GetFontSize(fontType));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
context.Memory.WriteInt64(position, SystemStateMgr.GetLanguageCode(index));
|
||||
context.Memory.Write((ulong)position, SystemStateMgr.GetLanguageCode(index));
|
||||
|
||||
position += 8;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
if (firmwareData != null)
|
||||
{
|
||||
context.Memory.WriteBytes(replyPos, firmwareData);
|
||||
context.Memory.Write((ulong)replyPos, firmwareData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
writer.Write(Encoding.ASCII.GetBytes(build));
|
||||
|
||||
context.Memory.WriteBytes(replyPos, ms.ToArray());
|
||||
context.Memory.Write((ulong)replyPos, ms.ToArray());
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
|
@ -114,10 +114,15 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
long namePos = context.Request.PtrBuff[1].Position;
|
||||
long nameSize = context.Request.PtrBuff[1].Size;
|
||||
|
||||
byte[] Class = context.Memory.ReadBytes(classPos, classSize);
|
||||
byte[] name = context.Memory.ReadBytes(namePos, nameSize);
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(Class).Trim('\0') + "!" + Encoding.ASCII.GetString(name).Trim('\0');
|
||||
context.Memory.Read((ulong)classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read((ulong)namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
||||
|
||||
|
@ -161,10 +166,15 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
long replyPos = context.Request.ReceiveBuff[0].Position;
|
||||
long replySize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
byte[] Class = context.Memory.ReadBytes(classPos, classSize);
|
||||
byte[] name = context.Memory.ReadBytes(namePos, nameSize);
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(Class).Trim('\0') + "!" + Encoding.ASCII.GetString(name).Trim('\0');
|
||||
context.Memory.Read((ulong)classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read((ulong)namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
||||
|
||||
|
@ -197,7 +207,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
throw new NotImplementedException(nxSetting.GetType().Name);
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(replyPos, settingBuffer);
|
||||
context.Memory.Write((ulong)replyPos, settingBuffer);
|
||||
|
||||
Logger.PrintDebug(LogClass.ServiceSet, $"{askedSetting} set value: {nxSetting} as {nxSetting.GetType()}");
|
||||
}
|
||||
|
|
|
@ -199,21 +199,23 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
|
||||
private IPEndPoint ParseSockAddr(ServiceCtx context, long bufferPosition, long bufferSize)
|
||||
{
|
||||
int size = context.Memory.ReadByte(bufferPosition);
|
||||
int family = context.Memory.ReadByte(bufferPosition + 1);
|
||||
int port = BinaryPrimitives.ReverseEndianness(context.Memory.ReadUInt16(bufferPosition + 2));
|
||||
int size = context.Memory.Read<byte>((ulong)bufferPosition);
|
||||
int family = context.Memory.Read<byte>((ulong)bufferPosition + 1);
|
||||
int port = BinaryPrimitives.ReverseEndianness(context.Memory.Read<ushort>((ulong)bufferPosition + 2));
|
||||
|
||||
byte[] rawIp = context.Memory.ReadBytes(bufferPosition + 4, 4);
|
||||
byte[] rawIp = new byte[4];
|
||||
|
||||
context.Memory.Read((ulong)bufferPosition + 4, rawIp);
|
||||
|
||||
return new IPEndPoint(new IPAddress(rawIp), port);
|
||||
}
|
||||
|
||||
private void WriteSockAddr(ServiceCtx context, long bufferPosition, IPEndPoint endPoint)
|
||||
{
|
||||
context.Memory.WriteByte(bufferPosition, 0);
|
||||
context.Memory.WriteByte(bufferPosition + 1, (byte)endPoint.AddressFamily);
|
||||
context.Memory.WriteUInt16(bufferPosition + 2, BinaryPrimitives.ReverseEndianness((ushort)endPoint.Port));
|
||||
context.Memory.WriteBytes(bufferPosition + 4, endPoint.Address.GetAddressBytes());
|
||||
context.Memory.Write((ulong)bufferPosition, (byte)0);
|
||||
context.Memory.Write((ulong)bufferPosition + 1, (byte)endPoint.AddressFamily);
|
||||
context.Memory.Write((ulong)bufferPosition + 2, BinaryPrimitives.ReverseEndianness((ushort)endPoint.Port));
|
||||
context.Memory.Write((ulong)bufferPosition + 4, endPoint.Address.GetAddressBytes());
|
||||
}
|
||||
|
||||
private void WriteSockAddr(ServiceCtx context, long bufferPosition, BsdSocket socket, bool isRemote)
|
||||
|
@ -281,8 +283,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
|
||||
int flags = context.RequestData.ReadInt32();
|
||||
|
||||
byte[] rawPath = context.Memory.ReadBytes(bufferPosition, bufferSize);
|
||||
string path = Encoding.ASCII.GetString(rawPath);
|
||||
byte[] rawPath = new byte[bufferSize];
|
||||
|
||||
context.Memory.Read((ulong)bufferPosition, rawPath);
|
||||
|
||||
string path = Encoding.ASCII.GetString(rawPath);
|
||||
|
||||
WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
|
||||
|
||||
|
@ -321,7 +326,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
|
||||
for (int i = 0; i < fdsCount; i++)
|
||||
{
|
||||
int socketFd = context.Memory.ReadInt32(bufferPosition + i * 8);
|
||||
int socketFd = context.Memory.Read<int>((ulong)(bufferPosition + i * 8));
|
||||
|
||||
BsdSocket socket = RetrieveSocket(socketFd);
|
||||
|
||||
|
@ -329,8 +334,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
{
|
||||
return WriteBsdResult(context, -1, LinuxError.EBADF);}
|
||||
|
||||
PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 4);
|
||||
PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.ReadInt16(bufferPosition + i * 8 + 6);
|
||||
PollEvent.EventTypeMask inputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>((ulong)(bufferPosition + i * 8 + 4));
|
||||
PollEvent.EventTypeMask outputEvents = (PollEvent.EventTypeMask)context.Memory.Read<short>((ulong)(bufferPosition + i * 8 + 6));
|
||||
|
||||
events[i] = new PollEvent(socketFd, socket, inputEvents, outputEvents);
|
||||
}
|
||||
|
@ -405,8 +410,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
for (int i = 0; i < fdsCount; i++)
|
||||
{
|
||||
PollEvent Event = events[i];
|
||||
context.Memory.WriteInt32(bufferPosition + i * 8, Event.SocketFd);
|
||||
context.Memory.WriteInt16(bufferPosition + i * 8 + 4, (short)Event.InputEvents);
|
||||
context.Memory.Write((ulong)(bufferPosition + i * 8), Event.SocketFd);
|
||||
context.Memory.Write((ulong)(bufferPosition + i * 8 + 4), (short)Event.InputEvents);
|
||||
|
||||
PollEvent.EventTypeMask outputEvents = 0;
|
||||
|
||||
|
@ -435,7 +440,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
outputEvents |= PollEvent.EventTypeMask.Output;
|
||||
}
|
||||
|
||||
context.Memory.WriteInt16(bufferPosition + i * 8 + 6, (short)outputEvents);
|
||||
context.Memory.Write((ulong)(bufferPosition + i * 8 + 6), (short)outputEvents);
|
||||
}
|
||||
|
||||
return WriteBsdResult(context, readEvents.Count + writeEvents.Count + errorEvents.Count, LinuxError.SUCCESS);
|
||||
|
@ -481,7 +486,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
result = socket.Handle.Receive(receivedBuffer, socketFlags);
|
||||
errno = SetResultErrno(socket.Handle, result);
|
||||
|
||||
context.Memory.WriteBytes(receivePosition, receivedBuffer);
|
||||
context.Memory.Write((ulong)receivePosition, receivedBuffer);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
|
@ -524,7 +529,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
result = socket.Handle.ReceiveFrom(receivedBuffer, receivedBuffer.Length, socketFlags, ref endPoint);
|
||||
errno = SetResultErrno(socket.Handle, result);
|
||||
|
||||
context.Memory.WriteBytes(receivePosition, receivedBuffer);
|
||||
context.Memory.Write((ulong)receivePosition, receivedBuffer);
|
||||
WriteSockAddr(context, sockAddrOutPosition, (IPEndPoint)endPoint);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
|
@ -559,7 +564,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
|
||||
}
|
||||
|
||||
byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
|
||||
byte[] sendBuffer = new byte[sendSize];
|
||||
|
||||
context.Memory.Read((ulong)sendPosition, sendBuffer);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -600,8 +607,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
return WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
|
||||
}
|
||||
|
||||
byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
|
||||
EndPoint endPoint = ParseSockAddr(context, bufferPosition, bufferSize);
|
||||
byte[] sendBuffer = new byte[sendSize];
|
||||
|
||||
context.Memory.Read((ulong)sendPosition, sendBuffer);
|
||||
|
||||
EndPoint endPoint = ParseSockAddr(context, bufferPosition, bufferSize);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -856,7 +866,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
(long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
|
||||
|
||||
// FIXME: OOB not implemented.
|
||||
context.Memory.WriteInt32(bufferPosition, 0);
|
||||
context.Memory.Write((ulong)bufferPosition, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -925,13 +935,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
case SocketOptionName.Type:
|
||||
case SocketOptionName.Linger:
|
||||
socket.Handle.GetSocketOption(SocketOptionLevel.Socket, optionName, optionValue);
|
||||
context.Memory.WriteBytes(optionValuePosition, optionValue);
|
||||
context.Memory.Write((ulong)optionValuePosition, optionValue);
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
|
||||
case (SocketOptionName)0x200:
|
||||
socket.Handle.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue);
|
||||
context.Memory.WriteBytes(optionValuePosition, optionValue);
|
||||
context.Memory.Write((ulong)optionValuePosition, optionValue);
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
|
||||
|
@ -965,18 +975,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
case SocketOptionName.SendTimeout:
|
||||
case SocketOptionName.Type:
|
||||
case SocketOptionName.ReuseAddress:
|
||||
socket.Handle.SetSocketOption(SocketOptionLevel.Socket, optionName, context.Memory.ReadInt32(optionValuePosition));
|
||||
socket.Handle.SetSocketOption(SocketOptionLevel.Socket, optionName, context.Memory.Read<int>((ulong)optionValuePosition));
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
|
||||
case (SocketOptionName)0x200:
|
||||
socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, context.Memory.ReadInt32(optionValuePosition));
|
||||
socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, context.Memory.Read<int>((ulong)optionValuePosition));
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
|
||||
case SocketOptionName.Linger:
|
||||
socket.Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,
|
||||
new LingerOption(context.Memory.ReadInt32(optionValuePosition) != 0, context.Memory.ReadInt32(optionValuePosition + 4)));
|
||||
new LingerOption(context.Memory.Read<int>((ulong)optionValuePosition) != 0, context.Memory.Read<int>((ulong)optionValuePosition + 4)));
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
|
||||
|
@ -1100,7 +1110,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||
|
||||
if (socket != null)
|
||||
{
|
||||
byte[] sendBuffer = context.Memory.ReadBytes(sendPosition, sendSize);
|
||||
byte[] sendBuffer = new byte[sendSize];
|
||||
|
||||
context.Memory.Read((ulong)sendPosition, sendBuffer);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
|||
{
|
||||
byte[] settingNameBuffer = Encoding.UTF8.GetBytes(settingName + '\0');
|
||||
|
||||
context.Memory.WriteBytes(outputPosition, settingNameBuffer);
|
||||
context.Memory.Write((ulong)outputPosition, settingNameBuffer);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -62,7 +62,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
|||
{
|
||||
byte[] identifierBuffer = Encoding.UTF8.GetBytes(identifier + '\0');
|
||||
|
||||
context.Memory.WriteBytes(outputPosition, identifierBuffer);
|
||||
context.Memory.Write((ulong)outputPosition, identifierBuffer);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
|||
|
||||
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress + '\0');
|
||||
|
||||
context.Memory.WriteBytes(outputPosition, resolvedAddressBuffer);
|
||||
context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
|||
|
||||
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress + '\0');
|
||||
|
||||
context.Memory.WriteBytes(outputPosition, resolvedAddressBuffer);
|
||||
context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer);
|
||||
|
||||
context.ResponseData.Write((int)errorCode);
|
||||
|
||||
|
|
|
@ -108,8 +108,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager
|
|||
{
|
||||
(long inputPosition, long inputSize) = context.Request.GetBufferType0x21();
|
||||
|
||||
byte[] addressBuffer = context.Memory.ReadBytes(inputPosition, inputSize);
|
||||
string address = Encoding.UTF8.GetString(addressBuffer);
|
||||
byte[] addressBuffer = new byte[inputSize];
|
||||
|
||||
context.Memory.Read((ulong)inputPosition, addressBuffer);
|
||||
|
||||
string address = Encoding.UTF8.GetString(addressBuffer);
|
||||
|
||||
resultCode = Resolve(context, address, out resolvedAddress);
|
||||
|
||||
|
|
|
@ -21,37 +21,37 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
|||
string hostName = hostEntry.HostName + '\0';
|
||||
|
||||
// h_name
|
||||
context.Memory.WriteBytes(bufferPosition, Encoding.ASCII.GetBytes(hostName));
|
||||
context.Memory.Write((ulong)bufferPosition, Encoding.ASCII.GetBytes(hostName));
|
||||
bufferPosition += hostName.Length;
|
||||
|
||||
// h_aliases list size
|
||||
context.Memory.WriteInt32(bufferPosition, IPAddress.HostToNetworkOrder(hostEntry.Aliases.Length));
|
||||
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder(hostEntry.Aliases.Length));
|
||||
bufferPosition += 4;
|
||||
|
||||
// Actual aliases
|
||||
foreach (string alias in hostEntry.Aliases)
|
||||
{
|
||||
context.Memory.WriteBytes(bufferPosition, Encoding.ASCII.GetBytes(alias + '\0'));
|
||||
context.Memory.Write((ulong)bufferPosition, Encoding.ASCII.GetBytes(alias + '\0'));
|
||||
bufferPosition += alias.Length + 1;
|
||||
}
|
||||
|
||||
// h_addrtype but it's a short (also only support IPv4)
|
||||
context.Memory.WriteInt16(bufferPosition, IPAddress.HostToNetworkOrder((short)2));
|
||||
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder((short)2));
|
||||
bufferPosition += 2;
|
||||
|
||||
// h_length but it's a short
|
||||
context.Memory.WriteInt16(bufferPosition, IPAddress.HostToNetworkOrder((short)4));
|
||||
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder((short)4));
|
||||
bufferPosition += 2;
|
||||
|
||||
// Ip address count, we can only support ipv4 (blame Nintendo)
|
||||
context.Memory.WriteInt32(bufferPosition, addresses != null ? IPAddress.HostToNetworkOrder(addresses.Count) : 0);
|
||||
context.Memory.Write((ulong)bufferPosition, addresses != null ? IPAddress.HostToNetworkOrder(addresses.Count) : 0);
|
||||
bufferPosition += 4;
|
||||
|
||||
if (addresses != null)
|
||||
{
|
||||
foreach (IPAddress ip in addresses)
|
||||
{
|
||||
context.Memory.WriteInt32(bufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(ip.GetAddressBytes(), 0)));
|
||||
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(ip.GetAddressBytes(), 0)));
|
||||
bufferPosition += 4;
|
||||
}
|
||||
}
|
||||
|
@ -168,8 +168,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
|||
// GetHostByName(u8, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>)
|
||||
public ResultCode GetHostByName(ServiceCtx context)
|
||||
{
|
||||
byte[] rawName = context.Memory.ReadBytes(context.Request.SendBuff[0].Position, context.Request.SendBuff[0].Size);
|
||||
string name = Encoding.ASCII.GetString(rawName).TrimEnd('\0');
|
||||
byte[] rawName = new byte[context.Request.SendBuff[0].Size];
|
||||
|
||||
context.Memory.Read((ulong)context.Request.SendBuff[0].Position, rawName);
|
||||
|
||||
string name = Encoding.ASCII.GetString(rawName).TrimEnd('\0');
|
||||
|
||||
// TODO: use params
|
||||
bool enableNsdResolve = context.RequestData.ReadInt32() == 1;
|
||||
|
@ -248,7 +251,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
|||
// GetHostByAddr(u32, u32, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>)
|
||||
public ResultCode GetHostByAddress(ServiceCtx context)
|
||||
{
|
||||
byte[] rawIp = context.Memory.ReadBytes(context.Request.SendBuff[0].Position, context.Request.SendBuff[0].Size);
|
||||
byte[] rawIp = new byte[context.Request.SendBuff[0].Size];
|
||||
|
||||
context.Memory.Read((ulong)context.Request.SendBuff[0].Position, rawIp);
|
||||
|
||||
// TODO: use params
|
||||
uint socketLength = context.RequestData.ReadUInt32();
|
||||
|
@ -325,7 +330,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
|||
if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size)
|
||||
{
|
||||
resultCode = 0;
|
||||
context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
||||
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
|
@ -342,7 +347,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
|||
if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size)
|
||||
{
|
||||
resultCode = 0;
|
||||
context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
||||
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Spl
|
|||
|
||||
_rng.GetBytes(randomBytes);
|
||||
|
||||
context.Memory.WriteBytes(context.Request.ReceiveBuff[0].Position, randomBytes);
|
||||
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, randomBytes);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
long replyPos = context.Request.ReceiveBuff[0].Position;
|
||||
long replySize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, dataSize);
|
||||
ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, (int)dataSize);
|
||||
|
||||
Span<byte> outputParcel = new Span<byte>(new byte[replySize]);
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
if (result == ResultCode.Success)
|
||||
{
|
||||
context.Memory.WriteBytes(replyPos, outputParcel.ToArray());
|
||||
context.Memory.Write((ulong)replyPos, outputParcel);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
(long dataPos, long dataSize) = context.Request.GetBufferType0x21();
|
||||
(long replyPos, long replySize) = context.Request.GetBufferType0x22();
|
||||
|
||||
ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan((ulong)dataPos, (ulong)dataSize);
|
||||
ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan((ulong)dataPos, (int)dataSize);
|
||||
|
||||
Span<byte> outputParcel = new Span<byte>(new byte[replySize]);
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
if (result == ResultCode.Success)
|
||||
{
|
||||
context.Memory.WriteBytes(replyPos, outputParcel.ToArray());
|
||||
context.Memory.Write((ulong)replyPos, outputParcel);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -401,7 +401,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
Debug.Assert(ipcDesc.Size == Marshal.SizeOf<ClockSnapshot>());
|
||||
|
||||
using (BinaryReader bufferReader = new BinaryReader(new MemoryStream(context.Memory.ReadBytes(ipcDesc.Position, ipcDesc.Size))))
|
||||
byte[] temp = new byte[ipcDesc.Size];
|
||||
|
||||
context.Memory.Read((ulong)ipcDesc.Position, temp);
|
||||
|
||||
using (BinaryReader bufferReader = new BinaryReader(new MemoryStream(temp)))
|
||||
{
|
||||
return bufferReader.ReadStruct<ClockSnapshot>();
|
||||
}
|
||||
|
@ -418,7 +422,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
bufferWriter.WriteStruct(clockSnapshot);
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(ipcDesc.Position, memory.ToArray());
|
||||
context.Memory.Write((ulong)ipcDesc.Position, memory.ToArray());
|
||||
memory.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
|
||||
(long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(context.Memory.ReadBytes(bufferPosition, bufferSize)))
|
||||
byte[] temp = new byte[bufferSize];
|
||||
|
||||
context.Memory.Read((ulong)bufferPosition, temp);
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp))
|
||||
{
|
||||
_timeManager.SetupTimeZoneManager(locationName, timeZoneUpdateTimePoint, totalLocationNameCount, timeZoneRuleVersion, timeZoneBinaryStream);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
@ -71,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
|
|||
return ResultCode.LocationNameTooLong;
|
||||
}
|
||||
|
||||
context.Memory.WriteBytes(bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
|
||||
context.Memory.Write((ulong)bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
|
||||
MemoryHelper.FillWithZeros(context.Memory, bufferPosition + offset + locationName.Length, padding);
|
||||
|
||||
offset += 0x24;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Services.Time.Clock;
|
||||
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
|
@ -129,7 +129,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
|
|||
|
||||
ResultCode result;
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(context.Memory.ReadBytes(bufferPosition, bufferSize)))
|
||||
byte[] temp = new byte[bufferSize];
|
||||
|
||||
context.Memory.Read((ulong)bufferPosition, temp);
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp))
|
||||
{
|
||||
result = _timeZoneManager.SetDeviceLocationNameWithTimeZoneRule(locationName, timeZoneBinaryStream);
|
||||
}
|
||||
|
@ -156,7 +160,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
|
|||
|
||||
ResultCode result;
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(context.Memory.ReadBytes(bufferPosition, bufferSize)))
|
||||
byte[] temp = new byte[bufferSize];
|
||||
|
||||
context.Memory.Read((ulong)bufferPosition, temp);
|
||||
|
||||
using (MemoryStream timeZoneBinaryStream = new MemoryStream(temp))
|
||||
{
|
||||
result = _timeZoneManager.ParseTimeZoneRuleBinary(out TimeZoneRule timeZoneRule, timeZoneBinaryStream);
|
||||
|
||||
|
@ -246,7 +254,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
|
|||
long outBufferPosition = context.Request.RecvListBuff[0].Position;
|
||||
long outBufferSize = context.Request.RecvListBuff[0].Size;
|
||||
|
||||
context.Memory.WriteInt64(outBufferPosition, posixTime);
|
||||
context.Memory.Write((ulong)outBufferPosition, posixTime);
|
||||
context.ResponseData.Write(1);
|
||||
}
|
||||
|
||||
|
@ -266,7 +274,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.StaticService
|
|||
long outBufferPosition = context.Request.RecvListBuff[0].Position;
|
||||
long outBufferSize = context.Request.RecvListBuff[0].Size;
|
||||
|
||||
context.Memory.WriteInt64(outBufferPosition, posixTime);
|
||||
context.Memory.Write((ulong)outBufferPosition, posixTime);
|
||||
|
||||
// There could be only one result on one calendar as leap seconds aren't supported.
|
||||
context.ResponseData.Write(1);
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
EphemeralClockContextWriter = new EphemeralNetworkSystemClockContextWriter();
|
||||
}
|
||||
|
||||
public void Initialize(Switch device, Horizon system, KSharedMemory sharedMemory, long timeSharedMemoryAddress, int timeSharedMemorySize)
|
||||
public void Initialize(Switch device, Horizon system, KSharedMemory sharedMemory, ulong timeSharedMemoryAddress, int timeSharedMemorySize)
|
||||
{
|
||||
SharedMemory.Initialize(device, sharedMemory, timeSharedMemoryAddress, timeSharedMemorySize);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
|
@ -13,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
private Switch _device;
|
||||
private KSharedMemory _sharedMemory;
|
||||
private long _timeSharedMemoryAddress;
|
||||
private ulong _timeSharedMemoryAddress;
|
||||
private int _timeSharedMemorySize;
|
||||
|
||||
private const uint SteadyClockContextOffset = 0x00;
|
||||
|
@ -21,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
private const uint NetworkSystemClockContextOffset = 0x80;
|
||||
private const uint AutomaticCorrectionEnabledOffset = 0xC8;
|
||||
|
||||
public void Initialize(Switch device, KSharedMemory sharedMemory, long timeSharedMemoryAddress, int timeSharedMemorySize)
|
||||
public void Initialize(Switch device, KSharedMemory sharedMemory, ulong timeSharedMemoryAddress, int timeSharedMemorySize)
|
||||
{
|
||||
_device = device;
|
||||
_sharedMemory = sharedMemory;
|
||||
|
@ -29,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
_timeSharedMemorySize = timeSharedMemorySize;
|
||||
|
||||
// Clean the shared memory
|
||||
_device.Memory.FillWithZeros(_timeSharedMemoryAddress, _timeSharedMemorySize);
|
||||
_device.Memory.ZeroFill(_timeSharedMemoryAddress, (ulong)_timeSharedMemorySize);
|
||||
}
|
||||
|
||||
public KSharedMemory GetSharedMemory()
|
||||
|
@ -86,9 +87,9 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
WriteObjectToSharedMemory(NetworkSystemClockContextOffset, 4, context);
|
||||
}
|
||||
|
||||
private T ReadObjectFromSharedMemory<T>(long offset, long padding)
|
||||
private T ReadObjectFromSharedMemory<T>(ulong offset, ulong padding) where T : unmanaged
|
||||
{
|
||||
long indexOffset = _timeSharedMemoryAddress + offset;
|
||||
ulong indexOffset = _timeSharedMemoryAddress + offset;
|
||||
|
||||
T result;
|
||||
uint index;
|
||||
|
@ -96,31 +97,31 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
|
||||
do
|
||||
{
|
||||
index = _device.Memory.ReadUInt32(indexOffset);
|
||||
index = _device.Memory.Read<uint>(indexOffset);
|
||||
|
||||
long objectOffset = indexOffset + 4 + padding + (index & 1) * Marshal.SizeOf<T>();
|
||||
ulong objectOffset = indexOffset + 4 + padding + (ulong)((index & 1) * Unsafe.SizeOf<T>());
|
||||
|
||||
result = _device.Memory.ReadStruct<T>(objectOffset);
|
||||
result = _device.Memory.Read<T>(objectOffset);
|
||||
|
||||
Thread.MemoryBarrier();
|
||||
|
||||
possiblyNewIndex = _device.Memory.ReadUInt32(indexOffset);
|
||||
possiblyNewIndex = _device.Memory.Read<uint>(indexOffset);
|
||||
} while (index != possiblyNewIndex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void WriteObjectToSharedMemory<T>(long offset, long padding, T value)
|
||||
private void WriteObjectToSharedMemory<T>(ulong offset, ulong padding, T value) where T : unmanaged
|
||||
{
|
||||
long indexOffset = _timeSharedMemoryAddress + offset;
|
||||
uint newIndex = _device.Memory.ReadUInt32(indexOffset) + 1;
|
||||
long objectOffset = indexOffset + 4 + padding + (newIndex & 1) * Marshal.SizeOf<T>();
|
||||
ulong indexOffset = _timeSharedMemoryAddress + offset;
|
||||
uint newIndex = _device.Memory.Read<uint>(indexOffset) + 1;
|
||||
ulong objectOffset = indexOffset + 4 + padding + (ulong)((newIndex & 1) * Unsafe.SizeOf<T>());
|
||||
|
||||
_device.Memory.WriteStruct(objectOffset, value);
|
||||
_device.Memory.Write(objectOffset, value);
|
||||
|
||||
Thread.MemoryBarrier();
|
||||
|
||||
_device.Memory.WriteUInt32(indexOffset, newIndex);
|
||||
_device.Memory.Write(indexOffset, newIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using ARMeilleure.Memory;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Services.SurfaceFlinger;
|
||||
|
@ -62,11 +62,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
MemoryHelper.FillWithZeros(context.Memory, recBuffPtr, 0x60);
|
||||
|
||||
// Add only the default display to buffer
|
||||
context.Memory.WriteBytes(recBuffPtr, Encoding.ASCII.GetBytes("Default"));
|
||||
context.Memory.WriteInt64(recBuffPtr + 0x40, 0x1L);
|
||||
context.Memory.WriteInt64(recBuffPtr + 0x48, 0x1L);
|
||||
context.Memory.WriteInt64(recBuffPtr + 0x50, 1280L);
|
||||
context.Memory.WriteInt64(recBuffPtr + 0x58, 720L);
|
||||
context.Memory.Write((ulong)recBuffPtr, Encoding.ASCII.GetBytes("Default"));
|
||||
context.Memory.Write((ulong)recBuffPtr + 0x40, 0x1L);
|
||||
context.Memory.Write((ulong)recBuffPtr + 0x48, 0x1L);
|
||||
context.Memory.Write((ulong)recBuffPtr + 0x50, 1280L);
|
||||
context.Memory.Write((ulong)recBuffPtr + 0x58, 720L);
|
||||
|
||||
context.ResponseData.Write(1L);
|
||||
|
||||
|
@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
|
||||
ReadOnlySpan<byte> parcelData = parcel.Finish();
|
||||
|
||||
context.Memory.WriteBytes(parcelPtr, parcelData.ToArray());
|
||||
context.Memory.Write((ulong)parcelPtr, parcelData);
|
||||
|
||||
context.ResponseData.Write((long)parcelData.Length);
|
||||
|
||||
|
@ -166,7 +166,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
|
||||
ReadOnlySpan<byte> parcelData = parcel.Finish();
|
||||
|
||||
context.Memory.WriteBytes(parcelPtr, parcelData.ToArray());
|
||||
context.Memory.Write((ulong)parcelPtr, parcelData);
|
||||
|
||||
context.ResponseData.Write(layerId);
|
||||
context.ResponseData.Write((long)parcelData.Length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue