btdrv.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/logging/log.h"
  5. #include "core/core.h"
  6. #include "core/hle/ipc_helpers.h"
  7. #include "core/hle/kernel/hle_ipc.h"
  8. #include "core/hle/kernel/k_event.h"
  9. #include "core/hle/kernel/k_readable_event.h"
  10. #include "core/hle/kernel/kernel.h"
  11. #include "core/hle/service/btdrv/btdrv.h"
  12. #include "core/hle/service/service.h"
  13. #include "core/hle/service/sm/sm.h"
  14. namespace Service::BtDrv {
  15. class Bt final : public ServiceFramework<Bt> {
  16. public:
  17. explicit Bt(Core::System& system_) : ServiceFramework{system_, "bt"} {
  18. // clang-format off
  19. static const FunctionInfo functions[] = {
  20. {0, nullptr, "LeClientReadCharacteristic"},
  21. {1, nullptr, "LeClientReadDescriptor"},
  22. {2, nullptr, "LeClientWriteCharacteristic"},
  23. {3, nullptr, "LeClientWriteDescriptor"},
  24. {4, nullptr, "LeClientRegisterNotification"},
  25. {5, nullptr, "LeClientDeregisterNotification"},
  26. {6, nullptr, "SetLeResponse"},
  27. {7, nullptr, "LeSendIndication"},
  28. {8, nullptr, "GetLeEventInfo"},
  29. {9, &Bt::RegisterBleEvent, "RegisterBleEvent"},
  30. };
  31. // clang-format on
  32. RegisterHandlers(functions);
  33. auto& kernel = system.Kernel();
  34. register_event = Kernel::KEvent::Create(kernel, "BT:RegisterEvent");
  35. register_event->Initialize();
  36. }
  37. private:
  38. void RegisterBleEvent(Kernel::HLERequestContext& ctx) {
  39. LOG_WARNING(Service_BTM, "(STUBBED) called");
  40. IPC::ResponseBuilder rb{ctx, 2, 1};
  41. rb.Push(RESULT_SUCCESS);
  42. rb.PushCopyObjects(register_event->GetReadableEvent());
  43. }
  44. std::shared_ptr<Kernel::KEvent> register_event;
  45. };
  46. class BtDrv final : public ServiceFramework<BtDrv> {
  47. public:
  48. explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
  49. // clang-format off
  50. static const FunctionInfo functions[] = {
  51. {0, nullptr, "InitializeBluetoothDriver"},
  52. {1, nullptr, "InitializeBluetooth"},
  53. {2, nullptr, "EnableBluetooth"},
  54. {3, nullptr, "DisableBluetooth"},
  55. {4, nullptr, "FinalizeBluetooth"},
  56. {5, nullptr, "GetAdapterProperties"},
  57. {6, nullptr, "GetAdapterProperty"},
  58. {7, nullptr, "SetAdapterProperty"},
  59. {8, nullptr, "StartInquiry"},
  60. {9, nullptr, "StopInquiry"},
  61. {10, nullptr, "CreateBond"},
  62. {11, nullptr, "RemoveBond"},
  63. {12, nullptr, "CancelBond"},
  64. {13, nullptr, "RespondToPinRequest"},
  65. {14, nullptr, "RespondToSspRequest"},
  66. {15, nullptr, "GetEventInfo"},
  67. {16, nullptr, "InitializeHid"},
  68. {17, nullptr, "OpenHidConnection"},
  69. {18, nullptr, "CloseHidConnection"},
  70. {19, nullptr, "WriteHidData"},
  71. {20, nullptr, "WriteHidData2"},
  72. {21, nullptr, "SetHidReport"},
  73. {22, nullptr, "GetHidReport"},
  74. {23, nullptr, "TriggerConnection"},
  75. {24, nullptr, "AddPairedDeviceInfo"},
  76. {25, nullptr, "GetPairedDeviceInfo"},
  77. {26, nullptr, "FinalizeHid"},
  78. {27, nullptr, "GetHidEventInfo"},
  79. {28, nullptr, "SetTsi"},
  80. {29, nullptr, "EnableBurstMode"},
  81. {30, nullptr, "SetZeroRetransmission"},
  82. {31, nullptr, "EnableMcMode"},
  83. {32, nullptr, "EnableLlrScan"},
  84. {33, nullptr, "DisableLlrScan"},
  85. {34, nullptr, "EnableRadio"},
  86. {35, nullptr, "SetVisibility"},
  87. {36, nullptr, "EnableTbfcScan"},
  88. {37, nullptr, "RegisterHidReportEvent"},
  89. {38, nullptr, "GetHidReportEventInfo"},
  90. {39, nullptr, "GetLatestPlr"},
  91. {40, nullptr, "GetPendingConnections"},
  92. {41, nullptr, "GetChannelMap"},
  93. {42, nullptr, "EnableTxPowerBoostSetting"},
  94. {43, nullptr, "IsTxPowerBoostSettingEnabled"},
  95. {44, nullptr, "EnableAfhSetting"},
  96. {45, nullptr, "IsAfhSettingEnabled"},
  97. {46, nullptr, "InitializeBle"},
  98. {47, nullptr, "EnableBle"},
  99. {48, nullptr, "DisableBle"},
  100. {49, nullptr, "FinalizeBle"},
  101. {50, nullptr, "SetBleVisibility"},
  102. {51, nullptr, "SetBleConnectionParameter"},
  103. {52, nullptr, "SetBleDefaultConnectionParameter"},
  104. {53, nullptr, "SetBleAdvertiseData"},
  105. {54, nullptr, "SetBleAdvertiseParameter"},
  106. {55, nullptr, "StartBleScan"},
  107. {56, nullptr, "StopBleScan"},
  108. {57, nullptr, "AddBleScanFilterCondition"},
  109. {58, nullptr, "DeleteBleScanFilterCondition"},
  110. {59, nullptr, "DeleteBleScanFilter"},
  111. {60, nullptr, "ClearBleScanFilters"},
  112. {61, nullptr, "EnableBleScanFilter"},
  113. {62, nullptr, "RegisterGattClient"},
  114. {63, nullptr, "UnregisterGattClient"},
  115. {64, nullptr, "UnregisterAllGattClients"},
  116. {65, nullptr, "ConnectGattServer"},
  117. {66, nullptr, "CancelConnectGattServer"},
  118. {67, nullptr, "DisconnectGattServer"},
  119. {68, nullptr, "GetGattAttribute"},
  120. {69, nullptr, "GetGattService"},
  121. {70, nullptr, "ConfigureAttMtu"},
  122. {71, nullptr, "RegisterGattServer"},
  123. {72, nullptr, "UnregisterGattServer"},
  124. {73, nullptr, "ConnectGattClient"},
  125. {74, nullptr, "DisconnectGattClient"},
  126. {75, nullptr, "AddGattService"},
  127. {76, nullptr, "EnableGattService"},
  128. {77, nullptr, "AddGattCharacteristic"},
  129. {78, nullptr, "AddGattDescriptor"},
  130. {79, nullptr, "GetBleManagedEventInfo"},
  131. {80, nullptr, "GetGattFirstCharacteristic"},
  132. {81, nullptr, "GetGattNextCharacteristic"},
  133. {82, nullptr, "GetGattFirstDescriptor"},
  134. {83, nullptr, "GetGattNextDescriptor"},
  135. {84, nullptr, "RegisterGattManagedDataPath"},
  136. {85, nullptr, "UnregisterGattManagedDataPath"},
  137. {86, nullptr, "RegisterGattHidDataPath"},
  138. {87, nullptr, "UnregisterGattHidDataPath"},
  139. {88, nullptr, "RegisterGattDataPath"},
  140. {89, nullptr, "UnregisterGattDataPath"},
  141. {90, nullptr, "ReadGattCharacteristic"},
  142. {91, nullptr, "ReadGattDescriptor"},
  143. {92, nullptr, "WriteGattCharacteristic"},
  144. {93, nullptr, "WriteGattDescriptor"},
  145. {94, nullptr, "RegisterGattNotification"},
  146. {95, nullptr, "UnregisterGattNotification"},
  147. {96, nullptr, "GetLeHidEventInfo"},
  148. {97, nullptr, "RegisterBleHidEvent"},
  149. {98, nullptr, "SetBleScanParameter"},
  150. {99, nullptr, "MoveToSecondaryPiconet"},
  151. {100, nullptr, "IsBluetoothEnabled"},
  152. {128, nullptr, "AcquireAudioEvent"},
  153. {129, nullptr, "GetAudioEventInfo"},
  154. {130, nullptr, "OpenAudioConnection"},
  155. {131, nullptr, "CloseAudioConnection"},
  156. {132, nullptr, "OpenAudioOut"},
  157. {133, nullptr, "CloseAudioOut"},
  158. {134, nullptr, "AcquireAudioOutStateChangedEvent"},
  159. {135, nullptr, "StartAudioOut"},
  160. {136, nullptr, "StopAudioOut"},
  161. {137, nullptr, "GetAudioOutState"},
  162. {138, nullptr, "GetAudioOutFeedingCodec"},
  163. {139, nullptr, "GetAudioOutFeedingParameter"},
  164. {140, nullptr, "AcquireAudioOutBufferAvailableEvent"},
  165. {141, nullptr, "SendAudioData"},
  166. {142, nullptr, "AcquireAudioControlInputStateChangedEvent"},
  167. {143, nullptr, "GetAudioControlInputState"},
  168. {144, nullptr, "AcquireAudioConnectionStateChangedEvent"},
  169. {145, nullptr, "GetConnectedAudioDevice"},
  170. {256, nullptr, "IsManufacturingMode"},
  171. {257, nullptr, "EmulateBluetoothCrash"},
  172. {258, nullptr, "GetBleChannelMap"},
  173. };
  174. // clang-format on
  175. RegisterHandlers(functions);
  176. }
  177. };
  178. void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
  179. std::make_shared<BtDrv>(system)->InstallAsService(sm);
  180. std::make_shared<Bt>(system)->InstallAsService(sm);
  181. }
  182. } // namespace Service::BtDrv