0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 18:45:46 +00:00

Add BRK instruction, fix wrong namespace on one of Am interfaces, and disable Debug/Trace logs by default

This commit is contained in:
gdkchan 2018-02-10 10:24:16 -03:00
parent 276f9f6d48
commit 9063766ed6
12 changed files with 51 additions and 16 deletions

View file

@ -2,10 +2,10 @@
Logging_Enable_Info = true
#Enabled print trace logs
Logging_Enable_Trace = true
Logging_Enable_Trace = false
#Enabled print debug logs
Logging_Enable_Debug = true
Logging_Enable_Debug = false
#Enabled print warning logs
Logging_Enable_Warn = true

View file

@ -150,7 +150,8 @@ namespace ChocolArm64.Decoder
private static bool IsException(AOpCode OpCode)
{
return OpCode.Emitter == AInstEmit.Svc ||
return OpCode.Emitter == AInstEmit.Brk ||
OpCode.Emitter == AInstEmit.Svc ||
OpCode.Emitter == AInstEmit.Und;
}

View file

@ -8,7 +8,7 @@ namespace ChocolArm64.Decoder
public AOpCodeException(AInst Inst, long Position, int OpCode) : base(Inst, Position)
{
Id = (OpCode >> 5) & 0xfff;
Id = (OpCode >> 5) & 0xffff;
}
}
}

View file

@ -7,7 +7,17 @@ namespace ChocolArm64.Instruction
{
static partial class AInstEmit
{
public static void Brk(AILEmitterCtx Context)
{
EmitExceptionCall(Context, nameof(ARegisters.OnBreak));
}
public static void Svc(AILEmitterCtx Context)
{
EmitExceptionCall(Context, nameof(ARegisters.OnSvcCall));
}
private static void EmitExceptionCall(AILEmitterCtx Context, string MthdName)
{
AOpCodeException Op = (AOpCodeException)Context.CurrOp;
@ -17,7 +27,7 @@ namespace ChocolArm64.Instruction
Context.EmitLdc_I4(Op.Id);
Context.EmitCall(typeof(ARegisters), nameof(ARegisters.OnSvcCall));
Context.EmitCall(typeof(ARegisters), MthdName);
if (Context.CurrBlock.Next != null)
{

View file

@ -2,11 +2,11 @@ using System;
namespace ChocolArm64.State
{
public class SvcEventArgs : EventArgs
public class AExceptionEventArgs : EventArgs
{
public int Id { get; private set; }
public SvcEventArgs(int Id)
public AExceptionEventArgs(int Id)
{
this.Id = Id;
}

View file

@ -42,12 +42,18 @@ namespace ChocolArm64.State
public long CntpctEl0 => Environment.TickCount * TicksPerMS;
public event EventHandler<SvcEventArgs> SvcCall;
public event EventHandler<AExceptionEventArgs> Break;
public event EventHandler<AExceptionEventArgs> SvcCall;
public event EventHandler<EventArgs> Undefined;
public void OnBreak(int Imm)
{
Break?.Invoke(this, new AExceptionEventArgs(Imm));
}
public void OnSvcCall(int Imm)
{
SvcCall?.Invoke(this, new SvcEventArgs(Imm));
SvcCall?.Invoke(this, new AExceptionEventArgs(Imm));
}
public void OnUndefined()

View file

@ -0,0 +1,11 @@
using System;
namespace Ryujinx.OsHle.Exceptions
{
public class GuestBrokeExecutionException : Exception
{
private const string ExMsg = "The guest program broke execution!";
public GuestBrokeExecutionException() : base(ExMsg) { }
}
}

View file

@ -1,10 +1,9 @@
using Ryujinx.OsHle.Ipc;
using Ryujinx.OsHle.Objects.Am;
using System.Collections.Generic;
using static Ryujinx.OsHle.Objects.ObjHelper;
namespace Ryujinx.OsHle.Objects
namespace Ryujinx.OsHle.Objects.Am
{
class IApplicationProxy : IIpcInterface
{

View file

@ -1,7 +1,9 @@
using ChocolArm64;
using ChocolArm64.Memory;
using ChocolArm64.State;
using Ryujinx.Loaders;
using Ryujinx.Loaders.Executables;
using Ryujinx.OsHle.Exceptions;
using Ryujinx.OsHle.Handles;
using Ryujinx.OsHle.Svc;
using System;
@ -135,6 +137,7 @@ namespace Ryujinx.OsHle
return -1;
}
Thread.Registers.Break += BreakHandler;
Thread.Registers.SvcCall += SvcHandler.SvcCall;
Thread.Registers.ProcessId = ProcessId;
Thread.Registers.ThreadId = Ns.Os.IdGen.GenerateId();
@ -148,6 +151,11 @@ namespace Ryujinx.OsHle
return Handle;
}
private void BreakHandler(object sender, AExceptionEventArgs e)
{
throw new GuestBrokeExecutionException();
}
private int GetFreeTlsSlot(AThread Thread)
{
for (int Index = 1; Index < TotalTlsSlots; Index++)

View file

@ -1,4 +1,4 @@
using Ryujinx.OsHle.Objects;
using Ryujinx.OsHle.Objects.Am;
using static Ryujinx.OsHle.Objects.ObjHelper;

View file

@ -63,7 +63,7 @@ namespace Ryujinx.OsHle.Svc
Rng = new Random();
}
public void SvcCall(object sender, SvcEventArgs e)
public void SvcCall(object sender, AExceptionEventArgs e)
{
ARegisters Registers = (ARegisters)sender;
@ -75,7 +75,7 @@ namespace Ryujinx.OsHle.Svc
}
else
{
throw new NotImplementedException(e.Id.ToString("x3"));
throw new NotImplementedException(e.Id.ToString("x4"));
}
}
}