2018-07-26 18:00:50 -04:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-11-16 09:42:17 -05:00
|
|
|
#include "common/logging/log.h"
|
2020-11-08 15:49:45 -05:00
|
|
|
#include "core/core.h"
|
2018-11-16 09:42:17 -05:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
#include "core/hle/kernel/hle_ipc.h"
|
2021-01-31 04:38:57 -05:00
|
|
|
#include "core/hle/kernel/k_event.h"
|
2021-01-30 01:48:06 -05:00
|
|
|
#include "core/hle/kernel/k_readable_event.h"
|
2018-11-26 18:34:07 -05:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2018-07-26 18:00:50 -04:00
|
|
|
#include "core/hle/service/btdrv/btdrv.h"
|
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
#include "core/hle/service/sm/sm.h"
|
|
|
|
|
|
|
|
namespace Service::BtDrv {
|
|
|
|
|
2018-11-16 09:42:17 -05:00
|
|
|
class Bt final : public ServiceFramework<Bt> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit Bt(Core::System& system_) : ServiceFramework{system_, "bt"} {
|
2018-11-16 09:42:17 -05:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2019-01-29 21:40:39 -05:00
|
|
|
{0, nullptr, "LeClientReadCharacteristic"},
|
|
|
|
{1, nullptr, "LeClientReadDescriptor"},
|
|
|
|
{2, nullptr, "LeClientWriteCharacteristic"},
|
|
|
|
{3, nullptr, "LeClientWriteDescriptor"},
|
|
|
|
{4, nullptr, "LeClientRegisterNotification"},
|
|
|
|
{5, nullptr, "LeClientDeregisterNotification"},
|
|
|
|
{6, nullptr, "SetLeResponse"},
|
|
|
|
{7, nullptr, "LeSendIndication"},
|
|
|
|
{8, nullptr, "GetLeEventInfo"},
|
|
|
|
{9, &Bt::RegisterBleEvent, "RegisterBleEvent"},
|
2018-11-16 09:42:17 -05:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
RegisterHandlers(functions);
|
2018-11-26 18:34:07 -05:00
|
|
|
|
2019-09-21 04:42:38 -04:00
|
|
|
auto& kernel = system.Kernel();
|
2021-01-31 04:38:57 -05:00
|
|
|
register_event = Kernel::KEvent::Create(kernel, "BT:RegisterEvent");
|
|
|
|
register_event->Initialize();
|
2018-11-16 09:42:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-01-29 21:40:39 -05:00
|
|
|
void RegisterBleEvent(Kernel::HLERequestContext& ctx) {
|
2018-11-26 01:06:13 -05:00
|
|
|
LOG_WARNING(Service_BTM, "(STUBBED) called");
|
|
|
|
|
2018-11-16 09:42:17 -05:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2021-01-31 04:38:57 -05:00
|
|
|
rb.PushCopyObjects(register_event->GetReadableEvent());
|
2018-11-16 09:42:17 -05:00
|
|
|
}
|
2018-11-27 09:18:29 -05:00
|
|
|
|
2021-01-31 04:38:57 -05:00
|
|
|
std::shared_ptr<Kernel::KEvent> register_event;
|
2018-11-16 09:42:17 -05:00
|
|
|
};
|
|
|
|
|
2018-07-26 18:00:50 -04:00
|
|
|
class BtDrv final : public ServiceFramework<BtDrv> {
|
|
|
|
public:
|
2020-11-26 15:19:08 -05:00
|
|
|
explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
|
2018-07-26 18:00:50 -04:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2019-01-29 21:40:39 -05:00
|
|
|
{0, nullptr, "InitializeBluetoothDriver"},
|
|
|
|
{1, nullptr, "InitializeBluetooth"},
|
|
|
|
{2, nullptr, "EnableBluetooth"},
|
|
|
|
{3, nullptr, "DisableBluetooth"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{4, nullptr, "FinalizeBluetooth"},
|
2018-07-26 18:00:50 -04:00
|
|
|
{5, nullptr, "GetAdapterProperties"},
|
|
|
|
{6, nullptr, "GetAdapterProperty"},
|
|
|
|
{7, nullptr, "SetAdapterProperty"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{8, nullptr, "StartInquiry"},
|
|
|
|
{9, nullptr, "StopInquiry"},
|
2018-07-26 18:00:50 -04:00
|
|
|
{10, nullptr, "CreateBond"},
|
|
|
|
{11, nullptr, "RemoveBond"},
|
|
|
|
{12, nullptr, "CancelBond"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{13, nullptr, "RespondToPinRequest"},
|
|
|
|
{14, nullptr, "RespondToSspRequest"},
|
2019-01-29 21:40:39 -05:00
|
|
|
{15, nullptr, "GetEventInfo"},
|
|
|
|
{16, nullptr, "InitializeHid"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{17, nullptr, "OpenHidConnection"},
|
|
|
|
{18, nullptr, "CloseHidConnection"},
|
|
|
|
{19, nullptr, "WriteHidData"},
|
|
|
|
{20, nullptr, "WriteHidData2"},
|
|
|
|
{21, nullptr, "SetHidReport"},
|
|
|
|
{22, nullptr, "GetHidReport"},
|
|
|
|
{23, nullptr, "TriggerConnection"},
|
|
|
|
{24, nullptr, "AddPairedDeviceInfo"},
|
|
|
|
{25, nullptr, "GetPairedDeviceInfo"},
|
|
|
|
{26, nullptr, "FinalizeHid"},
|
|
|
|
{27, nullptr, "GetHidEventInfo"},
|
|
|
|
{28, nullptr, "SetTsi"},
|
|
|
|
{29, nullptr, "EnableBurstMode"},
|
|
|
|
{30, nullptr, "SetZeroRetransmission"},
|
|
|
|
{31, nullptr, "EnableMcMode"},
|
|
|
|
{32, nullptr, "EnableLlrScan"},
|
|
|
|
{33, nullptr, "DisableLlrScan"},
|
|
|
|
{34, nullptr, "EnableRadio"},
|
|
|
|
{35, nullptr, "SetVisibility"},
|
|
|
|
{36, nullptr, "EnableTbfcScan"},
|
2019-01-29 21:40:39 -05:00
|
|
|
{37, nullptr, "RegisterHidReportEvent"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{38, nullptr, "GetHidReportEventInfo"},
|
2019-01-29 21:40:39 -05:00
|
|
|
{39, nullptr, "GetLatestPlr"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{40, nullptr, "GetPendingConnections"},
|
2019-01-29 21:40:39 -05:00
|
|
|
{41, nullptr, "GetChannelMap"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{42, nullptr, "EnableTxPowerBoostSetting"},
|
|
|
|
{43, nullptr, "IsTxPowerBoostSettingEnabled"},
|
|
|
|
{44, nullptr, "EnableAfhSetting"},
|
|
|
|
{45, nullptr, "IsAfhSettingEnabled"},
|
|
|
|
{46, nullptr, "InitializeBle"},
|
|
|
|
{47, nullptr, "EnableBle"},
|
|
|
|
{48, nullptr, "DisableBle"},
|
|
|
|
{49, nullptr, "FinalizeBle"},
|
|
|
|
{50, nullptr, "SetBleVisibility"},
|
|
|
|
{51, nullptr, "SetBleConnectionParameter"},
|
|
|
|
{52, nullptr, "SetBleDefaultConnectionParameter"},
|
|
|
|
{53, nullptr, "SetBleAdvertiseData"},
|
|
|
|
{54, nullptr, "SetBleAdvertiseParameter"},
|
|
|
|
{55, nullptr, "StartBleScan"},
|
|
|
|
{56, nullptr, "StopBleScan"},
|
|
|
|
{57, nullptr, "AddBleScanFilterCondition"},
|
|
|
|
{58, nullptr, "DeleteBleScanFilterCondition"},
|
|
|
|
{59, nullptr, "DeleteBleScanFilter"},
|
|
|
|
{60, nullptr, "ClearBleScanFilters"},
|
|
|
|
{61, nullptr, "EnableBleScanFilter"},
|
|
|
|
{62, nullptr, "RegisterGattClient"},
|
|
|
|
{63, nullptr, "UnregisterGattClient"},
|
|
|
|
{64, nullptr, "UnregisterAllGattClients"},
|
|
|
|
{65, nullptr, "ConnectGattServer"},
|
|
|
|
{66, nullptr, "CancelConnectGattServer"},
|
|
|
|
{67, nullptr, "DisconnectGattServer"},
|
|
|
|
{68, nullptr, "GetGattAttribute"},
|
|
|
|
{69, nullptr, "GetGattService"},
|
|
|
|
{70, nullptr, "ConfigureAttMtu"},
|
|
|
|
{71, nullptr, "RegisterGattServer"},
|
|
|
|
{72, nullptr, "UnregisterGattServer"},
|
|
|
|
{73, nullptr, "ConnectGattClient"},
|
|
|
|
{74, nullptr, "DisconnectGattClient"},
|
|
|
|
{75, nullptr, "AddGattService"},
|
|
|
|
{76, nullptr, "EnableGattService"},
|
|
|
|
{77, nullptr, "AddGattCharacteristic"},
|
|
|
|
{78, nullptr, "AddGattDescriptor"},
|
|
|
|
{79, nullptr, "GetBleManagedEventInfo"},
|
|
|
|
{80, nullptr, "GetGattFirstCharacteristic"},
|
|
|
|
{81, nullptr, "GetGattNextCharacteristic"},
|
|
|
|
{82, nullptr, "GetGattFirstDescriptor"},
|
|
|
|
{83, nullptr, "GetGattNextDescriptor"},
|
|
|
|
{84, nullptr, "RegisterGattManagedDataPath"},
|
|
|
|
{85, nullptr, "UnregisterGattManagedDataPath"},
|
|
|
|
{86, nullptr, "RegisterGattHidDataPath"},
|
|
|
|
{87, nullptr, "UnregisterGattHidDataPath"},
|
|
|
|
{88, nullptr, "RegisterGattDataPath"},
|
|
|
|
{89, nullptr, "UnregisterGattDataPath"},
|
|
|
|
{90, nullptr, "ReadGattCharacteristic"},
|
|
|
|
{91, nullptr, "ReadGattDescriptor"},
|
|
|
|
{92, nullptr, "WriteGattCharacteristic"},
|
|
|
|
{93, nullptr, "WriteGattDescriptor"},
|
|
|
|
{94, nullptr, "RegisterGattNotification"},
|
|
|
|
{95, nullptr, "UnregisterGattNotification"},
|
2019-01-29 21:40:39 -05:00
|
|
|
{96, nullptr, "GetLeHidEventInfo"},
|
|
|
|
{97, nullptr, "RegisterBleHidEvent"},
|
2020-06-26 20:34:29 -04:00
|
|
|
{98, nullptr, "SetBleScanParameter"},
|
|
|
|
{99, nullptr, "MoveToSecondaryPiconet"},
|
|
|
|
{256, nullptr, "IsManufacturingMode"},
|
2019-04-10 14:48:37 -04:00
|
|
|
{257, nullptr, "EmulateBluetoothCrash"},
|
2019-11-12 08:54:58 -05:00
|
|
|
{258, nullptr, "GetBleChannelMap"},
|
2018-07-26 18:00:50 -04:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-21 04:42:38 -04:00
|
|
|
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
|
2020-11-26 15:19:08 -05:00
|
|
|
std::make_shared<BtDrv>(system)->InstallAsService(sm);
|
2019-09-21 04:42:38 -04:00
|
|
|
std::make_shared<Bt>(system)->InstallAsService(sm);
|
2018-07-26 18:00:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::BtDrv
|