08831eecf7
* IPC refactor part 3 + 4: New server HIPC message processor with source generator based serialization * Make types match on calls to AlignUp/AlignDown * Formatting * Address some PR feedback * Move BitfieldExtensions to Ryujinx.Common.Utilities and consolidate implementations * Rename Reader/Writer to SpanReader/SpanWriter and move to Ryujinx.Common.Memory * Implement EventType * Address more PR feedback * Log request processing errors since they are not normal * Rename waitable to multiwait and add missing lock * PR feedback * Ac_K PR feedback
128 lines
4.7 KiB
C#
128 lines
4.7 KiB
C#
using Ryujinx.Common.Logging;
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.Horizon.Common;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.BluetoothManager.BtmUser
|
|
{
|
|
class IBtmUserCore : IpcService
|
|
{
|
|
public KEvent _bleScanEvent;
|
|
public int _bleScanEventHandle;
|
|
|
|
public KEvent _bleConnectionEvent;
|
|
public int _bleConnectionEventHandle;
|
|
|
|
public KEvent _bleServiceDiscoveryEvent;
|
|
public int _bleServiceDiscoveryEventHandle;
|
|
|
|
public KEvent _bleMtuConfigEvent;
|
|
public int _bleMtuConfigEventHandle;
|
|
|
|
public IBtmUserCore() { }
|
|
|
|
[CommandHipc(0)] // 5.0.0+
|
|
// AcquireBleScanEvent() -> (byte<1>, handle<copy>)
|
|
public ResultCode AcquireBleScanEvent(ServiceCtx context)
|
|
{
|
|
Result result = Result.Success;
|
|
|
|
if (_bleScanEventHandle == 0)
|
|
{
|
|
_bleScanEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
result = context.Process.HandleTable.GenerateHandle(_bleScanEvent.ReadableEvent, out _bleScanEventHandle);
|
|
|
|
if (result != Result.Success)
|
|
{
|
|
// NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
|
|
Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
|
|
}
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleScanEventHandle);
|
|
|
|
context.ResponseData.Write(result == Result.Success ? 1 : 0);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandHipc(17)] // 5.0.0+
|
|
// AcquireBleConnectionEvent() -> (byte<1>, handle<copy>)
|
|
public ResultCode AcquireBleConnectionEvent(ServiceCtx context)
|
|
{
|
|
Result result = Result.Success;
|
|
|
|
if (_bleConnectionEventHandle == 0)
|
|
{
|
|
_bleConnectionEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
result = context.Process.HandleTable.GenerateHandle(_bleConnectionEvent.ReadableEvent, out _bleConnectionEventHandle);
|
|
|
|
if (result != Result.Success)
|
|
{
|
|
// NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
|
|
Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
|
|
}
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleConnectionEventHandle);
|
|
|
|
context.ResponseData.Write(result == Result.Success ? 1 : 0);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandHipc(26)] // 5.0.0+
|
|
// AcquireBleServiceDiscoveryEvent() -> (byte<1>, handle<copy>)
|
|
public ResultCode AcquireBleServiceDiscoveryEvent(ServiceCtx context)
|
|
{
|
|
Result result = Result.Success;
|
|
|
|
if (_bleServiceDiscoveryEventHandle == 0)
|
|
{
|
|
_bleServiceDiscoveryEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
result = context.Process.HandleTable.GenerateHandle(_bleServiceDiscoveryEvent.ReadableEvent, out _bleServiceDiscoveryEventHandle);
|
|
|
|
if (result != Result.Success)
|
|
{
|
|
// NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
|
|
Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
|
|
}
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleServiceDiscoveryEventHandle);
|
|
|
|
context.ResponseData.Write(result == Result.Success ? 1 : 0);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[CommandHipc(33)] // 5.0.0+
|
|
// AcquireBleMtuConfigEvent() -> (byte<1>, handle<copy>)
|
|
public ResultCode AcquireBleMtuConfigEvent(ServiceCtx context)
|
|
{
|
|
Result result = Result.Success;
|
|
|
|
if (_bleMtuConfigEventHandle == 0)
|
|
{
|
|
_bleMtuConfigEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
result = context.Process.HandleTable.GenerateHandle(_bleMtuConfigEvent.ReadableEvent, out _bleMtuConfigEventHandle);
|
|
|
|
if (result != Result.Success)
|
|
{
|
|
// NOTE: We use a Logging instead of an exception because the call return a boolean if succeed or not.
|
|
Logger.Error?.Print(LogClass.ServiceBsd, "Out of handles!");
|
|
}
|
|
}
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_bleMtuConfigEventHandle);
|
|
|
|
context.ResponseData.Write(result == Result.Success ? 1 : 0);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
}
|
|
} |