btdrv.cpp 7.0 KB

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