Esempio n. 1
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);
        }
Esempio n. 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);
        }