2022-08-18 09:04:54 -07:00
|
|
|
|
using Ryujinx.Common.Logging;
|
2020-12-11 19:06:20 -08:00
|
|
|
|
using Ryujinx.Cpu;
|
2020-02-05 20:09:59 -08:00
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types;
|
2023-01-04 14:15:45 -08:00
|
|
|
|
using Ryujinx.Horizon.Common;
|
2020-02-05 20:09:59 -08:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
|
|
|
|
{
|
|
|
|
|
class IDeliveryCacheProgressService : IpcService
|
|
|
|
|
{
|
|
|
|
|
private KEvent _event;
|
2020-12-01 15:23:43 -08:00
|
|
|
|
private int _eventHandle;
|
2020-02-05 20:09:59 -08:00
|
|
|
|
|
|
|
|
|
public IDeliveryCacheProgressService(ServiceCtx context)
|
|
|
|
|
{
|
2020-05-03 20:41:29 -07:00
|
|
|
|
_event = new KEvent(context.Device.System.KernelContext);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 15:01:24 -07:00
|
|
|
|
[CommandHipc(0)]
|
2020-02-05 20:09:59 -08:00
|
|
|
|
// GetEvent() -> handle<copy>
|
|
|
|
|
public ResultCode GetEvent(ServiceCtx context)
|
|
|
|
|
{
|
2020-12-01 15:23:43 -08:00
|
|
|
|
if (_eventHandle == 0)
|
2020-02-05 20:09:59 -08:00
|
|
|
|
{
|
2023-01-04 14:15:45 -08:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out _eventHandle) != Result.Success)
|
2020-12-01 15:23:43 -08:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
2020-02-05 20:09:59 -08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-01 15:23:43 -08:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_eventHandle);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
|
2020-08-03 16:32:53 -07:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 15:01:24 -07:00
|
|
|
|
[CommandHipc(1)]
|
2020-02-05 20:09:59 -08:00
|
|
|
|
// GetImpl() -> buffer<nn::bcat::detail::DeliveryCacheProgressImpl, 0x1a>
|
|
|
|
|
public ResultCode GetImpl(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
DeliveryCacheProgressImpl deliveryCacheProgress = new DeliveryCacheProgressImpl
|
|
|
|
|
{
|
|
|
|
|
State = DeliveryCacheProgressImpl.Status.Done,
|
|
|
|
|
Result = 0
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-24 03:16:01 -07:00
|
|
|
|
ulong dcpSize = WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
|
2020-12-11 19:06:20 -08:00
|
|
|
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(dcpSize);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
|
2020-08-03 16:32:53 -07:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-24 03:16:01 -07:00
|
|
|
|
private ulong WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
|
2020-02-05 20:09:59 -08:00
|
|
|
|
{
|
2020-12-11 19:06:20 -08:00
|
|
|
|
return MemoryHelper.Write(context.Memory, ipcDesc.Position, deliveryCacheProgress);
|
2020-02-05 20:09:59 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|