diff --git a/Ryujinx.conf b/Ryujinx.conf index 590318fe7..ee21ad904 100644 --- a/Ryujinx.conf +++ b/Ryujinx.conf @@ -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 diff --git a/Ryujinx/Cpu/AOpCodeTable.cs b/Ryujinx/Cpu/AOpCodeTable.cs index 14c249950..b61326a47 100644 --- a/Ryujinx/Cpu/AOpCodeTable.cs +++ b/Ryujinx/Cpu/AOpCodeTable.cs @@ -32,6 +32,7 @@ namespace ChocolArm64 Set("100101xxxxxxxxxxxxxxxxxxxxxxxxxx", AInstEmit.Bl, typeof(AOpCodeBImmAl)); Set("11010110001xxxxx000000xxxxxxxxxx", AInstEmit.Blr, typeof(AOpCodeBReg)); Set("11010110000xxxxx000000xxxxxxxxxx", AInstEmit.Br, typeof(AOpCodeBReg)); + Set("11010100001xxxxxxxxxxxxxxxx00000", AInstEmit.Brk, typeof(AOpCodeException)); Set("x0110101xxxxxxxxxxxxxxxxxxxxxxxx", AInstEmit.Cbnz, typeof(AOpCodeBImmCmp)); Set("x0110100xxxxxxxxxxxxxxxxxxxxxxxx", AInstEmit.Cbz, typeof(AOpCodeBImmCmp)); Set("x0111010010xxxxxxxxx10xxxxxxxxxx", AInstEmit.Ccmn, typeof(AOpCodeCcmpImm)); diff --git a/Ryujinx/Cpu/Decoder/ADecoder.cs b/Ryujinx/Cpu/Decoder/ADecoder.cs index 1d3400396..06a535c1b 100644 --- a/Ryujinx/Cpu/Decoder/ADecoder.cs +++ b/Ryujinx/Cpu/Decoder/ADecoder.cs @@ -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; } @@ -160,7 +161,7 @@ namespace ChocolArm64.Decoder AInst Inst = AOpCodeTable.GetInst(OpCode); - AOpCode DecodedOpCode = new AOpCode(AInst.Undefined, Position); + AOpCode DecodedOpCode = new AOpCode(AInst.Undefined, Position, OpCode); if (Inst.Type != null) { diff --git a/Ryujinx/Cpu/Decoder/AOpCode.cs b/Ryujinx/Cpu/Decoder/AOpCode.cs index 4e5a80700..5d1275930 100644 --- a/Ryujinx/Cpu/Decoder/AOpCode.cs +++ b/Ryujinx/Cpu/Decoder/AOpCode.cs @@ -6,14 +6,16 @@ namespace ChocolArm64.Decoder { class AOpCode : IAOpCode { - public long Position { get; private set; } + public long Position { get; private set; } + public int RawOpCode { get; private set; } public AInstEmitter Emitter { get; protected set; } public ARegisterSize RegisterSize { get; protected set; } - public AOpCode(AInst Inst, long Position) + public AOpCode(AInst Inst, long Position, int OpCode) { - this.Position = Position; + this.Position = Position; + this.RawOpCode = OpCode; RegisterSize = ARegisterSize.Int64; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeAdr.cs b/Ryujinx/Cpu/Decoder/AOpCodeAdr.cs index 49f756e72..3396281f4 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeAdr.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeAdr.cs @@ -7,7 +7,7 @@ namespace ChocolArm64.Decoder public int Rd { get; private set; } public long Imm { get; private set; } - public AOpCodeAdr(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeAdr(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rd = OpCode & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeAlu.cs b/Ryujinx/Cpu/Decoder/AOpCodeAlu.cs index 981af800e..e1a44f04b 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeAlu.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeAlu.cs @@ -10,7 +10,7 @@ namespace ChocolArm64.Decoder public ADataOp DataOp { get; private set; } - public AOpCodeAlu(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeAlu(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rd = (OpCode >> 0) & 0x1f; Rn = (OpCode >> 5) & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBImm.cs b/Ryujinx/Cpu/Decoder/AOpCodeBImm.cs index 2a56d4af4..6519d281d 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBImm.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBImm.cs @@ -6,6 +6,6 @@ namespace ChocolArm64.Decoder { public long Imm { get; protected set; } - public AOpCodeBImm(AInst Inst, long Position) : base(Inst, Position) { } + public AOpCodeBImm(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { } } } \ No newline at end of file diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBImmAl.cs b/Ryujinx/Cpu/Decoder/AOpCodeBImmAl.cs index 1b6a98e7c..a4ff686d6 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBImmAl.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBImmAl.cs @@ -4,7 +4,7 @@ namespace ChocolArm64.Decoder { class AOpCodeBImmAl : AOpCodeBImm { - public AOpCodeBImmAl(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeBImmAl(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Imm = Position + ADecoderHelper.DecodeImm26_2(OpCode); } diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBImmCmp.cs b/Ryujinx/Cpu/Decoder/AOpCodeBImmCmp.cs index e0ce57e38..1b6185da6 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBImmCmp.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBImmCmp.cs @@ -6,7 +6,7 @@ namespace ChocolArm64.Decoder { public int Rt { get; private set; } - public AOpCodeBImmCmp(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeBImmCmp(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rt = OpCode & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBImmCond.cs b/Ryujinx/Cpu/Decoder/AOpCodeBImmCond.cs index e4ae845fe..1310feb8d 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBImmCond.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBImmCond.cs @@ -6,7 +6,7 @@ namespace ChocolArm64.Decoder { public ACond Cond { get; private set; } - public AOpCodeBImmCond(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeBImmCond(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int O0 = (OpCode >> 4) & 1; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBImmTest.cs b/Ryujinx/Cpu/Decoder/AOpCodeBImmTest.cs index 6b8b966db..73e57b7ab 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBImmTest.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBImmTest.cs @@ -7,7 +7,7 @@ namespace ChocolArm64.Decoder public int Rt { get; private set; } public int Pos { get; private set; } - public AOpCodeBImmTest(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeBImmTest(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rt = OpCode & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeBReg.cs b/Ryujinx/Cpu/Decoder/AOpCodeBReg.cs index a71fc338a..c9c600af5 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeBReg.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeBReg.cs @@ -6,7 +6,7 @@ namespace ChocolArm64.Decoder { public int Rn { get; private set; } - public AOpCodeBReg(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeBReg(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int Op4 = (OpCode >> 0) & 0x1f; int Op2 = (OpCode >> 16) & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeException.cs b/Ryujinx/Cpu/Decoder/AOpCodeException.cs index 6d4a03861..4579c1a7b 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeException.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeException.cs @@ -6,9 +6,9 @@ namespace ChocolArm64.Decoder { public int Id { get; private set; } - public AOpCodeException(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeException(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { - Id = (OpCode >> 5) & 0xfff; + Id = (OpCode >> 5) & 0xffff; } } } \ No newline at end of file diff --git a/Ryujinx/Cpu/Decoder/AOpCodeMem.cs b/Ryujinx/Cpu/Decoder/AOpCodeMem.cs index 1950b2867..5ec72125a 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeMem.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeMem.cs @@ -9,7 +9,7 @@ namespace ChocolArm64.Decoder public int Size { get; protected set; } public bool Extend64 { get; protected set; } - public AOpCodeMem(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeMem(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rt = (OpCode >> 0) & 0x1f; Rn = (OpCode >> 5) & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeMemLit.cs b/Ryujinx/Cpu/Decoder/AOpCodeMemLit.cs index b94294353..ad719a194 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeMemLit.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeMemLit.cs @@ -10,7 +10,7 @@ namespace ChocolArm64.Decoder public bool Signed { get; private set; } public bool Prefetch { get; private set; } - public AOpCodeMemLit(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeMemLit(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rt = OpCode & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeMov.cs b/Ryujinx/Cpu/Decoder/AOpCodeMov.cs index 3d1431fb1..d5398646d 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeMov.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeMov.cs @@ -9,7 +9,7 @@ namespace ChocolArm64.Decoder public long Imm { get; private set; } public int Pos { get; private set; } - public AOpCodeMov(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeMov(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int P1 = (OpCode >> 22) & 1; int SF = (OpCode >> 31) & 1; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimd.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimd.cs index 796199845..5f940b220 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimd.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimd.cs @@ -12,7 +12,7 @@ namespace ChocolArm64.Decoder public int SizeF => Size & 1; - public AOpCodeSimd(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimd(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rd = (OpCode >> 0) & 0x1f; Rn = (OpCode >> 5) & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimdFmov.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimdFmov.cs index 1047beffc..3f8889598 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimdFmov.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimdFmov.cs @@ -8,7 +8,7 @@ namespace ChocolArm64.Decoder public long Imm { get; private set; } public int Size { get; private set; } - public AOpCodeSimdFmov(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimdFmov(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int Imm5 = (OpCode >> 5) & 0x1f; int Type = (OpCode >> 22) & 0x3; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimdImm.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimdImm.cs index 3a08ce63a..2959aee6d 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimdImm.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimdImm.cs @@ -9,7 +9,7 @@ namespace ChocolArm64.Decoder public long Imm { get; private set; } public int Size { get; private set; } - public AOpCodeSimdImm(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimdImm(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rd = OpCode & 0x1f; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemLit.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemLit.cs index cf6915f56..ea6fe00be 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemLit.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemLit.cs @@ -10,7 +10,7 @@ namespace ChocolArm64.Decoder public bool Signed => false; public bool Prefetch => false; - public AOpCodeSimdMemLit(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimdMemLit(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int Opc = (OpCode >> 30) & 3; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemMs.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemMs.cs index 0e8480b03..635ec91e4 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemMs.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemMs.cs @@ -14,7 +14,7 @@ namespace ChocolArm64.Decoder public int Elems { get; private set; } public bool WBack { get; private set; } - public AOpCodeSimdMemMs(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimdMemMs(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { switch ((OpCode >> 12) & 0xf) { diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemSs.cs b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemSs.cs index c2917dfc8..5bad95edd 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSimdMemSs.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSimdMemSs.cs @@ -14,7 +14,7 @@ namespace ChocolArm64.Decoder public bool Replicate { get; private set; } public bool WBack { get; private set; } - public AOpCodeSimdMemSs(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSimdMemSs(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { int Size = (OpCode >> 10) & 3; int S = (OpCode >> 12) & 1; diff --git a/Ryujinx/Cpu/Decoder/AOpCodeSystem.cs b/Ryujinx/Cpu/Decoder/AOpCodeSystem.cs index 95b291001..3d81a5d45 100644 --- a/Ryujinx/Cpu/Decoder/AOpCodeSystem.cs +++ b/Ryujinx/Cpu/Decoder/AOpCodeSystem.cs @@ -11,7 +11,7 @@ namespace ChocolArm64.Decoder public int Op1 { get; private set; } public int Op0 { get; private set; } - public AOpCodeSystem(AInst Inst, long Position, int OpCode) : base(Inst, Position) + public AOpCodeSystem(AInst Inst, long Position, int OpCode) : base(Inst, Position, OpCode) { Rt = (OpCode >> 0) & 0x1f; Op2 = (OpCode >> 5) & 0x7; diff --git a/Ryujinx/Cpu/Exceptions/VmmAccessViolationException.cs b/Ryujinx/Cpu/Exceptions/VmmAccessViolationException.cs index dd9d7a646..a557502e5 100644 --- a/Ryujinx/Cpu/Exceptions/VmmAccessViolationException.cs +++ b/Ryujinx/Cpu/Exceptions/VmmAccessViolationException.cs @@ -5,7 +5,7 @@ namespace ChocolArm64.Exceptions { public class VmmAccessViolationException : Exception { - private const string ExMsg = "Value at address 0x{0:x16} could not be \"{1}\"!"; + private const string ExMsg = "Address 0x{0:x16} does not have \"{1}\" permission!"; public VmmAccessViolationException() { } diff --git a/Ryujinx/Cpu/Instruction/AInstEmitException.cs b/Ryujinx/Cpu/Instruction/AInstEmitException.cs index 2f1edf781..f05d962f2 100644 --- a/Ryujinx/Cpu/Instruction/AInstEmitException.cs +++ b/Ryujinx/Cpu/Instruction/AInstEmitException.cs @@ -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) { @@ -27,7 +37,21 @@ namespace ChocolArm64.Instruction public static void Und(AILEmitterCtx Context) { - throw new NotImplementedException($"Undefined instruction at {Context.CurrOp.Position:x16}"); + AOpCode Op = Context.CurrOp; + + Context.EmitStoreState(); + + Context.EmitLdarg(ATranslatedSub.RegistersArgIdx); + + Context.EmitLdc_I8(Op.Position); + Context.EmitLdc_I4(Op.RawOpCode); + + Context.EmitCall(typeof(ARegisters), nameof(ARegisters.OnUndefined)); + + if (Context.CurrBlock.Next != null) + { + Context.EmitLoadState(Context.CurrBlock.Next); + } } } } \ No newline at end of file diff --git a/Ryujinx/Cpu/Memory/AMemoryMapInfo.cs b/Ryujinx/Cpu/Memory/AMemoryMapInfo.cs index 8ba6c25e6..44b2cc079 100644 --- a/Ryujinx/Cpu/Memory/AMemoryMapInfo.cs +++ b/Ryujinx/Cpu/Memory/AMemoryMapInfo.cs @@ -5,14 +5,16 @@ namespace ChocolArm64.Memory public long Position { get; private set; } public long Size { get; private set; } public int Type { get; private set; } + public int Attr { get; private set; } public AMemoryPerm Perm { get; private set; } - public AMemoryMapInfo(long Position, long Size, int Type, AMemoryPerm Perm) + public AMemoryMapInfo(long Position, long Size, int Type, int Attr, AMemoryPerm Perm) { this.Position = Position; this.Size = Size; this.Type = Type; + this.Attr = Attr; this.Perm = Perm; } } diff --git a/Ryujinx/Cpu/Memory/AMemoryMgr.cs b/Ryujinx/Cpu/Memory/AMemoryMgr.cs index 544e51302..05284059e 100644 --- a/Ryujinx/Cpu/Memory/AMemoryMgr.cs +++ b/Ryujinx/Cpu/Memory/AMemoryMgr.cs @@ -1,5 +1,3 @@ -using System.Runtime.CompilerServices; - namespace ChocolArm64.Memory { public class AMemoryMgr @@ -27,24 +25,23 @@ namespace ChocolArm64.Memory private enum PTMap { Unmapped, - Physical, - Mirror + Mapped } private struct PTEntry { - public long Position; - public int Type; - public PTMap Map; public AMemoryPerm Perm; - public PTEntry(long Position, int Type, PTMap Map, AMemoryPerm Perm) + public int Type; + public int Attr; + + public PTEntry(PTMap Map, AMemoryPerm Perm, int Type, int Attr) { - this.Position = Position; - this.Type = Type; - this.Map = Map; - this.Perm = Perm; + this.Map = Map; + this.Perm = Perm; + this.Type = Type; + this.Attr = Attr; } } @@ -53,7 +50,7 @@ namespace ChocolArm64.Memory private bool IsHeapInitialized; public long HeapAddr { get; private set; } - public int HeapSize { get; private set; } + public long HeapSize { get; private set; } public AMemoryMgr(AMemoryAlloc Allocator) { @@ -101,10 +98,10 @@ namespace ChocolArm64.Memory return false; } - public void SetHeapSize(int Size, int Type) + public void SetHeapSize(long Size, int Type) { //TODO: Return error when theres no enough space to allocate heap. - Size = (int)AMemoryHelper.PageRoundUp(Size); + Size = AMemoryHelper.PageRoundUp(Size); long Position = HeapAddr; @@ -132,40 +129,13 @@ namespace ChocolArm64.Memory HeapSize = Size; } - public bool MapPhys(long Src, long Dst, long Size, int Type, AMemoryPerm Perm) - { - Src = AMemoryHelper.PageRoundDown(Src); - Dst = AMemoryHelper.PageRoundDown(Dst); - - Size = AMemoryHelper.PageRoundUp(Size); - - if (Dst < 0 || Dst + Size >= RamSize) - { - return false; - } - - long PagesCount = Size / PageSize; - - while (PagesCount-- > 0) - { - SetPTEntry(Src, new PTEntry(Dst, Type, PTMap.Physical, Perm)); - - Src += PageSize; - Dst += PageSize; - } - - return true; - } - public void MapPhys(long Position, long Size, int Type, AMemoryPerm Perm) { while (Size > 0) { if (!IsMapped(Position)) { - long PhysPos = Allocator.Alloc(PageSize); - - SetPTEntry(Position, new PTEntry(PhysPos, Type, PTMap.Physical, Perm)); + SetPTEntry(Position, new PTEntry(PTMap.Mapped, Perm, Type, 0)); } long CPgSize = PageSize - (Position & PageMask); @@ -186,13 +156,19 @@ namespace ChocolArm64.Memory while (PagesCount-- > 0) { - PTEntry Entry = GetPTEntry(Src); + PTEntry SrcEntry = GetPTEntry(Src); + PTEntry DstEntry = GetPTEntry(Dst); - Entry.Type = Type; - Entry.Map = PTMap.Mirror; - Entry.Position = Dst; + DstEntry.Map = PTMap.Mapped; + DstEntry.Type = Type; + DstEntry.Perm = SrcEntry.Perm; - SetPTEntry(Src, Entry); + SrcEntry.Perm = AMemoryPerm.None; + + SrcEntry.Attr |= 1; + + SetPTEntry(Src, SrcEntry); + SetPTEntry(Dst, DstEntry); Src += PageSize; Dst += PageSize; @@ -229,9 +205,10 @@ namespace ChocolArm64.Memory { PTEntry Entry = GetPTEntry(Pos); - return Entry.Type == BaseEntry.Type && - Entry.Map == BaseEntry.Map && - Entry.Perm == BaseEntry.Perm; + return Entry.Map == BaseEntry.Map && + Entry.Perm == BaseEntry.Perm && + Entry.Type == BaseEntry.Type && + Entry.Attr == BaseEntry.Attr; } long Start = Position; @@ -249,7 +226,12 @@ namespace ChocolArm64.Memory long Size = End - Start; - return new AMemoryMapInfo(Start, Size, BaseEntry.Type, BaseEntry.Perm); + return new AMemoryMapInfo( + Start, + Size, + BaseEntry.Type, + BaseEntry.Attr, + BaseEntry.Perm); } public bool HasPermission(long Position, AMemoryPerm Perm) @@ -257,7 +239,6 @@ namespace ChocolArm64.Memory return GetPTEntry(Position).Perm.HasFlag(Perm); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool IsMapped(long Position) { if (Position >> PTLvl0Bits + PTLvl1Bits + PTPageBits != 0) @@ -276,7 +257,6 @@ namespace ChocolArm64.Memory return PageTable[L0][L1].Map != PTMap.Unmapped; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private PTEntry GetPTEntry(long Position) { long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask; @@ -290,7 +270,6 @@ namespace ChocolArm64.Memory return PageTable[L0][L1]; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SetPTEntry(long Position, PTEntry Entry) { long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask; diff --git a/Ryujinx/Cpu/State/SvcEventArgs.cs b/Ryujinx/Cpu/State/AInstExceptEventArgs.cs similarity index 61% rename from Ryujinx/Cpu/State/SvcEventArgs.cs rename to Ryujinx/Cpu/State/AInstExceptEventArgs.cs index 3a43241a6..f2ee039b6 100644 --- a/Ryujinx/Cpu/State/SvcEventArgs.cs +++ b/Ryujinx/Cpu/State/AInstExceptEventArgs.cs @@ -2,11 +2,11 @@ using System; namespace ChocolArm64.State { - public class SvcEventArgs : EventArgs + public class AInstExceptEventArgs : EventArgs { public int Id { get; private set; } - public SvcEventArgs(int Id) + public AInstExceptEventArgs(int Id) { this.Id = Id; } diff --git a/Ryujinx/Cpu/State/AInstUndEventArgs.cs b/Ryujinx/Cpu/State/AInstUndEventArgs.cs new file mode 100644 index 000000000..53de65a33 --- /dev/null +++ b/Ryujinx/Cpu/State/AInstUndEventArgs.cs @@ -0,0 +1,16 @@ +using System; + +namespace ChocolArm64.State +{ + public class AInstUndEventArgs : EventArgs + { + public long Position { get; private set; } + public int RawOpCode { get; private set; } + + public AInstUndEventArgs(long Position, int RawOpCode) + { + this.Position = Position; + this.RawOpCode = RawOpCode; + } + } +} \ No newline at end of file diff --git a/Ryujinx/Cpu/State/ARegisters.cs b/Ryujinx/Cpu/State/ARegisters.cs index 76b8f9b3a..076567246 100644 --- a/Ryujinx/Cpu/State/ARegisters.cs +++ b/Ryujinx/Cpu/State/ARegisters.cs @@ -42,17 +42,23 @@ namespace ChocolArm64.State public long CntpctEl0 => Environment.TickCount * TicksPerMS; - public event EventHandler SvcCall; - public event EventHandler Undefined; + public event EventHandler Break; + public event EventHandler SvcCall; + public event EventHandler Undefined; + + public void OnBreak(int Imm) + { + Break?.Invoke(this, new AInstExceptEventArgs(Imm)); + } public void OnSvcCall(int Imm) { - SvcCall?.Invoke(this, new SvcEventArgs(Imm)); + SvcCall?.Invoke(this, new AInstExceptEventArgs(Imm)); } - public void OnUndefined() + public void OnUndefined(long Position, int RawOpCode) { - Undefined?.Invoke(this, EventArgs.Empty); + Undefined?.Invoke(this, new AInstUndEventArgs(Position, RawOpCode)); } } } \ No newline at end of file diff --git a/Ryujinx/Gpu/NsGpuMemoryMgr.cs b/Ryujinx/Gpu/NsGpuMemoryMgr.cs index e555f2af3..563a5c099 100644 --- a/Ryujinx/Gpu/NsGpuMemoryMgr.cs +++ b/Ryujinx/Gpu/NsGpuMemoryMgr.cs @@ -1,5 +1,3 @@ -using System.Runtime.CompilerServices; - namespace Ryujinx.Gpu { class NsGpuMemoryMgr @@ -16,7 +14,7 @@ namespace Ryujinx.Gpu private const int PTLvl0Mask = PTLvl0Size - 1; private const int PTLvl1Mask = PTLvl1Size - 1; - private const int PageMask = PageSize - 1; + private const int PageMask = PageSize - 1; private const int PTLvl0Bit = PTPageBits + PTLvl0Bits; private const int PTLvl1Bit = PTPageBits; @@ -107,6 +105,11 @@ namespace Ryujinx.Gpu long Position = 0; long FreeSize = 0; + if (Align < 1) + { + Align = 1; + } + Align = (Align + PageMask) & ~PageMask; while (Position + FreeSize < AddrSize) @@ -149,7 +152,6 @@ namespace Ryujinx.Gpu return BasePos + (Position & PageMask); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool HasPTAddr(long Position) { if (Position >> PTLvl0Bits + PTLvl1Bits + PTPageBits != 0) @@ -168,7 +170,6 @@ namespace Ryujinx.Gpu return PageTable[L0][L1] != PteUnmapped; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private long GetPTAddr(long Position) { long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask; @@ -182,7 +183,6 @@ namespace Ryujinx.Gpu return PageTable[L0][L1]; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SetPTAddr(long Position, long TgtAddr) { long L0 = (Position >> PTLvl0Bit) & PTLvl0Mask; diff --git a/Ryujinx/OsHle/Exceptions/GuestBrokeExecutionException.cs b/Ryujinx/OsHle/Exceptions/GuestBrokeExecutionException.cs new file mode 100644 index 000000000..1369c57b2 --- /dev/null +++ b/Ryujinx/OsHle/Exceptions/GuestBrokeExecutionException.cs @@ -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) { } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Exceptions/UndefinedInstructionException.cs b/Ryujinx/OsHle/Exceptions/UndefinedInstructionException.cs new file mode 100644 index 000000000..86033a82a --- /dev/null +++ b/Ryujinx/OsHle/Exceptions/UndefinedInstructionException.cs @@ -0,0 +1,13 @@ +using System; + +namespace Ryujinx.OsHle.Exceptions +{ + public class UndefinedInstructionException : Exception + { + private const string ExMsg = "The instruction at 0x{0:x16} (opcode 0x{1:x8}) is undefined!"; + + public UndefinedInstructionException() : base() { } + + public UndefinedInstructionException(long Position, int OpCode) : base(string.Format(ExMsg, Position, OpCode)) { } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Ipc/IpcHandler.cs b/Ryujinx/OsHle/Ipc/IpcHandler.cs index c8b26dba6..ff90d873b 100644 --- a/Ryujinx/OsHle/Ipc/IpcHandler.cs +++ b/Ryujinx/OsHle/Ipc/IpcHandler.cs @@ -10,8 +10,6 @@ namespace Ryujinx.OsHle.Ipc { static class IpcHandler { - private delegate long ServiceProcessRequest(ServiceCtx Context); - private static Dictionary<(string, int), ServiceProcessRequest> ServiceCmds = new Dictionary<(string, int), ServiceProcessRequest>() { @@ -71,122 +69,10 @@ namespace Ryujinx.OsHle.Ipc { ( "vi:m", 2), Service.ViGetDisplayService }, }; - private static Dictionary<(Type, int), ServiceProcessRequest> ObjectCmds = - new Dictionary<(Type, int), ServiceProcessRequest>() - { - //IManagerForApplication - { (typeof(AccIManagerForApplication), 0), AccIManagerForApplication.CheckAvailability }, - { (typeof(AccIManagerForApplication), 1), AccIManagerForApplication.GetAccountId }, - - //IProfile - { (typeof(AccIProfile), 1), AccIProfile.GetBase }, - - //IApplicationFunctions - { (typeof(AmIApplicationFunctions), 1), AmIApplicationFunctions.PopLaunchParameter }, - { (typeof(AmIApplicationFunctions), 20), AmIApplicationFunctions.EnsureSaveData }, - { (typeof(AmIApplicationFunctions), 21), AmIApplicationFunctions.GetDesiredLanguage }, - { (typeof(AmIApplicationFunctions), 40), AmIApplicationFunctions.NotifyRunning }, - - //IApplicationProxy - { (typeof(AmIApplicationProxy), 0), AmIApplicationProxy.GetCommonStateGetter }, - { (typeof(AmIApplicationProxy), 1), AmIApplicationProxy.GetSelfController }, - { (typeof(AmIApplicationProxy), 2), AmIApplicationProxy.GetWindowController }, - { (typeof(AmIApplicationProxy), 3), AmIApplicationProxy.GetAudioController }, - { (typeof(AmIApplicationProxy), 4), AmIApplicationProxy.GetDisplayController }, - { (typeof(AmIApplicationProxy), 11), AmIApplicationProxy.GetLibraryAppletCreator }, - { (typeof(AmIApplicationProxy), 20), AmIApplicationProxy.GetApplicationFunctions }, - { (typeof(AmIApplicationProxy), 1000), AmIApplicationProxy.GetDebugFunctions }, - - //ICommonStateGetter - { (typeof(AmICommonStateGetter), 0), AmICommonStateGetter.GetEventHandle }, - { (typeof(AmICommonStateGetter), 1), AmICommonStateGetter.ReceiveMessage }, - { (typeof(AmICommonStateGetter), 5), AmICommonStateGetter.GetOperationMode }, - { (typeof(AmICommonStateGetter), 6), AmICommonStateGetter.GetPerformanceMode }, - { (typeof(AmICommonStateGetter), 9), AmICommonStateGetter.GetCurrentFocusState }, - - //ISelfController - { (typeof(AmISelfController), 11), AmISelfController.SetOperationModeChangedNotification }, - { (typeof(AmISelfController), 12), AmISelfController.SetPerformanceModeChangedNotification }, - { (typeof(AmISelfController), 13), AmISelfController.SetFocusHandlingMode }, - { (typeof(AmISelfController), 16), AmISelfController.SetOutOfFocusSuspendingEnabled }, - - //IStorage - { (typeof(AmIStorage), 0), AmIStorage.Open }, - - //IStorageAccessor - { (typeof(AmIStorageAccessor), 0), AmIStorageAccessor.GetSize }, - { (typeof(AmIStorageAccessor), 11), AmIStorageAccessor.Read }, - - //IWindowController - { (typeof(AmIWindowController), 1), AmIWindowController.GetAppletResourceUserId }, - { (typeof(AmIWindowController), 10), AmIWindowController.AcquireForegroundRights }, - - //ISession - { (typeof(ApmISession), 0), ApmISession.SetPerformanceConfiguration }, - - //IAudioRenderer - { (typeof(AudIAudioRenderer), 4), AudIAudioRenderer.RequestUpdateAudioRenderer }, - { (typeof(AudIAudioRenderer), 5), AudIAudioRenderer.StartAudioRenderer }, - { (typeof(AudIAudioRenderer), 6), AudIAudioRenderer.StopAudioRenderer }, - { (typeof(AudIAudioRenderer), 7), AudIAudioRenderer.QuerySystemEvent }, - - //IAudioOut - { (typeof(AudIAudioOut), 0), AudIAudioOut.GetAudioOutState }, - { (typeof(AudIAudioOut), 1), AudIAudioOut.StartAudioOut }, - { (typeof(AudIAudioOut), 2), AudIAudioOut.StopAudioOut }, - { (typeof(AudIAudioOut), 3), AudIAudioOut.AppendAudioOutBuffer }, - { (typeof(AudIAudioOut), 4), AudIAudioOut.RegisterBufferEvent }, - { (typeof(AudIAudioOut), 5), AudIAudioOut.GetReleasedAudioOutBuffer }, - { (typeof(AudIAudioOut), 6), AudIAudioOut.ContainsAudioOutBuffer }, - { (typeof(AudIAudioOut), 7), AudIAudioOut.AppendAudioOutBuffer_ex }, - { (typeof(AudIAudioOut), 8), AudIAudioOut.GetReleasedAudioOutBuffer_ex }, - - //IFile - { (typeof(FspSrvIFile), 0), FspSrvIFile.Read }, - { (typeof(FspSrvIFile), 1), FspSrvIFile.Write }, - - //IFileSystem - { (typeof(FspSrvIFileSystem), 7), FspSrvIFileSystem.GetEntryType }, - { (typeof(FspSrvIFileSystem), 8), FspSrvIFileSystem.OpenFile }, - { (typeof(FspSrvIFileSystem), 10), FspSrvIFileSystem.Commit }, - - //IStorage - { (typeof(FspSrvIStorage), 0), FspSrvIStorage.Read }, - - //IAppletResource - { (typeof(HidIAppletResource), 0), HidIAppletResource.GetSharedMemoryHandle }, - - //ISystemClock - { (typeof(TimeISystemClock), 0), TimeISystemClock.GetCurrentTime }, - - //IApplicationDisplayService - { (typeof(ViIApplicationDisplayService), 100), ViIApplicationDisplayService.GetRelayService }, - { (typeof(ViIApplicationDisplayService), 101), ViIApplicationDisplayService.GetSystemDisplayService }, - { (typeof(ViIApplicationDisplayService), 102), ViIApplicationDisplayService.GetManagerDisplayService }, - { (typeof(ViIApplicationDisplayService), 103), ViIApplicationDisplayService.GetIndirectDisplayTransactionService }, - { (typeof(ViIApplicationDisplayService), 1010), ViIApplicationDisplayService.OpenDisplay }, - { (typeof(ViIApplicationDisplayService), 2020), ViIApplicationDisplayService.OpenLayer }, - { (typeof(ViIApplicationDisplayService), 2030), ViIApplicationDisplayService.CreateStrayLayer }, - { (typeof(ViIApplicationDisplayService), 2101), ViIApplicationDisplayService.SetLayerScalingMode }, - { (typeof(ViIApplicationDisplayService), 5202), ViIApplicationDisplayService.GetDisplayVSyncEvent }, - - //IHOSBinderDriver - { (typeof(ViIHOSBinderDriver), 0), ViIHOSBinderDriver.TransactParcel }, - { (typeof(ViIHOSBinderDriver), 1), ViIHOSBinderDriver.AdjustRefcount }, - { (typeof(ViIHOSBinderDriver), 2), ViIHOSBinderDriver.GetNativeHandle }, - - //IManagerDisplayService - { (typeof(ViIManagerDisplayService), 2010), ViIManagerDisplayService.CreateManagedLayer }, - { (typeof(ViIManagerDisplayService), 6000), ViIManagerDisplayService.AddToLayerStack }, - - //ISystemDisplayService - { (typeof(ViISystemDisplayService), 2205), ViISystemDisplayService.SetLayerZ }, - }; - private const long SfciMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'I' << 24; private const long SfcoMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'O' << 24; - public static void ProcessRequest( + public static void IpcCall( Switch Ns, AMemory Memory, HSession Session, @@ -221,15 +107,15 @@ namespace Ryujinx.OsHle.Ipc if (Obj is HDomain) { - DbgServiceName = $"{ServiceName} {CmdId}"; - ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); + + DbgServiceName = $"{ServiceName} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } else if (Obj != null) { - DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}"; + ((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); - ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq); + DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } } else if (Request.DomCmd == IpcDomCmd.DeleteObj) @@ -250,15 +136,15 @@ namespace Ryujinx.OsHle.Ipc { object Obj = ((HSessionObj)Session).Obj; - DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}"; + ((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); - ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq); + DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } else { - DbgServiceName = $"{ServiceName} {CmdId}"; - ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); + + DbgServiceName = $"{ServiceName} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } } diff --git a/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs b/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs new file mode 100644 index 000000000..838a6aea8 --- /dev/null +++ b/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs @@ -0,0 +1,4 @@ +namespace Ryujinx.OsHle.Ipc +{ + delegate long ServiceProcessRequest(ServiceCtx Context); +} \ No newline at end of file diff --git a/Ryujinx/OsHle/MemoryInfo.cs b/Ryujinx/OsHle/MemoryInfo.cs index adf863b27..395ccf73e 100644 --- a/Ryujinx/OsHle/MemoryInfo.cs +++ b/Ryujinx/OsHle/MemoryInfo.cs @@ -18,7 +18,7 @@ namespace Ryujinx.OsHle BaseAddress = MapInfo.Position; Size = MapInfo.Size; MemType = MapInfo.Type; - MemAttr = 0; + MemAttr = MapInfo.Attr; MemPerm = (int)MapInfo.Perm; IpcRefCount = 0; DeviceRefCount = 0; diff --git a/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs b/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs new file mode 100644 index 000000000..404ee7da6 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Acc +{ + class IManagerForApplication : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IManagerForApplication() + { + m_Commands = new Dictionary() + { + { 0, CheckAvailability }, + { 1, GetAccountId } + }; + } + + public long CheckAvailability(ServiceCtx Context) + { + return 0; + } + + public long GetAccountId(ServiceCtx Context) + { + Context.ResponseData.Write(0xcafeL); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Acc/IProfile.cs b/Ryujinx/OsHle/Objects/Acc/IProfile.cs new file mode 100644 index 000000000..c84c7ae28 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Acc/IProfile.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Acc +{ + class IProfile : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IProfile() + { + m_Commands = new Dictionary() + { + { 1, GetBase } + }; + } + + public long GetBase(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs b/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs deleted file mode 100644 index 8e2a002ba..000000000 --- a/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AccIManagerForApplication - { - public static long CheckAvailability(ServiceCtx Context) - { - return 0; - } - - public static long GetAccountId(ServiceCtx Context) - { - Context.ResponseData.Write(0xcafeL); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AccIProfile.cs b/Ryujinx/OsHle/Objects/AccIProfile.cs deleted file mode 100644 index 2dbe189d7..000000000 --- a/Ryujinx/OsHle/Objects/AccIProfile.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AccIProfile - { - public static long GetBase(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs b/Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs similarity index 59% rename from Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs rename to Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs index b5712484e..138d9084f 100644 --- a/Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs +++ b/Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs @@ -1,22 +1,39 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; using System.IO; using static Ryujinx.OsHle.Objects.ObjHelper; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Am { - class AmIApplicationFunctions + class IApplicationFunctions : IIpcInterface { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationFunctions() + { + m_Commands = new Dictionary() + { + { 1, PopLaunchParameter }, + { 20, EnsureSaveData }, + { 21, GetDesiredLanguage }, + { 40, NotifyRunning } + }; + } + private const uint LaunchParamsMagic = 0xc79497ca; - public static long PopLaunchParameter(ServiceCtx Context) + public long PopLaunchParameter(ServiceCtx Context) { //Only the first 0x18 bytes of the Data seems to be actually used. - MakeObject(Context, new AmIStorage(MakeLaunchParams())); + MakeObject(Context, new IStorage(MakeLaunchParams())); return 0; } - public static long EnsureSaveData(ServiceCtx Context) + public long EnsureSaveData(ServiceCtx Context) { long UIdLow = Context.RequestData.ReadInt64(); long UIdHigh = Context.RequestData.ReadInt64(); @@ -26,7 +43,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long GetDesiredLanguage(ServiceCtx Context) + public long GetDesiredLanguage(ServiceCtx Context) { //This is an enumerator where each number is a differnet language. //0 is Japanese and 1 is English, need to figure out the other codes. @@ -35,14 +52,14 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long NotifyRunning(ServiceCtx Context) + public long NotifyRunning(ServiceCtx Context) { Context.ResponseData.Write(1); return 0; } - private static byte[] MakeLaunchParams() + private byte[] MakeLaunchParams() { //Size needs to be at least 0x88 bytes otherwise application errors. using (MemoryStream MS = new MemoryStream()) diff --git a/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs b/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs new file mode 100644 index 000000000..3d692d6bc --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs @@ -0,0 +1,85 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IApplicationProxy : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationProxy() + { + m_Commands = new Dictionary() + { + { 0, GetCommonStateGetter }, + { 1, GetSelfController }, + { 2, GetWindowController }, + { 3, GetAudioController }, + { 4, GetDisplayController }, + { 11, GetLibraryAppletCreator }, + { 20, GetApplicationFunctions }, + { 1000, GetDebugFunctions } + }; + } + + public long GetCommonStateGetter(ServiceCtx Context) + { + MakeObject(Context, new ICommonStateGetter()); + + return 0; + } + + public long GetSelfController(ServiceCtx Context) + { + MakeObject(Context, new ISelfController()); + + return 0; + } + + public long GetWindowController(ServiceCtx Context) + { + MakeObject(Context, new IWindowController()); + + return 0; + } + + public long GetAudioController(ServiceCtx Context) + { + MakeObject(Context, new IAudioController()); + + return 0; + } + + public long GetDisplayController(ServiceCtx Context) + { + MakeObject(Context, new IDisplayController()); + + return 0; + } + + public long GetLibraryAppletCreator(ServiceCtx Context) + { + MakeObject(Context, new ILibraryAppletCreator()); + + return 0; + } + + public long GetApplicationFunctions(ServiceCtx Context) + { + MakeObject(Context, new IApplicationFunctions()); + + return 0; + } + + public long GetDebugFunctions(ServiceCtx Context) + { + MakeObject(Context, new IDebugFunctions()); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IAudioController.cs b/Ryujinx/OsHle/Objects/Am/IAudioController.cs new file mode 100644 index 000000000..0ca49f892 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IAudioController.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IAudioController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioController() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs b/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs new file mode 100644 index 000000000..5a3af8e11 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs @@ -0,0 +1,74 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ICommonStateGetter : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ICommonStateGetter() + { + m_Commands = new Dictionary() + { + { 0, GetEventHandle }, + { 1, ReceiveMessage }, + { 5, GetOperationMode }, + { 6, GetPerformanceMode }, + { 9, GetCurrentFocusState }, + }; + } + + private enum FocusState + { + InFocus = 1, + OutOfFocus = 2 + } + + private enum OperationMode + { + Handheld = 0, + Docked = 1 + } + + public long GetEventHandle(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + + return 0; + } + + public long ReceiveMessage(ServiceCtx Context) + { + //Program expects 0xF at 0x17ae70 on puyo sdk, + //otherwise runs on a infinite loop until it reads said value. + //What it means is still unknown. + Context.ResponseData.Write(0xfL); + + return 0; //0x680; + } + + public long GetOperationMode(ServiceCtx Context) + { + Context.ResponseData.Write((byte)OperationMode.Handheld); + + return 0; + } + + public long GetPerformanceMode(ServiceCtx Context) + { + Context.ResponseData.Write((byte)0); + + return 0; + } + + public long GetCurrentFocusState(ServiceCtx Context) + { + Context.ResponseData.Write((byte)FocusState.InFocus); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs b/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs new file mode 100644 index 000000000..dc57e8e6e --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IDebugFunctions : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IDebugFunctions() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IDisplayController.cs b/Ryujinx/OsHle/Objects/Am/IDisplayController.cs new file mode 100644 index 000000000..886120866 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IDisplayController.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IDisplayController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IDisplayController() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs b/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs new file mode 100644 index 000000000..91fae3dd0 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ILibraryAppletCreator : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ILibraryAppletCreator() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs b/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs new file mode 100644 index 000000000..c462ff07f --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IParentalControlService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IParentalControlService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ISelfController.cs b/Ryujinx/OsHle/Objects/Am/ISelfController.cs new file mode 100644 index 000000000..c46396c55 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ISelfController.cs @@ -0,0 +1,53 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ISelfController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISelfController() + { + m_Commands = new Dictionary() + { + { 11, SetOperationModeChangedNotification }, + { 12, SetPerformanceModeChangedNotification }, + { 13, SetFocusHandlingMode }, + { 16, SetOutOfFocusSuspendingEnabled } + }; + } + + public long SetOperationModeChangedNotification(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetPerformanceModeChangedNotification(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetFocusHandlingMode(ServiceCtx Context) + { + bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false; + bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false; + bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IStorage.cs b/Ryujinx/OsHle/Objects/Am/IStorage.cs new file mode 100644 index 000000000..d5a7ee610 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IStorage.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IStorage : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public byte[] Data { get; private set; } + + public IStorage(byte[] Data) + { + m_Commands = new Dictionary() + { + { 0, Open } + }; + + this.Data = Data; + } + + public long Open(ServiceCtx Context) + { + MakeObject(Context, new IStorageAccessor(this)); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIStorageAccessor.cs b/Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs similarity index 56% rename from Ryujinx/OsHle/Objects/AmIStorageAccessor.cs rename to Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs index 62007ef81..bcf0fc01c 100644 --- a/Ryujinx/OsHle/Objects/AmIStorageAccessor.cs +++ b/Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs @@ -1,32 +1,38 @@ using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; using System; +using System.Collections.Generic; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Am { - class AmIStorageAccessor + class IStorageAccessor : IIpcInterface { - public AmIStorage Storage { get; private set; } + private Dictionary m_Commands; - public AmIStorageAccessor(AmIStorage Storage) + public IReadOnlyDictionary Commands => m_Commands; + + private IStorage Storage; + + public IStorageAccessor(IStorage Storage) { + m_Commands = new Dictionary() + { + { 0, GetSize }, + { 11, Read } + }; + this.Storage = Storage; } - public static long GetSize(ServiceCtx Context) + public long GetSize(ServiceCtx Context) { - AmIStorageAccessor Accessor = Context.GetObject(); - - Context.ResponseData.Write((long)Accessor.Storage.Data.Length); + Context.ResponseData.Write((long)Storage.Data.Length); return 0; } - public static long Read(ServiceCtx Context) + public long Read(ServiceCtx Context) { - AmIStorageAccessor Accessor = Context.GetObject(); - - AmIStorage Storage = Accessor.Storage; - long ReadPosition = Context.RequestData.ReadInt64(); if (Context.Request.RecvListBuff.Count > 0) diff --git a/Ryujinx/OsHle/Objects/Am/IWindowController.cs b/Ryujinx/OsHle/Objects/Am/IWindowController.cs new file mode 100644 index 000000000..1796644e3 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IWindowController.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IWindowController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IWindowController() + { + m_Commands = new Dictionary() + { + { 1, GetAppletResourceUserId }, + { 10, AcquireForegroundRights } + }; + } + + public long GetAppletResourceUserId(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + + return 0; + } + + public long AcquireForegroundRights(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs b/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs deleted file mode 100644 index 2b0bc346d..000000000 --- a/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs +++ /dev/null @@ -1,63 +0,0 @@ -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class AmIApplicationProxy - { - public static long GetCommonStateGetter(ServiceCtx Context) - { - MakeObject(Context, new AmICommonStateGetter()); - - return 0; - } - - public static long GetSelfController(ServiceCtx Context) - { - MakeObject(Context, new AmISelfController()); - - return 0; - } - - public static long GetWindowController(ServiceCtx Context) - { - MakeObject(Context, new AmIWindowController()); - - return 0; - } - - public static long GetAudioController(ServiceCtx Context) - { - MakeObject(Context, new AmIAudioController()); - - return 0; - } - - public static long GetDisplayController(ServiceCtx Context) - { - MakeObject(Context, new AmIDisplayController()); - - return 0; - } - - public static long GetLibraryAppletCreator(ServiceCtx Context) - { - MakeObject(Context, new AmILibraryAppletCreator()); - - return 0; - } - - public static long GetApplicationFunctions(ServiceCtx Context) - { - MakeObject(Context, new AmIApplicationFunctions()); - - return 0; - } - - public static long GetDebugFunctions(ServiceCtx Context) - { - MakeObject(Context, new AmIDebugFunctions()); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIAudioController.cs b/Ryujinx/OsHle/Objects/AmIAudioController.cs deleted file mode 100644 index 59d94bda4..000000000 --- a/Ryujinx/OsHle/Objects/AmIAudioController.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIAudioController - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs b/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs deleted file mode 100644 index 32f065c81..000000000 --- a/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmICommonStateGetter - { - private enum FocusState - { - InFocus = 1, - OutOfFocus = 2 - } - - private enum OperationMode - { - Handheld = 0, - Docked = 1 - } - - public static long GetEventHandle(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - - return 0; - } - - public static long ReceiveMessage(ServiceCtx Context) - { - //Program expects 0xF at 0x17ae70 on puyo sdk, - //otherwise runs on a infinite loop until it reads said value. - //What it means is still unknown. - Context.ResponseData.Write(0xfL); - - return 0; //0x680; - } - - public static long GetOperationMode(ServiceCtx Context) - { - Context.ResponseData.Write((byte)OperationMode.Handheld); - - return 0; - } - - public static long GetPerformanceMode(ServiceCtx Context) - { - Context.ResponseData.Write((byte)0); - - return 0; - } - - public static long GetCurrentFocusState(ServiceCtx Context) - { - Context.ResponseData.Write((byte)FocusState.InFocus); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs b/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs deleted file mode 100644 index 9794c43f4..000000000 --- a/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIDebugFunctions - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIDisplayController.cs b/Ryujinx/OsHle/Objects/AmIDisplayController.cs deleted file mode 100644 index be36ca0ca..000000000 --- a/Ryujinx/OsHle/Objects/AmIDisplayController.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIDisplayController - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs b/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs deleted file mode 100644 index 585df9e99..000000000 --- a/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmILibraryAppletCreator - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIParentalControlService.cs b/Ryujinx/OsHle/Objects/AmIParentalControlService.cs deleted file mode 100644 index 12c3c2a96..000000000 --- a/Ryujinx/OsHle/Objects/AmIParentalControlService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIParentalControlService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmISelfController.cs b/Ryujinx/OsHle/Objects/AmISelfController.cs deleted file mode 100644 index 8affb92b6..000000000 --- a/Ryujinx/OsHle/Objects/AmISelfController.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmISelfController - { - public static long SetOperationModeChangedNotification(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetPerformanceModeChangedNotification(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetFocusHandlingMode(ServiceCtx Context) - { - bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetOutOfFocusSuspendingEnabled(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIStorage.cs b/Ryujinx/OsHle/Objects/AmIStorage.cs deleted file mode 100644 index 7e608ac8c..000000000 --- a/Ryujinx/OsHle/Objects/AmIStorage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class AmIStorage - { - public byte[] Data { get; private set; } - - public AmIStorage(byte[] Data) - { - this.Data = Data; - } - - public static long Open(ServiceCtx Context) - { - AmIStorage Storage = Context.GetObject(); - - MakeObject(Context, new AmIStorageAccessor(Storage)); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIWindowController.cs b/Ryujinx/OsHle/Objects/AmIWindowController.cs deleted file mode 100644 index ea967ae84..000000000 --- a/Ryujinx/OsHle/Objects/AmIWindowController.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIWindowController - { - public static long GetAppletResourceUserId(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - - return 0; - } - - public static long AcquireForegroundRights(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Apm/ISession.cs b/Ryujinx/OsHle/Objects/Apm/ISession.cs new file mode 100644 index 000000000..f3965b484 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Apm/ISession.cs @@ -0,0 +1,28 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Apm +{ + class ISession : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISession() + { + m_Commands = new Dictionary() + { + { 0, SetPerformanceConfiguration } + }; + } + + public long SetPerformanceConfiguration(ServiceCtx Context) + { + int PerfMode = Context.RequestData.ReadInt32(); + int PerfConfig = Context.RequestData.ReadInt32(); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ApmISession.cs b/Ryujinx/OsHle/Objects/ApmISession.cs deleted file mode 100644 index 2b2c03515..000000000 --- a/Ryujinx/OsHle/Objects/ApmISession.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ApmISession - { - public static long SetPerformanceConfiguration(ServiceCtx Context) - { - int PerfMode = Context.RequestData.ReadInt32(); - int PerfConfig = Context.RequestData.ReadInt32(); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AudIAudioOut.cs b/Ryujinx/OsHle/Objects/Aud/IAudioOut.cs similarity index 69% rename from Ryujinx/OsHle/Objects/AudIAudioOut.cs rename to Ryujinx/OsHle/Objects/Aud/IAudioOut.cs index 029c058f2..5feb67d89 100644 --- a/Ryujinx/OsHle/Objects/AudIAudioOut.cs +++ b/Ryujinx/OsHle/Objects/Aud/IAudioOut.cs @@ -1,16 +1,36 @@ using ChocolArm64.Memory; -using OpenTK.Audio; -using OpenTK.Audio.OpenAL; using Ryujinx.OsHle.Handles; using Ryujinx.OsHle.Ipc; +using OpenTK.Audio; +using OpenTK.Audio.OpenAL; using System; using System.Collections.Generic; using System.IO; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Aud { - class AudIAudioOut + class IAudioOut : IIpcInterface { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioOut() + { + m_Commands = new Dictionary() + { + { 0, GetAudioOutState }, + { 1, StartAudioOut }, + { 2, StopAudioOut }, + { 3, AppendAudioOutBuffer }, + { 4, RegisterBufferEvent }, + { 5, GetReleasedAudioOutBuffer }, + { 6, ContainsAudioOutBuffer }, + { 7, AppendAudioOutBuffer_ex }, + { 8, GetReleasedAudioOutBuffer_ex } + }; + } + enum AudioOutState { Started, @@ -18,24 +38,24 @@ namespace Ryujinx.OsHle.Objects }; //IAudioOut - private static AudioOutState State = AudioOutState.Stopped; - private static Queue KeysQueue = new Queue(); + private AudioOutState State = AudioOutState.Stopped; + private Queue KeysQueue = new Queue(); //OpenAL - private static bool OpenALInstalled = true; - private static AudioContext AudioCtx; - private static int Source; - private static int Buffer; + private bool OpenALInstalled = true; + private AudioContext AudioCtx; + private int Source; + private int Buffer; //Return State of IAudioOut - public static long GetAudioOutState(ServiceCtx Context) + public long GetAudioOutState(ServiceCtx Context) { Context.ResponseData.Write((int)State); return 0; } - public static long StartAudioOut(ServiceCtx Context) + public long StartAudioOut(ServiceCtx Context) { if (State == AudioOutState.Stopped) { @@ -57,7 +77,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long StopAudioOut(ServiceCtx Context) + public long StopAudioOut(ServiceCtx Context) { if (State == AudioOutState.Started) { @@ -75,7 +95,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long AppendAudioOutBuffer(ServiceCtx Context) + public long AppendAudioOutBuffer(ServiceCtx Context) { long BufferId = Context.RequestData.ReadInt64(); @@ -109,7 +129,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long RegisterBufferEvent(ServiceCtx Context) + public long RegisterBufferEvent(ServiceCtx Context) { int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); @@ -118,7 +138,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long GetReleasedAudioOutBuffer(ServiceCtx Context) + public long GetReleasedAudioOutBuffer(ServiceCtx Context) { long TempKey = 0; @@ -141,17 +161,17 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long ContainsAudioOutBuffer(ServiceCtx Context) + public long ContainsAudioOutBuffer(ServiceCtx Context) { return 0; } - public static long AppendAudioOutBuffer_ex(ServiceCtx Context) + public long AppendAudioOutBuffer_ex(ServiceCtx Context) { return 0; } - public static long GetReleasedAudioOutBuffer_ex(ServiceCtx Context) + public long GetReleasedAudioOutBuffer_ex(ServiceCtx Context) { return 0; } diff --git a/Ryujinx/OsHle/Objects/AudIAudioRenderer.cs b/Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs similarity index 58% rename from Ryujinx/OsHle/Objects/AudIAudioRenderer.cs rename to Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs index 35a5b82da..a953d82a0 100644 --- a/Ryujinx/OsHle/Objects/AudIAudioRenderer.cs +++ b/Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs @@ -1,13 +1,29 @@ using Ryujinx.OsHle.Handles; using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Aud { - class AudIAudioRenderer + class IAudioRenderer : IIpcInterface { - public static long RequestUpdateAudioRenderer(ServiceCtx Context) + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioRenderer() { - //buffer < unknown, 5, 0 >) -> (buffer < unknown, 6, 0 >, buffer < unknown, 6, 0 > + m_Commands = new Dictionary() + { + { 4, RequestUpdateAudioRenderer }, + { 5, StartAudioRenderer }, + { 6, StopAudioRenderer }, + { 7, QuerySystemEvent } + }; + } + + public long RequestUpdateAudioRenderer(ServiceCtx Context) + { + //(buffer) -> (buffer, buffer) long Position = Context.Request.ReceiveBuff[0].Position; @@ -28,17 +44,17 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long StartAudioRenderer(ServiceCtx Context) + public long StartAudioRenderer(ServiceCtx Context) { return 0; } - public static long StopAudioRenderer(ServiceCtx Context) + public long StopAudioRenderer(ServiceCtx Context) { return 0; } - public static long QuerySystemEvent(ServiceCtx Context) + public long QuerySystemEvent(ServiceCtx Context) { int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); diff --git a/Ryujinx/OsHle/Objects/Friend/IFriendService.cs b/Ryujinx/OsHle/Objects/Friend/IFriendService.cs new file mode 100644 index 000000000..41084f8da --- /dev/null +++ b/Ryujinx/OsHle/Objects/Friend/IFriendService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Friend +{ + class IFriendService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IFriendService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FriendIFriendService.cs b/Ryujinx/OsHle/Objects/FriendIFriendService.cs deleted file mode 100644 index 9a39380a5..000000000 --- a/Ryujinx/OsHle/Objects/FriendIFriendService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class FriendIFriendService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrvIFile.cs b/Ryujinx/OsHle/Objects/FspSrv/IFile.cs similarity index 66% rename from Ryujinx/OsHle/Objects/FspSrvIFile.cs rename to Ryujinx/OsHle/Objects/FspSrv/IFile.cs index 4b9f8c37b..1c6cc2e29 100644 --- a/Ryujinx/OsHle/Objects/FspSrvIFile.cs +++ b/Ryujinx/OsHle/Objects/FspSrv/IFile.cs @@ -1,23 +1,32 @@ using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; using System; - +using System.Collections.Generic; using System.IO; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.FspSrv { - class FspSrvIFile : IDisposable + class IFile : IIpcInterface, IDisposable { - public Stream BaseStream { get; private set; } + private Dictionary m_Commands; - public FspSrvIFile(Stream BaseStream) + public IReadOnlyDictionary Commands => m_Commands; + + private Stream BaseStream; + + public IFile(Stream BaseStream) { + m_Commands = new Dictionary() + { + { 0, Read }, + { 1, Write } + }; + this.BaseStream = BaseStream; } - public static long Read(ServiceCtx Context) + public long Read(ServiceCtx Context) { - FspSrvIFile File = Context.GetObject(); - long Position = Context.Request.ReceiveBuff[0].Position; long Zero = Context.RequestData.ReadInt64(); @@ -26,7 +35,7 @@ namespace Ryujinx.OsHle.Objects byte[] Data = new byte[Size]; - int ReadSize = File.BaseStream.Read(Data, 0, (int)Size); + int ReadSize = BaseStream.Read(Data, 0, (int)Size); AMemoryHelper.WriteBytes(Context.Memory, Position, Data); @@ -38,10 +47,8 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long Write(ServiceCtx Context) + public long Write(ServiceCtx Context) { - FspSrvIFile File = Context.GetObject(); - long Position = Context.Request.SendBuff[0].Position; long Zero = Context.RequestData.ReadInt64(); @@ -50,8 +57,8 @@ namespace Ryujinx.OsHle.Objects byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, Position, (int)Size); - File.BaseStream.Seek(Offset, SeekOrigin.Begin); - File.BaseStream.Write(Data, 0, (int)Size); + BaseStream.Seek(Offset, SeekOrigin.Begin); + BaseStream.Write(Data, 0, (int)Size); return 0; } diff --git a/Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs b/Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs similarity index 53% rename from Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs rename to Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs index fed1c55ac..bf501594f 100644 --- a/Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs +++ b/Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs @@ -1,28 +1,39 @@ using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; using System.IO; using static Ryujinx.OsHle.Objects.ObjHelper; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.FspSrv { - class FspSrvIFileSystem + class IFileSystem : IIpcInterface { - public string FilePath { get; private set; } + private Dictionary m_Commands; - public FspSrvIFileSystem(string Path) + public IReadOnlyDictionary Commands => m_Commands; + + private string Path; + + public IFileSystem(string Path) { - this.FilePath = Path; + m_Commands = new Dictionary() + { + { 7, GetEntryType }, + { 8, OpenFile }, + { 10, Commit } + }; + + this.Path = Path; } - public static long GetEntryType(ServiceCtx Context) + public long GetEntryType(ServiceCtx Context) { - FspSrvIFileSystem FileSystem = Context.GetObject(); - long Position = Context.Request.PtrBuff[0].Position; string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); - string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); + string FileName = Context.Ns.VFs.GetFullPath(Path, Name); if (FileName == null) { @@ -37,17 +48,15 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long OpenFile(ServiceCtx Context) + public long OpenFile(ServiceCtx Context) { - FspSrvIFileSystem FileSystem = Context.GetObject(); - long Position = Context.Request.PtrBuff[0].Position; int FilterFlags = Context.RequestData.ReadInt32(); string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); - string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); + string FileName = Context.Ns.VFs.GetFullPath(Path, Name); if (FileName == null) { @@ -57,12 +66,12 @@ namespace Ryujinx.OsHle.Objects FileStream Stream = new FileStream(FileName, FileMode.OpenOrCreate); - MakeObject(Context, new FspSrvIFile(Stream)); + MakeObject(Context, new IFile(Stream)); return 0; } - public static long Commit(ServiceCtx Context) + public long Commit(ServiceCtx Context) { return 0; } diff --git a/Ryujinx/OsHle/Objects/FspSrvIStorage.cs b/Ryujinx/OsHle/Objects/FspSrv/IStorage.cs similarity index 55% rename from Ryujinx/OsHle/Objects/FspSrvIStorage.cs rename to Ryujinx/OsHle/Objects/FspSrv/IStorage.cs index 76ad8917a..40fb87cac 100644 --- a/Ryujinx/OsHle/Objects/FspSrvIStorage.cs +++ b/Ryujinx/OsHle/Objects/FspSrv/IStorage.cs @@ -1,22 +1,30 @@ using ChocolArm64.Memory; using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; using System.IO; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.FspSrv { - class FspSrvIStorage + class IStorage : IIpcInterface { - public Stream BaseStream { get; private set; } + private Dictionary m_Commands; - public FspSrvIStorage(Stream BaseStream) + public IReadOnlyDictionary Commands => m_Commands; + + private Stream BaseStream; + + public IStorage(Stream BaseStream) { + m_Commands = new Dictionary() + { + { 0, Read } + }; + this.BaseStream = BaseStream; } - public static long Read(ServiceCtx Context) + public long Read(ServiceCtx Context) { - FspSrvIStorage Storage = Context.GetObject(); - long Offset = Context.RequestData.ReadInt64(); long Size = Context.RequestData.ReadInt64(); @@ -32,8 +40,8 @@ namespace Ryujinx.OsHle.Objects byte[] Data = new byte[Size]; - Storage.BaseStream.Seek(Offset, SeekOrigin.Begin); - Storage.BaseStream.Read(Data, 0, Data.Length); + BaseStream.Seek(Offset, SeekOrigin.Begin); + BaseStream.Read(Data, 0, Data.Length); AMemoryHelper.WriteBytes(Context.Memory, BuffDesc.Position, Data); } diff --git a/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs b/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs new file mode 100644 index 000000000..ac7ccf564 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs @@ -0,0 +1,32 @@ +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Hid +{ + class IAppletResource : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public HSharedMem Handle; + + public IAppletResource(HSharedMem Handle) + { + m_Commands = new Dictionary() + { + { 0, GetSharedMemoryHandle } + }; + + this.Handle = Handle; + } + + public static long GetSharedMemoryHandle(ServiceCtx Context) + { + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.HidHandle); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/HidIAppletResource.cs b/Ryujinx/OsHle/Objects/HidIAppletResource.cs deleted file mode 100644 index 73b948df7..000000000 --- a/Ryujinx/OsHle/Objects/HidIAppletResource.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; - -namespace Ryujinx.OsHle.Objects -{ - class HidIAppletResource - { - public HSharedMem Handle; - - public HidIAppletResource(HSharedMem Handle) - { - this.Handle = Handle; - } - - public static long GetSharedMemoryHandle(ServiceCtx Context) - { - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.HidHandle); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/IIpcInterface.cs b/Ryujinx/OsHle/Objects/IIpcInterface.cs new file mode 100644 index 000000000..af0594cc1 --- /dev/null +++ b/Ryujinx/OsHle/Objects/IIpcInterface.cs @@ -0,0 +1,10 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects +{ + interface IIpcInterface + { + IReadOnlyDictionary Commands { get; } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs b/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs new file mode 100644 index 000000000..a5139bab0 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ISteadyClock : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISteadyClock() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ISystemClock.cs b/Ryujinx/OsHle/Objects/Time/ISystemClock.cs new file mode 100644 index 000000000..2c5b898b7 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ISystemClock.cs @@ -0,0 +1,30 @@ +using Ryujinx.OsHle.Ipc; +using System; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ISystemClock : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + private static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + public ISystemClock() + { + m_Commands = new Dictionary() + { + { 0, GetCurrentTime } + }; + } + + public long GetCurrentTime(ServiceCtx Context) + { + Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs b/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs new file mode 100644 index 000000000..29e7ec927 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ITimeZoneService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ITimeZoneService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeISteadyClock.cs b/Ryujinx/OsHle/Objects/TimeISteadyClock.cs deleted file mode 100644 index ead8c41a1..000000000 --- a/Ryujinx/OsHle/Objects/TimeISteadyClock.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class TimeISteadyClock - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeISystemClock.cs b/Ryujinx/OsHle/Objects/TimeISystemClock.cs deleted file mode 100644 index d9a3a073e..000000000 --- a/Ryujinx/OsHle/Objects/TimeISystemClock.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Ryujinx.OsHle.Objects -{ - class TimeISystemClock - { - private static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - public static long GetCurrentTime(ServiceCtx Context) - { - Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs b/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs deleted file mode 100644 index af5490a61..000000000 --- a/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class TimeITimeZoneService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs similarity index 64% rename from Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs rename to Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs index 174c97b4f..4fa359280 100644 --- a/Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs +++ b/Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs @@ -1,44 +1,65 @@ using ChocolArm64.Memory; using Ryujinx.OsHle.Handles; using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; using System.IO; using static Ryujinx.OsHle.Objects.Android.Parcel; using static Ryujinx.OsHle.Objects.ObjHelper; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Vi { - class ViIApplicationDisplayService + class IApplicationDisplayService : IIpcInterface { - public static long GetRelayService(ServiceCtx Context) + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationDisplayService() { - MakeObject(Context, new ViIHOSBinderDriver()); + m_Commands = new Dictionary() + { + { 100, GetRelayService }, + { 101, GetSystemDisplayService }, + { 102, GetManagerDisplayService }, + { 103, GetIndirectDisplayTransactionService }, + { 1010, OpenDisplay }, + { 2020, OpenLayer }, + { 2030, CreateStrayLayer }, + { 2101, SetLayerScalingMode }, + { 5202, GetDisplayVSyncEvent } + }; + } + + public long GetRelayService(ServiceCtx Context) + { + MakeObject(Context, new IHOSBinderDriver()); return 0; } - public static long GetSystemDisplayService(ServiceCtx Context) + public long GetSystemDisplayService(ServiceCtx Context) { - MakeObject(Context, new ViISystemDisplayService()); + MakeObject(Context, new ISystemDisplayService()); return 0; } - public static long GetManagerDisplayService(ServiceCtx Context) + public long GetManagerDisplayService(ServiceCtx Context) { - MakeObject(Context, new ViIManagerDisplayService()); + MakeObject(Context, new IManagerDisplayService()); return 0; } - public static long GetIndirectDisplayTransactionService(ServiceCtx Context) + public long GetIndirectDisplayTransactionService(ServiceCtx Context) { - MakeObject(Context, new ViIHOSBinderDriver()); + MakeObject(Context, new IHOSBinderDriver()); return 0; } - public static long OpenDisplay(ServiceCtx Context) + public long OpenDisplay(ServiceCtx Context) { string Name = GetDisplayName(Context); @@ -49,7 +70,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long OpenLayer(ServiceCtx Context) + public long OpenLayer(ServiceCtx Context) { long LayerId = Context.RequestData.ReadInt64(); long UserId = Context.RequestData.ReadInt64(); @@ -65,7 +86,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long CreateStrayLayer(ServiceCtx Context) + public long CreateStrayLayer(ServiceCtx Context) { long LayerFlags = Context.RequestData.ReadInt64(); long DisplayId = Context.RequestData.ReadInt64(); @@ -84,7 +105,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long SetLayerScalingMode(ServiceCtx Context) + public long SetLayerScalingMode(ServiceCtx Context) { int ScalingMode = Context.RequestData.ReadInt32(); long Unknown = Context.RequestData.ReadInt64(); @@ -92,7 +113,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long GetDisplayVSyncEvent(ServiceCtx Context) + public long GetDisplayVSyncEvent(ServiceCtx Context) { string Name = GetDisplayName(Context); @@ -103,7 +124,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - private static byte[] MakeIGraphicsBufferProducer(long BasePtr) + private byte[] MakeIGraphicsBufferProducer(long BasePtr) { long Id = 0x20; long CookiePtr = 0L; @@ -133,7 +154,7 @@ namespace Ryujinx.OsHle.Objects } } - private static string GetDisplayName(ServiceCtx Context) + private string GetDisplayName(ServiceCtx Context) { string Name = string.Empty; diff --git a/Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs b/Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs similarity index 57% rename from Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs rename to Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs index 13393eafc..157d600fb 100644 --- a/Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs +++ b/Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs @@ -9,39 +9,51 @@ using System.Text; using static Ryujinx.OsHle.Objects.Android.Parcel; -namespace Ryujinx.OsHle.Objects +namespace Ryujinx.OsHle.Objects.Vi { - class ViIHOSBinderDriver + class IHOSBinderDriver : IIpcInterface { - private delegate long ServiceProcessRequest(ServiceCtx Context, byte[] ParcelData); + private delegate long ServiceProcessParcel(ServiceCtx Context, byte[] ParcelData); - private static Dictionary<(string, int), ServiceProcessRequest> InterfaceMthd = - new Dictionary<(string, int), ServiceProcessRequest>() - { - { ("android.gui.IGraphicBufferProducer", 0x1), GraphicBufferProducerRequestBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x3), GraphicBufferProducerDequeueBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x7), GraphicBufferProducerQueueBuffer }, - //{ ("android.gui.IGraphicBufferProducer", 0x8), GraphicBufferProducerCancelBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x9), GraphicBufferProducerQuery }, - { ("android.gui.IGraphicBufferProducer", 0xa), GraphicBufferProducerConnect }, - { ("android.gui.IGraphicBufferProducer", 0xe), GraphicBufferPreallocateBuffer }, - }; + private Dictionary m_Commands; + + private Dictionary<(string, int), ServiceProcessParcel> m_Methods; + + public IReadOnlyDictionary Commands => m_Commands; private class BufferObj { } - public IdPoolWithObj BufferSlots { get; private set; } + private IdPoolWithObj BufferSlots; - public byte[] Gbfr; + private byte[] Gbfr; - public ViIHOSBinderDriver() + public IHOSBinderDriver() { + m_Commands = new Dictionary() + { + { 0, TransactParcel }, + { 1, AdjustRefcount }, + { 2, GetNativeHandle } + }; + + m_Methods = new Dictionary<(string, int), ServiceProcessParcel>() + { + { ("android.gui.IGraphicBufferProducer", 0x1), GraphicBufferProducerRequestBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x3), GraphicBufferProducerDequeueBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x7), GraphicBufferProducerQueueBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x8), GraphicBufferProducerCancelBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x9), GraphicBufferProducerQuery }, + { ("android.gui.IGraphicBufferProducer", 0xa), GraphicBufferProducerConnect }, + { ("android.gui.IGraphicBufferProducer", 0xe), GraphicBufferPreallocateBuffer } + }; + BufferSlots = new IdPoolWithObj(); } - public static long TransactParcel(ServiceCtx Context) + public long TransactParcel(ServiceCtx Context) { int Id = Context.RequestData.ReadInt32(); int Code = Context.RequestData.ReadInt32(); @@ -63,7 +75,7 @@ namespace Ryujinx.OsHle.Objects string InterfaceName = Encoding.Unicode.GetString(Data, 8, StrSize * 2); - if (InterfaceMthd.TryGetValue((InterfaceName, Code), out ServiceProcessRequest ProcReq)) + if (m_Methods.TryGetValue((InterfaceName, Code), out ServiceProcessParcel ProcReq)) { return ProcReq(Context, Data); } @@ -74,43 +86,37 @@ namespace Ryujinx.OsHle.Objects } } - private static long GraphicBufferProducerRequestBuffer(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerRequestBuffer(ServiceCtx Context, byte[] ParcelData) { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - - int GbfrSize = BinderDriver.Gbfr?.Length ?? 0; + int GbfrSize = Gbfr?.Length ?? 0; byte[] Data = new byte[GbfrSize + 4]; - if (BinderDriver.Gbfr != null) + if (Gbfr != null) { - Buffer.BlockCopy(BinderDriver.Gbfr, 0, Data, 0, GbfrSize); + Buffer.BlockCopy(Gbfr, 0, Data, 0, GbfrSize); } return MakeReplyParcel(Context, Data); } - private static long GraphicBufferProducerDequeueBuffer(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerDequeueBuffer(ServiceCtx Context, byte[] ParcelData) { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - //Note: It seems that the maximum number of slots is 64, because if we return //a Slot number > 63, it seems to cause a buffer overrun and it reads garbage. //Note 2: The size of each object associated with the slot is 0x30. - int Slot = BinderDriver.BufferSlots.GenerateId(new BufferObj()); + int Slot = BufferSlots.GenerateId(new BufferObj()); return MakeReplyParcel(Context, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } - private static long GraphicBufferProducerQueueBuffer(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerQueueBuffer(ServiceCtx Context, byte[] ParcelData) { return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); } - private static long GraphicBufferProducerCancelBuffer(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerCancelBuffer(ServiceCtx Context, byte[] ParcelData) { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - using (MemoryStream MS = new MemoryStream(ParcelData)) { BinaryReader Reader = new BinaryReader(MS); @@ -119,31 +125,29 @@ namespace Ryujinx.OsHle.Objects int Slot = Reader.ReadInt32(); - BinderDriver.BufferSlots.Delete(Slot); + BufferSlots.Delete(Slot); return MakeReplyParcel(Context, 0); } } - private static long GraphicBufferProducerQuery(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerQuery(ServiceCtx Context, byte[] ParcelData) { return MakeReplyParcel(Context, 0, 0); } - private static long GraphicBufferProducerConnect(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferProducerConnect(ServiceCtx Context, byte[] ParcelData) { return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); } - private static long GraphicBufferPreallocateBuffer(ServiceCtx Context, byte[] ParcelData) + private long GraphicBufferPreallocateBuffer(ServiceCtx Context, byte[] ParcelData) { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - int GbfrSize = ParcelData.Length - 0x54; - BinderDriver.Gbfr = new byte[GbfrSize]; + Gbfr = new byte[GbfrSize]; - Buffer.BlockCopy(ParcelData, 0x54, BinderDriver.Gbfr, 0, GbfrSize); + Buffer.BlockCopy(ParcelData, 0x54, Gbfr, 0, GbfrSize); using (MemoryStream MS = new MemoryStream(ParcelData)) { @@ -161,7 +165,7 @@ namespace Ryujinx.OsHle.Objects return MakeReplyParcel(Context, 0); } - private static long MakeReplyParcel(ServiceCtx Context, params int[] Ints) + private long MakeReplyParcel(ServiceCtx Context, params int[] Ints) { using (MemoryStream MS = new MemoryStream()) { @@ -176,7 +180,7 @@ namespace Ryujinx.OsHle.Objects } } - private static long MakeReplyParcel(ServiceCtx Context, byte[] Data) + private long MakeReplyParcel(ServiceCtx Context, byte[] Data) { long ReplyPos = Context.Request.ReceiveBuff[0].Position; long ReplySize = Context.Request.ReceiveBuff[0].Position; @@ -188,7 +192,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long AdjustRefcount(ServiceCtx Context) + public long AdjustRefcount(ServiceCtx Context) { int Id = Context.RequestData.ReadInt32(); int AddVal = Context.RequestData.ReadInt32(); @@ -197,7 +201,7 @@ namespace Ryujinx.OsHle.Objects return 0; } - public static long GetNativeHandle(ServiceCtx Context) + public long GetNativeHandle(ServiceCtx Context) { int Id = Context.RequestData.ReadInt32(); uint Unk = Context.RequestData.ReadUInt32(); diff --git a/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs new file mode 100644 index 000000000..c2bbf43b2 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class IManagerDisplayService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IManagerDisplayService() + { + m_Commands = new Dictionary() + { + { 2010, CreateManagedLayer }, + { 6000, AddToLayerStack } + }; + } + + public static long CreateManagedLayer(ServiceCtx Context) + { + Context.ResponseData.Write(0L); //LayerId + + return 0; + } + + public static long AddToLayerStack(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs new file mode 100644 index 000000000..39d197864 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs @@ -0,0 +1,25 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class ISystemDisplayService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISystemDisplayService() + { + m_Commands = new Dictionary() + { + { 2205, SetLayerZ } + }; + } + + public static long SetLayerZ(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs b/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs deleted file mode 100644 index 0fdca3bac..000000000 --- a/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ViIManagerDisplayService - { - public static long CreateManagedLayer(ServiceCtx Context) - { - Context.ResponseData.Write(0L); //LayerId - - return 0; - } - - public static long AddToLayerStack(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs b/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs deleted file mode 100644 index 8d3a51f4e..000000000 --- a/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ViISystemDisplayService - { - public static long SetLayerZ(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Process.cs b/Ryujinx/OsHle/Process.cs index b723b165c..668238468 100644 --- a/Ryujinx/OsHle/Process.cs +++ b/Ryujinx/OsHle/Process.cs @@ -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,19 +137,31 @@ namespace Ryujinx.OsHle return -1; } - Thread.Registers.SvcCall += SvcHandler.SvcCall; - Thread.Registers.ProcessId = ProcessId; - Thread.Registers.ThreadId = Ns.Os.IdGen.GenerateId(); - Thread.Registers.Tpidr = TlsPageAddr + TlsSlot * TlsSize; - Thread.Registers.X0 = (ulong)ArgsPtr; - Thread.Registers.X1 = (ulong)Handle; - Thread.Registers.X31 = (ulong)StackTop; + Thread.Registers.Break += BreakHandler; + Thread.Registers.SvcCall += SvcHandler.SvcCall; + Thread.Registers.Undefined += UndefinedHandler; + Thread.Registers.ProcessId = ProcessId; + Thread.Registers.ThreadId = Ns.Os.IdGen.GenerateId(); + Thread.Registers.Tpidr = TlsPageAddr + TlsSlot * TlsSize; + Thread.Registers.X0 = (ulong)ArgsPtr; + Thread.Registers.X1 = (ulong)Handle; + Thread.Registers.X31 = (ulong)StackTop; Thread.WorkFinished += ThreadFinished; return Handle; } + private void BreakHandler(object sender, AInstExceptEventArgs e) + { + throw new GuestBrokeExecutionException(); + } + + private void UndefinedHandler(object sender, AInstUndEventArgs e) + { + throw new UndefinedInstructionException(e.Position, e.RawOpCode); + } + private int GetFreeTlsSlot(AThread Thread) { for (int Index = 1; Index < TotalTlsSlots; Index++) diff --git a/Ryujinx/OsHle/ServiceCtx.cs b/Ryujinx/OsHle/ServiceCtx.cs index 88ddcdb77..501d8d0f0 100644 --- a/Ryujinx/OsHle/ServiceCtx.cs +++ b/Ryujinx/OsHle/ServiceCtx.cs @@ -7,7 +7,7 @@ namespace Ryujinx.OsHle { class ServiceCtx { - public Switch Ns { get; private set; } + public Switch Ns { get; private set; } public AMemory Memory { get; private set; } public HSession Session { get; private set; } public IpcMessage Request { get; private set; } @@ -32,21 +32,5 @@ namespace Ryujinx.OsHle this.RequestData = RequestData; this.ResponseData = ResponseData; } - - public T GetObject() - { - object Obj = null; - - if (Session is HSessionObj SessionObj) - { - Obj = SessionObj.Obj; - } - if (Session is HDomain Dom) - { - Obj = Dom.GetObject(Request.DomObjId); - } - - return Obj is T ? (T)Obj : default(T); - } } } \ No newline at end of file diff --git a/Ryujinx/OsHle/Services/ServiceAcc.cs b/Ryujinx/OsHle/Services/ServiceAcc.cs index 14a3e83ea..632fb41c2 100644 --- a/Ryujinx/OsHle/Services/ServiceAcc.cs +++ b/Ryujinx/OsHle/Services/ServiceAcc.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Acc; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -13,7 +13,7 @@ namespace Ryujinx.OsHle.Services public static long AccU0GetProfile(ServiceCtx Context) { - MakeObject(Context, new AccIProfile()); + MakeObject(Context, new IProfile()); return 0; } @@ -25,7 +25,7 @@ namespace Ryujinx.OsHle.Services public static long AccU0GetBaasAccountManagerForApplication(ServiceCtx Context) { - MakeObject(Context, new AccIManagerForApplication()); + MakeObject(Context, new IManagerForApplication()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceApm.cs b/Ryujinx/OsHle/Services/ServiceApm.cs index f0df462b7..81e68680a 100644 --- a/Ryujinx/OsHle/Services/ServiceApm.cs +++ b/Ryujinx/OsHle/Services/ServiceApm.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Apm; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long ApmOpenSession(ServiceCtx Context) { - MakeObject(Context, new ApmISession()); + MakeObject(Context, new ISession()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceAppletOE.cs b/Ryujinx/OsHle/Services/ServiceAppletOE.cs index 2f98a2014..9f2391df7 100644 --- a/Ryujinx/OsHle/Services/ServiceAppletOE.cs +++ b/Ryujinx/OsHle/Services/ServiceAppletOE.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Am; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long AppletOpenApplicationProxy(ServiceCtx Context) { - MakeObject(Context, new AmIApplicationProxy()); + MakeObject(Context, new IApplicationProxy()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceAud.cs b/Ryujinx/OsHle/Services/ServiceAud.cs index 18401ae95..6d1367cf1 100644 --- a/Ryujinx/OsHle/Services/ServiceAud.cs +++ b/Ryujinx/OsHle/Services/ServiceAud.cs @@ -1,5 +1,5 @@ using ChocolArm64.Memory; -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Aud; using System.Text; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -21,7 +21,7 @@ namespace Ryujinx.OsHle.Services public static long AudOutOpenAudioOut(ServiceCtx Context) { - MakeObject(Context, new AudIAudioOut()); + MakeObject(Context, new IAudioOut()); Context.ResponseData.Write(48000); //Sample Rate Context.ResponseData.Write(2); //Channel Count @@ -42,7 +42,7 @@ namespace Ryujinx.OsHle.Services public static long AudRenOpenAudioRenderer(ServiceCtx Context) { - MakeObject(Context, new AudIAudioRenderer()); + MakeObject(Context, new IAudioRenderer()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceFriend.cs b/Ryujinx/OsHle/Services/ServiceFriend.cs index 980d42196..10c23aaea 100644 --- a/Ryujinx/OsHle/Services/ServiceFriend.cs +++ b/Ryujinx/OsHle/Services/ServiceFriend.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Friend; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long FriendCreateFriendService(ServiceCtx Context) { - MakeObject(Context, new FriendIFriendService()); + MakeObject(Context, new IFriendService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceFspSrv.cs b/Ryujinx/OsHle/Services/ServiceFspSrv.cs index 7f431f267..17aa3bda7 100644 --- a/Ryujinx/OsHle/Services/ServiceFspSrv.cs +++ b/Ryujinx/OsHle/Services/ServiceFspSrv.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.FspSrv; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -13,28 +13,28 @@ namespace Ryujinx.OsHle.Services public static long FspSrvMountSdCard(ServiceCtx Context) { - MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetSdCardPath())); + MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetSdCardPath())); return 0; } public static long FspSrvMountSaveData(ServiceCtx Context) { - MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetGameSavesPath())); + MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetGameSavesPath())); return 0; } public static long FspSrvOpenDataStorageByCurrentProcess(ServiceCtx Context) { - MakeObject(Context, new FspSrvIStorage(Context.Ns.VFs.RomFs)); + MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs)); return 0; } public static long FspSrvOpenRomStorage(ServiceCtx Context) { - MakeObject(Context, new FspSrvIStorage(Context.Ns.VFs.RomFs)); + MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs)); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceHid.cs b/Ryujinx/OsHle/Services/ServiceHid.cs index 30093f49f..176c7842c 100644 --- a/Ryujinx/OsHle/Services/ServiceHid.cs +++ b/Ryujinx/OsHle/Services/ServiceHid.cs @@ -1,5 +1,5 @@ using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Hid; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -11,7 +11,7 @@ namespace Ryujinx.OsHle.Services { HSharedMem HidHndData = Context.Ns.Os.Handles.GetData(Context.Ns.Os.HidHandle); - MakeObject(Context, new HidIAppletResource(HidHndData)); + MakeObject(Context, new IAppletResource(HidHndData)); return 0; } diff --git a/Ryujinx/OsHle/Services/ServicePctl.cs b/Ryujinx/OsHle/Services/ServicePctl.cs index 62537f287..a0a5aaf3f 100644 --- a/Ryujinx/OsHle/Services/ServicePctl.cs +++ b/Ryujinx/OsHle/Services/ServicePctl.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Am; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long PctlCreateService(ServiceCtx Context) { - MakeObject(Context, new AmIParentalControlService()); + MakeObject(Context, new IParentalControlService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceTime.cs b/Ryujinx/OsHle/Services/ServiceTime.cs index 2b93e3db8..4f8e34e97 100644 --- a/Ryujinx/OsHle/Services/ServiceTime.cs +++ b/Ryujinx/OsHle/Services/ServiceTime.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Time; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,28 +8,28 @@ namespace Ryujinx.OsHle.Services { public static long TimeGetStandardUserSystemClock(ServiceCtx Context) { - MakeObject(Context, new TimeISystemClock()); + MakeObject(Context, new ISystemClock()); return 0; } public static long TimeGetStandardNetworkSystemClock(ServiceCtx Context) { - MakeObject(Context, new TimeISystemClock()); + MakeObject(Context, new ISystemClock()); return 0; } public static long TimeGetStandardSteadyClock(ServiceCtx Context) { - MakeObject(Context, new TimeISteadyClock()); + MakeObject(Context, new ISteadyClock()); return 0; } public static long TimeGetTimeZoneService(ServiceCtx Context) { - MakeObject(Context, new TimeITimeZoneService()); + MakeObject(Context, new ITimeZoneService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceVi.cs b/Ryujinx/OsHle/Services/ServiceVi.cs index d5c86bfc2..096bc18f0 100644 --- a/Ryujinx/OsHle/Services/ServiceVi.cs +++ b/Ryujinx/OsHle/Services/ServiceVi.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Vi; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -10,7 +10,7 @@ namespace Ryujinx.OsHle.Services { int Unknown = Context.RequestData.ReadInt32(); - MakeObject(Context, new ViIApplicationDisplayService()); + MakeObject(Context, new IApplicationDisplayService()); return 0; } diff --git a/Ryujinx/OsHle/Svc/SvcHandler.cs b/Ryujinx/OsHle/Svc/SvcHandler.cs index 9aea2dedb..44bd88ee6 100644 --- a/Ryujinx/OsHle/Svc/SvcHandler.cs +++ b/Ryujinx/OsHle/Svc/SvcHandler.cs @@ -63,7 +63,7 @@ namespace Ryujinx.OsHle.Svc Rng = new Random(); } - public void SvcCall(object sender, SvcEventArgs e) + public void SvcCall(object sender, AInstExceptEventArgs 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")); } } } diff --git a/Ryujinx/OsHle/Svc/SvcMemory.cs b/Ryujinx/OsHle/Svc/SvcMemory.cs index 70988eb0b..185cac892 100644 --- a/Ryujinx/OsHle/Svc/SvcMemory.cs +++ b/Ryujinx/OsHle/Svc/SvcMemory.cs @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Svc { private static void SvcSetHeapSize(Switch Ns, ARegisters Registers, AMemory Memory) { - int Size = (int)Registers.X1; + uint Size = (uint)Registers.X1; Memory.Manager.SetHeapSize(Size, (int)MemoryType.Heap); @@ -30,8 +30,8 @@ namespace Ryujinx.OsHle.Svc private static void SvcMapMemory(Switch Ns, ARegisters Registers, AMemory Memory) { - long Src = (long)Registers.X0; - long Dst = (long)Registers.X1; + long Dst = (long)Registers.X0; + long Src = (long)Registers.X1; long Size = (long)Registers.X2; Memory.Manager.MapMirror(Src, Dst, Size, (int)MemoryType.MappedMemory); @@ -79,11 +79,9 @@ namespace Ryujinx.OsHle.Svc HndData.VirtPos = Src; - if (Memory.Manager.MapPhys(Src, Dst, Size, - (int)MemoryType.SharedMemory, (AMemoryPerm)Perm)) - { - Registers.X0 = (int)SvcResult.Success; - } + Memory.Manager.MapPhys(Position, Size, (int)MemoryType.SharedMemory, (AMemoryPerm)Perm); + + Registers.X0 = (int)SvcResult.Success; } //TODO: Error codes. diff --git a/Ryujinx/OsHle/Svc/SvcSystem.cs b/Ryujinx/OsHle/Svc/SvcSystem.cs index 3c541381b..5721c53b8 100644 --- a/Ryujinx/OsHle/Svc/SvcSystem.cs +++ b/Ryujinx/OsHle/Svc/SvcSystem.cs @@ -93,7 +93,7 @@ namespace Ryujinx.OsHle.Svc if (Session != null) { - IpcHandler.ProcessRequest(Ns, Memory, Session, Cmd, CmdPtr, Handle); + IpcHandler.IpcCall(Ns, Memory, Session, Cmd, CmdPtr, Handle); byte[] Response = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);