| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- // Copyright 2018 yuzu emulator team
- // Licensed under GPLv2 or any later version
- // Refer to the license.txt file included.
- #include <memory>
- #include "common/logging/log.h"
- #include "core/hle/ipc_helpers.h"
- #include "core/hle/kernel/hle_ipc.h"
- #include "core/hle/kernel/kernel.h"
- #include "core/hle/kernel/readable_event.h"
- #include "core/hle/kernel/writable_event.h"
- #include "core/hle/service/btm/btm.h"
- #include "core/hle/service/service.h"
- namespace Service::BTM {
- class IBtmUserCore final : public ServiceFramework<IBtmUserCore> {
- public:
- explicit IBtmUserCore(Core::System& system) : ServiceFramework{"IBtmUserCore"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"},
- {1, nullptr, "GetBleScanFilterParameter"},
- {2, nullptr, "GetBleScanFilterParameter2"},
- {3, nullptr, "StartBleScanForGeneral"},
- {4, nullptr, "StopBleScanForGeneral"},
- {5, nullptr, "GetBleScanResultsForGeneral"},
- {6, nullptr, "StartBleScanForPaired"},
- {7, nullptr, "StopBleScanForPaired"},
- {8, nullptr, "StartBleScanForSmartDevice"},
- {9, nullptr, "StopBleScanForSmartDevice"},
- {10, nullptr, "GetBleScanResultsForSmartDevice"},
- {17, &IBtmUserCore::AcquireBleConnectionEvent, "AcquireBleConnectionEvent"},
- {18, nullptr, "BleConnect"},
- {19, nullptr, "BleDisconnect"},
- {20, nullptr, "BleGetConnectionState"},
- {21, nullptr, "AcquireBlePairingEvent"},
- {22, nullptr, "BlePairDevice"},
- {23, nullptr, "BleUnPairDevice"},
- {24, nullptr, "BleUnPairDevice2"},
- {25, nullptr, "BleGetPairedDevices"},
- {26, &IBtmUserCore::AcquireBleServiceDiscoveryEvent, "AcquireBleServiceDiscoveryEvent"},
- {27, nullptr, "GetGattServices"},
- {28, nullptr, "GetGattService"},
- {29, nullptr, "GetGattIncludedServices"},
- {30, nullptr, "GetBelongingGattService"},
- {31, nullptr, "GetGattCharacteristics"},
- {32, nullptr, "GetGattDescriptors"},
- {33, &IBtmUserCore::AcquireBleMtuConfigEvent, "AcquireBleMtuConfigEvent"},
- {34, nullptr, "ConfigureBleMtu"},
- {35, nullptr, "GetBleMtu"},
- {36, nullptr, "RegisterBleGattDataPath"},
- {37, nullptr, "UnregisterBleGattDataPath"},
- };
- // clang-format on
- RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- scan_event = Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ScanEvent");
- connection_event =
- Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConnectionEvent");
- service_discovery =
- Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:Discovery");
- config_event = Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConfigEvent");
- }
- private:
- void AcquireBleScanEvent(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_BTM, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(scan_event.readable);
- }
- void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_BTM, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(connection_event.readable);
- }
- void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_BTM, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(service_discovery.readable);
- }
- void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_BTM, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(config_event.readable);
- }
- Kernel::EventPair scan_event;
- Kernel::EventPair connection_event;
- Kernel::EventPair service_discovery;
- Kernel::EventPair config_event;
- };
- class BTM_USR final : public ServiceFramework<BTM_USR> {
- public:
- explicit BTM_USR(Core::System& system) : ServiceFramework{"btm:u"}, system(system) {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &BTM_USR::GetCore, "GetCore"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- private:
- void GetCore(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_BTM, "called");
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IBtmUserCore>(system);
- }
- Core::System& system;
- };
- class BTM final : public ServiceFramework<BTM> {
- public:
- explicit BTM() : ServiceFramework{"btm"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "GetState"},
- {1, nullptr, "GetHostDeviceProperty"},
- {2, nullptr, "AcquireDeviceConditionEvent"},
- {3, nullptr, "GetDeviceCondition"},
- {4, nullptr, "SetBurstMode"},
- {5, nullptr, "SetSlotMode"},
- {6, nullptr, "SetBluetoothMode"},
- {7, nullptr, "SetWlanMode"},
- {8, nullptr, "AcquireDeviceInfoEvent"},
- {9, nullptr, "GetDeviceInfo"},
- {10, nullptr, "AddDeviceInfo"},
- {11, nullptr, "RemoveDeviceInfo"},
- {12, nullptr, "IncreaseDeviceInfoOrder"},
- {13, nullptr, "LlrNotify"},
- {14, nullptr, "EnableRadio"},
- {15, nullptr, "DisableRadio"},
- {16, nullptr, "HidDisconnect"},
- {17, nullptr, "HidSetRetransmissionMode"},
- {18, nullptr, "AcquireAwakeReqEvent"},
- {19, nullptr, "AcquireLlrStateEvent"},
- {20, nullptr, "IsLlrStarted"},
- {21, nullptr, "EnableSlotSaving"},
- {22, nullptr, "ProtectDeviceInfo"},
- {23, nullptr, "AcquireBleScanEvent"},
- {24, nullptr, "GetBleScanParameterGeneral"},
- {25, nullptr, "GetBleScanParameterSmartDevice"},
- {26, nullptr, "StartBleScanForGeneral"},
- {27, nullptr, "StopBleScanForGeneral"},
- {28, nullptr, "GetBleScanResultsForGeneral"},
- {29, nullptr, "StartBleScanForPairedDevice"},
- {30, nullptr, "StopBleScanForPairedDevice"},
- {31, nullptr, "StartBleScanForSmartDevice"},
- {32, nullptr, "StopBleScanForSmartDevice"},
- {33, nullptr, "GetBleScanResultsForSmartDevice"},
- {34, nullptr, "AcquireBleConnectionEvent"},
- {35, nullptr, "BleConnect"},
- {36, nullptr, "BleOverrideConnection"},
- {37, nullptr, "BleDisconnect"},
- {38, nullptr, "BleGetConnectionState"},
- {39, nullptr, "BleGetGattClientConditionList"},
- {40, nullptr, "AcquireBlePairingEvent"},
- {41, nullptr, "BlePairDevice"},
- {42, nullptr, "BleUnpairDeviceOnBoth"},
- {43, nullptr, "BleUnpairDevice"},
- {44, nullptr, "BleGetPairedAddresses"},
- {45, nullptr, "AcquireBleServiceDiscoveryEvent"},
- {46, nullptr, "GetGattServices"},
- {47, nullptr, "GetGattService"},
- {48, nullptr, "GetGattIncludedServices"},
- {49, nullptr, "GetBelongingService"},
- {50, nullptr, "GetGattCharacteristics"},
- {51, nullptr, "GetGattDescriptors"},
- {52, nullptr, "AcquireBleMtuConfigEvent"},
- {53, nullptr, "ConfigureBleMtu"},
- {54, nullptr, "GetBleMtu"},
- {55, nullptr, "RegisterBleGattDataPath"},
- {56, nullptr, "UnregisterBleGattDataPath"},
- {57, nullptr, "RegisterAppletResourceUserId"},
- {58, nullptr, "UnregisterAppletResourceUserId"},
- {59, nullptr, "SetAppletResourceUserId"},
- {60, nullptr, "Unknown"},
- {61, nullptr, "Unknown2"},
- {62, nullptr, "Unknown3"},
- {63, nullptr, "Unknown4"},
- {64, nullptr, "Unknown5"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- };
- class BTM_DBG final : public ServiceFramework<BTM_DBG> {
- public:
- explicit BTM_DBG() : ServiceFramework{"btm:dbg"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "AcquireDiscoveryEvent"},
- {1, nullptr, "StartDiscovery"},
- {2, nullptr, "CancelDiscovery"},
- {3, nullptr, "GetDeviceProperty"},
- {4, nullptr, "CreateBond"},
- {5, nullptr, "CancelBond"},
- {6, nullptr, "SetTsiMode"},
- {7, nullptr, "GeneralTest"},
- {8, nullptr, "HidConnect"},
- {9, nullptr, "GeneralGet"},
- {10, nullptr, "GetGattClientDisconnectionReason"},
- {11, nullptr, "GetBleConnectionParameter"},
- {12, nullptr, "GetBleConnectionParameterRequest"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- };
- class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
- public:
- explicit IBtmSystemCore() : ServiceFramework{"IBtmSystemCore"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "StartGamepadPairing"},
- {1, nullptr, "CancelGamepadPairing"},
- {2, nullptr, "ClearGamepadPairingDatabase"},
- {3, nullptr, "GetPairedGamepadCount"},
- {4, nullptr, "EnableRadio"},
- {5, nullptr, "DisableRadio"},
- {6, nullptr, "GetRadioOnOff"},
- {7, nullptr, "AcquireRadioEvent"},
- {8, nullptr, "AcquireGamepadPairingEvent"},
- {9, nullptr, "IsGamepadPairingStarted"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- };
- class BTM_SYS final : public ServiceFramework<BTM_SYS> {
- public:
- explicit BTM_SYS() : ServiceFramework{"btm:sys"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &BTM_SYS::GetCore, "GetCore"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- private:
- void GetCore(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_BTM, "called");
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IBtmSystemCore>();
- }
- };
- void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
- std::make_shared<BTM>()->InstallAsService(sm);
- std::make_shared<BTM_DBG>()->InstallAsService(sm);
- std::make_shared<BTM_SYS>()->InstallAsService(sm);
- std::make_shared<BTM_USR>(system)->InstallAsService(sm);
- }
- } // namespace Service::BTM
|