コード例 #1
0
        private static int Submit(ServiceCtx context)
        {
            long inputPosition  = context.Request.GetBufferType0x21().Position;
            long outputPosition = context.Request.GetBufferType0x22().Position;

            NvHostChannelSubmit args = MemoryHelper.Read <NvHostChannelSubmit>(context.Memory, inputPosition);

            NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;

            for (int index = 0; index < args.CmdBufsCount; index++)
            {
                long cmdBufOffset = inputPosition + 0x10 + index * 0xc;

                NvHostChannelCmdBuf cmdBuf = MemoryHelper.Read <NvHostChannelCmdBuf>(context.Memory, cmdBufOffset);

                NvMapHandle map = NvMapIoctl.GetNvMap(context, cmdBuf.MemoryId);

                int[] cmdBufData = new int[cmdBuf.WordsCount];

                for (int offset = 0; offset < cmdBufData.Length; offset++)
                {
                    cmdBufData[offset] = context.Memory.ReadInt32(map.Address + cmdBuf.Offset + offset * 4);
                }

                context.Device.Gpu.PushCommandBuffer(vmm, cmdBufData);
            }

            // TODO: Relocation, waitchecks, etc.

            return(NvResult.Success);
        }
コード例 #2
0
        private static int UnmapBuffer(ServiceCtx context)
        {
            long inputPosition = context.Request.GetBufferType0x21().Position;

            NvHostChannelMapBuffer args = MemoryHelper.Read <NvHostChannelMapBuffer>(context.Memory, inputPosition);

            NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;

            for (int index = 0; index < args.NumEntries; index++)
            {
                int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8);

                NvMapHandle map = NvMapIoctl.GetNvMap(context, handle);

                if (map == null)
                {
                    Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!");

                    return(NvResult.InvalidInput);
                }

                lock (map)
                {
                    if (map.DmaMapAddress != 0)
                    {
                        vmm.Free(map.DmaMapAddress, map.Size);

                        map.DmaMapAddress = 0;
                    }
                }
            }

            return(NvResult.Success);
        }
コード例 #3
0
        private static int SubmitGpfifo(ServiceCtx Context)
        {
            long InputPosition  = Context.Request.GetBufferType0x21Position();
            long OutputPosition = Context.Request.GetBufferType0x22Position();

            NvHostChannelSubmitGpfifo Args = AMemoryHelper.Read <NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);

            NvGpuVmm Vmm = NvGpuASIoctl.GetVmm(Context);

            for (int Index = 0; Index < Args.NumEntries; Index++)
            {
                long Gpfifo = Context.Memory.ReadInt64(InputPosition + 0x18 + Index * 8);

                long VA = Gpfifo & 0xff_ffff_ffff;

                int Size = (int)(Gpfifo >> 40) & 0x7ffffc;

                byte[] Data = Vmm.ReadBytes(VA, Size);

                NvGpuPBEntry[] PushBuffer = NvGpuPushBuffer.Decode(Data);

                Context.Ns.Gpu.Fifo.PushBuffer(Vmm, PushBuffer);
            }

            Args.SyncptId    = 0;
            Args.SyncptValue = 0;

            AMemoryHelper.Write(Context.Memory, OutputPosition, Args);

            return(NvResult.Success);
        }
コード例 #4
0
        private static int Submit(ServiceCtx Context)
        {
            long InputPosition  = Context.Request.GetBufferType0x21().Position;
            long OutputPosition = Context.Request.GetBufferType0x22().Position;

            NvHostChannelSubmit Args = MemoryHelper.Read <NvHostChannelSubmit>(Context.Memory, InputPosition);

            NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;

            for (int Index = 0; Index < Args.CmdBufsCount; Index++)
            {
                long CmdBufOffset = InputPosition + 0x10 + Index * 0xc;

                NvHostChannelCmdBuf CmdBuf = MemoryHelper.Read <NvHostChannelCmdBuf>(Context.Memory, CmdBufOffset);

                NvMapHandle Map = NvMapIoctl.GetNvMap(Context, CmdBuf.MemoryId);

                int[] CmdBufData = new int[CmdBuf.WordsCount];

                for (int Offset = 0; Offset < CmdBufData.Length; Offset++)
                {
                    CmdBufData[Offset] = Context.Memory.ReadInt32(Map.Address + CmdBuf.Offset + Offset * 4);
                }

                Context.Device.Gpu.PushCommandBuffer(Vmm, CmdBufData);
            }

            //TODO: Relocation, waitchecks, etc.

            return(NvResult.Success);
        }
コード例 #5
0
        private static int UnmapBuffer(ServiceCtx Context)
        {
            long InputPosition = Context.Request.GetBufferType0x21().Position;

            NvHostChannelMapBuffer Args = MemoryHelper.Read <NvHostChannelMapBuffer>(Context.Memory, InputPosition);

            NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;

            for (int Index = 0; Index < Args.NumEntries; Index++)
            {
                int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8);

                NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle);

                if (Map == null)
                {
                    Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!");

                    return(NvResult.InvalidInput);
                }

                lock (Map)
                {
                    if (Map.DmaMapAddress != 0)
                    {
                        Vmm.Free(Map.DmaMapAddress, Map.Size);

                        Map.DmaMapAddress = 0;
                    }
                }
            }

            return(NvResult.Success);
        }
コード例 #6
0
        public static void UnloadProcess(Process Process)
        {
            Fds.DeleteProcess(Process);

            NvGpuASIoctl.UnloadProcess(Process);

            NvHostCtrlIoctl.UnloadProcess(Process);

            NvMapIoctl.UnloadProcess(Process);
        }
コード例 #7
0
ファイル: INvDrvServices.cs プロジェクト: woxihuanjia/Ryujinx
        public static void UnloadProcess(KProcess process)
        {
            Fds.DeleteProcess(process);

            NvGpuASIoctl.UnloadProcess(process);

            NvHostChannelIoctl.UnloadProcess(process);

            NvHostCtrlIoctl.UnloadProcess(process);

            NvMapIoctl.UnloadProcess(process);
        }
コード例 #8
0
        private static int KickoffPbWithAttr(ServiceCtx context)
        {
            long inputPosition  = context.Request.GetBufferType0x21().Position;
            long outputPosition = context.Request.GetBufferType0x22().Position;

            NvHostChannelSubmitGpfifo args = MemoryHelper.Read <NvHostChannelSubmitGpfifo>(context.Memory, inputPosition);

            NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;

            for (int index = 0; index < args.NumEntries; index++)
            {
                long gpfifo = context.Memory.ReadInt64(args.Address + index * 8);

                PushGpfifo(context, vmm, gpfifo);
            }

            args.SyncptId    = 0;
            args.SyncptValue = 0;

            MemoryHelper.Write(context.Memory, outputPosition, args);

            return(NvResult.Success);
        }
コード例 #9
0
        private static int SubmitGpfifo(ServiceCtx Context)
        {
            long InputPosition  = Context.Request.GetBufferType0x21().Position;
            long OutputPosition = Context.Request.GetBufferType0x22().Position;

            NvHostChannelSubmitGpfifo Args = MemoryHelper.Read <NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);

            NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;;

            for (int Index = 0; Index < Args.NumEntries; Index++)
            {
                long Gpfifo = Context.Memory.ReadInt64(InputPosition + 0x18 + Index * 8);

                PushGpfifo(Context, Vmm, Gpfifo);
            }

            Args.SyncptId    = 0;
            Args.SyncptValue = 0;

            MemoryHelper.Write(Context.Memory, OutputPosition, Args);

            return(NvResult.Success);
        }