btdrv.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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/kernel.h"
  9. #include "core/hle/kernel/readable_event.h"
  10. #include "core/hle/kernel/writable_event.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{"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::WritableEvent::CreateEventPair(kernel, "BT:RegisterEvent");
  35. }
  36. private:
  37. void RegisterBleEvent(Kernel::HLERequestContext& ctx) {
  38. LOG_WARNING(Service_BTM, "(STUBBED) called");
  39. IPC::ResponseBuilder rb{ctx, 2, 1};
  40. rb.Push(RESULT_SUCCESS);
  41. rb.PushCopyObjects(register_event.readable);
  42. }
  43. Kernel::EventPair register_event;
  44. };
  45. class BtDrv final : public ServiceFramework<BtDrv> {
  46. public:
  47. explicit BtDrv() : ServiceFramework{"btdrv"} {
  48. // clang-format off
  49. static const FunctionInfo functions[] = {
  50. {0, nullptr, "InitializeBluetoothDriver"},
  51. {1, nullptr, "InitializeBluetooth"},
  52. {2, nullptr, "EnableBluetooth"},
  53. {3, nullptr, "DisableBluetooth"},
  54. {4, nullptr, "FinalizeBluetooth"},
  55. {5, nullptr, "GetAdapterProperties"},
  56. {6, nullptr, "GetAdapterProperty"},
  57. {7, nullptr, "SetAdapterProperty"},
  58. {8, nullptr, "StartInquiry"},
  59. {9, nullptr, "StopInquiry"},
  60. {10, nullptr, "CreateBond"},
  61. {11, nullptr, "RemoveBond"},
  62. {12, nullptr, "CancelBond"},
  63. {13, nullptr, "RespondToPinRequest"},
  64. {14, nullptr, "RespondToSspRequest"},
  65. {15, nullptr, "GetEventInfo"},
  66. {16, nullptr, "InitializeHid"},
  67. {17, nullptr, "OpenHidConnection"},
  68. {18, nullptr, "CloseHidConnection"},
  69. {19, nullptr, "WriteHidData"},
  70. {20, nullptr, "WriteHidData2"},
  71. {21, nullptr, "SetHidReport"},
  72. {22, nullptr, "GetHidReport"},
  73. {23, nullptr, "TriggerConnection"},
  74. {24, nullptr, "AddPairedDeviceInfo"},
  75. {25, nullptr, "GetPairedDeviceInfo"},
  76. {26, nullptr, "FinalizeHid"},
  77. {27, nullptr, "GetHidEventInfo"},
  78. {28, nullptr, "SetTsi"},
  79. {29, nullptr, "EnableBurstMode"},
  80. {30, nullptr, "SetZeroRetransmission"},
  81. {31, nullptr, "EnableMcMode"},
  82. {32, nullptr, "EnableLlrScan"},
  83. {33, nullptr, "DisableLlrScan"},
  84. {34, nullptr, "EnableRadio"},
  85. {35, nullptr, "SetVisibility"},
  86. {36, nullptr, "EnableTbfcScan"},
  87. {37, nullptr, "RegisterHidReportEvent"},
  88. {38, nullptr, "GetHidReportEventInfo"},
  89. {39, nullptr, "GetLatestPlr"},
  90. {40, nullptr, "GetPendingConnections"},
  91. {41, nullptr, "GetChannelMap"},
  92. {42, nullptr, "EnableTxPowerBoostSetting"},
  93. {43, nullptr, "IsTxPowerBoostSettingEnabled"},
  94. {44, nullptr, "EnableAfhSetting"},
  95. {45, nullptr, "IsAfhSettingEnabled"},
  96. {46, nullptr, "InitializeBle"},
  97. {47, nullptr, "EnableBle"},
  98. {48, nullptr, "DisableBle"},
  99. {49, nullptr, "FinalizeBle"},
  100. {50, nullptr, "SetBleVisibility"},
  101. {51, nullptr, "SetBleConnectionParameter"},
  102. {52, nullptr, "SetBleDefaultConnectionParameter"},
  103. {53, nullptr, "SetBleAdvertiseData"},
  104. {54, nullptr, "SetBleAdvertiseParameter"},
  105. {55, nullptr, "StartBleScan"},
  106. {56, nullptr, "StopBleScan"},
  107. {57, nullptr, "AddBleScanFilterCondition"},
  108. {58, nullptr, "DeleteBleScanFilterCondition"},
  109. {59, nullptr, "DeleteBleScanFilter"},
  110. {60, nullptr, "ClearBleScanFilters"},
  111. {61, nullptr, "EnableBleScanFilter"},
  112. {62, nullptr, "RegisterGattClient"},
  113. {63, nullptr, "UnregisterGattClient"},
  114. {64, nullptr, "UnregisterAllGattClients"},
  115. {65, nullptr, "ConnectGattServer"},
  116. {66, nullptr, "CancelConnectGattServer"},
  117. {67, nullptr, "DisconnectGattServer"},
  118. {68, nullptr, "GetGattAttribute"},
  119. {69, nullptr, "GetGattService"},
  120. {70, nullptr, "ConfigureAttMtu"},
  121. {71, nullptr, "RegisterGattServer"},
  122. {72, nullptr, "UnregisterGattServer"},
  123. {73, nullptr, "ConnectGattClient"},
  124. {74, nullptr, "DisconnectGattClient"},
  125. {75, nullptr, "AddGattService"},
  126. {76, nullptr, "EnableGattService"},
  127. {77, nullptr, "AddGattCharacteristic"},
  128. {78, nullptr, "AddGattDescriptor"},
  129. {79, nullptr, "GetBleManagedEventInfo"},
  130. {80, nullptr, "GetGattFirstCharacteristic"},
  131. {81, nullptr, "GetGattNextCharacteristic"},
  132. {82, nullptr, "GetGattFirstDescriptor"},
  133. {83, nullptr, "GetGattNextDescriptor"},
  134. {84, nullptr, "RegisterGattManagedDataPath"},
  135. {85, nullptr, "UnregisterGattManagedDataPath"},
  136. {86, nullptr, "RegisterGattHidDataPath"},
  137. {87, nullptr, "UnregisterGattHidDataPath"},
  138. {88, nullptr, "RegisterGattDataPath"},
  139. {89, nullptr, "UnregisterGattDataPath"},
  140. {90, nullptr, "ReadGattCharacteristic"},
  141. {91, nullptr, "ReadGattDescriptor"},
  142. {92, nullptr, "WriteGattCharacteristic"},
  143. {93, nullptr, "WriteGattDescriptor"},
  144. {94, nullptr, "RegisterGattNotification"},
  145. {95, nullptr, "UnregisterGattNotification"},
  146. {96, nullptr, "GetLeHidEventInfo"},
  147. {97, nullptr, "RegisterBleHidEvent"},
  148. {98, nullptr, "SetBleScanParameter"},
  149. {99, nullptr, "MoveToSecondaryPiconet"},
  150. {256, nullptr, "IsManufacturingMode"},
  151. {257, nullptr, "EmulateBluetoothCrash"},
  152. {258, nullptr, "GetBleChannelMap"},
  153. };
  154. // clang-format on
  155. RegisterHandlers(functions);
  156. }
  157. };
  158. void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
  159. std::make_shared<BtDrv>()->InstallAsService(sm);
  160. std::make_shared<Bt>(system)->InstallAsService(sm);
  161. }
  162. } // namespace Service::BtDrv