mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-24 15:37:10 +02:00
Add events to shared memory, make it work better with direct memory
This commit is contained in:
parent
161193e113
commit
ebddc40550
7 changed files with 116 additions and 31 deletions
|
@ -31,6 +31,8 @@ namespace Ryujinx.OsHle
|
|||
|
||||
private ConcurrentDictionary<int, Process> Processes;
|
||||
|
||||
private HSharedMem HidSharedMem;
|
||||
|
||||
private AMemoryAlloc Allocator;
|
||||
|
||||
private Switch Ns;
|
||||
|
@ -56,7 +58,12 @@ namespace Ryujinx.OsHle
|
|||
HidOffset = Allocator.Alloc(HidSize);
|
||||
FontOffset = Allocator.Alloc(FontSize);
|
||||
|
||||
HidHandle = Handles.GenerateId(new HSharedMem(HidOffset));
|
||||
HidSharedMem = new HSharedMem(HidOffset);
|
||||
|
||||
HidSharedMem.MemoryMapped += HidInit;
|
||||
|
||||
HidHandle = Handles.GenerateId(HidSharedMem);
|
||||
|
||||
FontHandle = Handles.GenerateId(new HSharedMem(FontOffset));
|
||||
}
|
||||
|
||||
|
@ -105,7 +112,7 @@ namespace Ryujinx.OsHle
|
|||
Processes.TryAdd(ProcessId, MainProcess);
|
||||
}
|
||||
|
||||
public void LoadProgram(string FileName)
|
||||
public void LoadProgram(string FileName)
|
||||
{
|
||||
int ProcessId = IdGen.GenerateId();
|
||||
|
||||
|
@ -139,18 +146,23 @@ namespace Ryujinx.OsHle
|
|||
}
|
||||
}
|
||||
|
||||
internal bool ExitProcess(int ProcessId) {
|
||||
Process process;
|
||||
var Success = Processes.TryRemove(ProcessId, out process);
|
||||
if (Success) {
|
||||
process.StopAllThreads();
|
||||
internal bool ExitProcess(int ProcessId)
|
||||
{
|
||||
bool Success = Processes.TryRemove(ProcessId, out Process Process);
|
||||
|
||||
if (Success)
|
||||
{
|
||||
Process.StopAllThreads();
|
||||
}
|
||||
|
||||
if (Processes.Count == 0) {
|
||||
if (Processes.Count == 0)
|
||||
{
|
||||
Ns.OnFinish(EventArgs.Empty);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
internal bool TryGetProcess(int ProcessId, out Process Process)
|
||||
{
|
||||
if (!Processes.TryGetValue(ProcessId, out Process))
|
||||
|
@ -176,11 +188,21 @@ namespace Ryujinx.OsHle
|
|||
Handles.Delete(Handle);
|
||||
}
|
||||
|
||||
private void HidInit(object sender, EventArgs e)
|
||||
{
|
||||
HSharedMem SharedMem = (HSharedMem)sender;
|
||||
|
||||
if (SharedMem.TryGetLastVirtualPosition(out long Position))
|
||||
{
|
||||
Logging.Info($"HID shared memory successfully mapped to {Position:x16}!");
|
||||
}
|
||||
}
|
||||
|
||||
public long GetVirtHidOffset()
|
||||
{
|
||||
HSharedMem HidSharedMem = Handles.GetData<HSharedMem>(HidHandle);
|
||||
HidSharedMem.TryGetLastVirtualPosition(out long Position);
|
||||
|
||||
return HidSharedMem.VirtPos;
|
||||
return Position;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue