btdrv.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/hle/ipc_helpers.h"
  6. #include "core/hle/kernel/hle_ipc.h"
  7. #include "core/hle/kernel/kernel.h"
  8. #include "core/hle/kernel/readable_event.h"
  9. #include "core/hle/kernel/writable_event.h"
  10. #include "core/hle/service/btdrv/btdrv.h"
  11. #include "core/hle/service/service.h"
  12. #include "core/hle/service/sm/sm.h"
  13. namespace Service::BtDrv {
  14. class Bt final : public ServiceFramework<Bt> {
  15. public:
  16. explicit Bt(Core::System& system) : ServiceFramework{"bt"} {
  17. // clang-format off
  18. static const FunctionInfo functions[] = {
  19. {0, nullptr, "LeClientReadCharacteristic"},
  20. {1, nullptr, "LeClientReadDescriptor"},
  21. {2, nullptr, "LeClientWriteCharacteristic"},
  22. {3, nullptr, "LeClientWriteDescriptor"},
  23. {4, nullptr, "LeClientRegisterNotification"},
  24. {5, nullptr, "LeClientDeregisterNotification"},
  25. {6, nullptr, "SetLeResponse"},
  26. {7, nullptr, "LeSendIndication"},
  27. {8, nullptr, "GetLeEventInfo"},
  28. {9, &Bt::RegisterBleEvent, "RegisterBleEvent"},
  29. };
  30. // clang-format on
  31. RegisterHandlers(functions);
  32. auto& kernel = system.Kernel();
  33. register_event = Kernel::WritableEvent::CreateEventPair(kernel, "BT:RegisterEvent");
  34. }
  35. private:
  36. void RegisterBleEvent(Kernel::HLERequestContext& ctx) {
  37. LOG_WARNING(Service_BTM, "(STUBBED) called");
  38. IPC::ResponseBuilder rb{ctx, 2, 1};
  39. rb.Push(RESULT_SUCCESS);
  40. rb.PushCopyObjects(register_event.readable);
  41. }
  42. Kernel::EventPair register_event;
  43. };
  44. class BtDrv final : public ServiceFramework<BtDrv> {
  45. public:
  46. explicit BtDrv() : ServiceFramework{"btdrv"} {
  47. // clang-format off
  48. static const FunctionInfo functions[] = {
  49. {0, nullptr, "InitializeBluetoothDriver"},
  50. {1, nullptr, "InitializeBluetooth"},
  51. {2, nullptr, "EnableBluetooth"},
  52. {3, nullptr, "DisableBluetooth"},
  53. {4, nullptr, "CleanupBluetooth"},
  54. {5, nullptr, "GetAdapterProperties"},
  55. {6, nullptr, "GetAdapterProperty"},
  56. {7, nullptr, "SetAdapterProperty"},
  57. {8, nullptr, "StartDiscovery"},
  58. {9, nullptr, "CancelDiscovery"},
  59. {10, nullptr, "CreateBond"},
  60. {11, nullptr, "RemoveBond"},
  61. {12, nullptr, "CancelBond"},
  62. {13, nullptr, "PinReply"},
  63. {14, nullptr, "SspReply"},
  64. {15, nullptr, "GetEventInfo"},
  65. {16, nullptr, "InitializeHid"},
  66. {17, nullptr, "HidConnect"},
  67. {18, nullptr, "HidDisconnect"},
  68. {19, nullptr, "HidSendData"},
  69. {20, nullptr, "HidSendData2"},
  70. {21, nullptr, "HidSetReport"},
  71. {22, nullptr, "HidGetReport"},
  72. {23, nullptr, "HidWakeController"},
  73. {24, nullptr, "HidAddPairedDevice"},
  74. {25, nullptr, "HidGetPairedDevice"},
  75. {26, nullptr, "CleanupHid"},
  76. {27, nullptr, "HidGetEventInfo"},
  77. {28, nullptr, "ExtSetTsi"},
  78. {29, nullptr, "ExtSetBurstMode"},
  79. {30, nullptr, "ExtSetZeroRetran"},
  80. {31, nullptr, "ExtSetMcMode"},
  81. {32, nullptr, "ExtStartLlrMode"},
  82. {33, nullptr, "ExtExitLlrMode"},
  83. {34, nullptr, "ExtSetRadio"},
  84. {35, nullptr, "ExtSetVisibility"},
  85. {36, nullptr, "ExtSetTbfcScan"},
  86. {37, nullptr, "RegisterHidReportEvent"},
  87. {38, nullptr, "HidGetReportEventInfo"},
  88. {39, nullptr, "GetLatestPlr"},
  89. {40, nullptr, "ExtGetPendingConnections"},
  90. {41, nullptr, "GetChannelMap"},
  91. {42, nullptr, "EnableBluetoothBoostSetting"},
  92. {43, nullptr, "IsBluetoothBoostSettingEnabled"},
  93. {44, nullptr, "EnableBluetoothAfhSetting"},
  94. {45, nullptr, "IsBluetoothAfhSettingEnabled"},
  95. {46, nullptr, "InitializeBluetoothLe"},
  96. {47, nullptr, "EnableBluetoothLe"},
  97. {48, nullptr, "DisableBluetoothLe"},
  98. {49, nullptr, "CleanupBluetoothLe"},
  99. {50, nullptr, "SetLeVisibility"},
  100. {51, nullptr, "SetLeConnectionParameter"},
  101. {52, nullptr, "SetLeDefaultConnectionParameter"},
  102. {53, nullptr, "SetLeAdvertiseData"},
  103. {54, nullptr, "SetLeAdvertiseParameter"},
  104. {55, nullptr, "StartLeScan"},
  105. {56, nullptr, "StopLeScan"},
  106. {57, nullptr, "AddLeScanFilterCondition"},
  107. {58, nullptr, "DeleteLeScanFilterCondition"},
  108. {59, nullptr, "DeleteLeScanFilter"},
  109. {60, nullptr, "ClearLeScanFilters"},
  110. {61, nullptr, "EnableLeScanFilter"},
  111. {62, nullptr, "RegisterLeClient"},
  112. {63, nullptr, "UnregisterLeClient"},
  113. {64, nullptr, "UnregisterLeClientAll"},
  114. {65, nullptr, "LeClientConnect"},
  115. {66, nullptr, "LeClientCancelConnection"},
  116. {67, nullptr, "LeClientDisconnect"},
  117. {68, nullptr, "LeClientGetAttributes"},
  118. {69, nullptr, "LeClientDiscoverService"},
  119. {70, nullptr, "LeClientConfigureMtu"},
  120. {71, nullptr, "RegisterLeServer"},
  121. {72, nullptr, "UnregisterLeServer"},
  122. {73, nullptr, "LeServerConnect"},
  123. {74, nullptr, "LeServerDisconnect"},
  124. {75, nullptr, "CreateLeService"},
  125. {76, nullptr, "StartLeService"},
  126. {77, nullptr, "AddLeCharacteristic"},
  127. {78, nullptr, "AddLeDescriptor"},
  128. {79, nullptr, "GetLeCoreEventInfo"},
  129. {80, nullptr, "LeGetFirstCharacteristic"},
  130. {81, nullptr, "LeGetNextCharacteristic"},
  131. {82, nullptr, "LeGetFirstDescriptor"},
  132. {83, nullptr, "LeGetNextDescriptor"},
  133. {84, nullptr, "RegisterLeCoreDataPath"},
  134. {85, nullptr, "UnregisterLeCoreDataPath"},
  135. {86, nullptr, "RegisterLeHidDataPath"},
  136. {87, nullptr, "UnregisterLeHidDataPath"},
  137. {88, nullptr, "RegisterLeDataPath"},
  138. {89, nullptr, "UnregisterLeDataPath"},
  139. {90, nullptr, "LeClientReadCharacteristic"},
  140. {91, nullptr, "LeClientReadDescriptor"},
  141. {92, nullptr, "LeClientWriteCharacteristic"},
  142. {93, nullptr, "LeClientWriteDescriptor"},
  143. {94, nullptr, "LeClientRegisterNotification"},
  144. {95, nullptr, "LeClientDeregisterNotification"},
  145. {96, nullptr, "GetLeHidEventInfo"},
  146. {97, nullptr, "RegisterBleHidEvent"},
  147. {98, nullptr, "SetLeScanParameter"},
  148. {256, nullptr, "GetIsManufacturingMode"},
  149. {257, nullptr, "EmulateBluetoothCrash"},
  150. {258, nullptr, "GetBleChannelMap"},
  151. };
  152. // clang-format on
  153. RegisterHandlers(functions);
  154. }
  155. };
  156. void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
  157. std::make_shared<BtDrv>()->InstallAsService(sm);
  158. std::make_shared<Bt>(system)->InstallAsService(sm);
  159. }
  160. } // namespace Service::BtDrv