2018-08-07 06:41:43 +00:00
|
|
|
// 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/service/service.h"
|
|
|
|
#include "core/hle/service/sm/sm.h"
|
|
|
|
#include "core/hle/service/usb/usb.h"
|
|
|
|
|
|
|
|
namespace Service::USB {
|
|
|
|
|
|
|
|
class IDsInterface final : public ServiceFramework<IDsInterface> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetDsEndpoint"},
|
|
|
|
{1, nullptr, "GetSetupEvent"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{2, nullptr, "Unknown2"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{3, nullptr, "EnableInterface"},
|
|
|
|
{4, nullptr, "DisableInterface"},
|
|
|
|
{5, nullptr, "CtrlInPostBufferAsync"},
|
|
|
|
{6, nullptr, "CtrlOutPostBufferAsync"},
|
|
|
|
{7, nullptr, "GetCtrlInCompletionEvent"},
|
|
|
|
{8, nullptr, "GetCtrlInReportData"},
|
|
|
|
{9, nullptr, "GetCtrlOutCompletionEvent"},
|
|
|
|
{10, nullptr, "GetCtrlOutReportData"},
|
|
|
|
{11, nullptr, "StallCtrl"},
|
|
|
|
{12, nullptr, "AppendConfigurationData"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class USB_DS final : public ServiceFramework<USB_DS> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit USB_DS(Core::System& system_) : ServiceFramework{system_, "usb:ds"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "BindDevice"},
|
|
|
|
{1, nullptr, "BindClientProcess"},
|
|
|
|
{2, nullptr, "GetDsInterface"},
|
|
|
|
{3, nullptr, "GetStateChangeEvent"},
|
|
|
|
{4, nullptr, "GetState"},
|
|
|
|
{5, nullptr, "ClearDeviceData"},
|
|
|
|
{6, nullptr, "AddUsbStringDescriptor"},
|
|
|
|
{7, nullptr, "DeleteUsbStringDescriptor"},
|
|
|
|
{8, nullptr, "SetUsbDeviceDescriptor"},
|
|
|
|
{9, nullptr, "SetBinaryObjectStore"},
|
|
|
|
{10, nullptr, "Enable"},
|
|
|
|
{11, nullptr, "Disable"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{12, nullptr, "Unknown12"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IClientEpSession final : public ServiceFramework<IClientEpSession> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IClientEpSession(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IClientEpSession"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2018-10-24 23:07:53 +00:00
|
|
|
{0, nullptr, "Open"},
|
|
|
|
{1, nullptr, "Close"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{2, nullptr, "Unknown2"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{3, nullptr, "Populate"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{4, nullptr, "PostBufferAsync"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{5, nullptr, "GetXferReport"},
|
2018-12-02 20:49:37 +00:00
|
|
|
{6, nullptr, "PostBufferMultiAsync"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{7, nullptr, "Unknown7"},
|
|
|
|
{8, nullptr, "Unknown8"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IClientIfSession final : public ServiceFramework<IClientIfSession> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IClientIfSession(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IClientIfSession"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2020-06-29 02:01:34 +00:00
|
|
|
{0, nullptr, "Unknown0"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{1, nullptr, "SetInterface"},
|
|
|
|
{2, nullptr, "GetInterface"},
|
|
|
|
{3, nullptr, "GetAlternateInterface"},
|
|
|
|
{4, nullptr, "GetCurrentFrame"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{5, nullptr, "CtrlXferAsync"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{6, nullptr, "Unknown6"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{7, nullptr, "GetCtrlXferReport"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{8, nullptr, "ResetDevice"},
|
|
|
|
{9, nullptr, "OpenUsbEp"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class USB_HS final : public ServiceFramework<USB_HS> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit USB_HS(Core::System& system_) : ServiceFramework{system_, "usb:hs"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "BindClientProcess"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{1, nullptr, "QueryAllInterfaces"},
|
|
|
|
{2, nullptr, "QueryAvailableInterfaces"},
|
|
|
|
{3, nullptr, "QueryAcquiredInterfaces"},
|
|
|
|
{4, nullptr, "CreateInterfaceAvailableEvent"},
|
|
|
|
{5, nullptr, "DestroyInterfaceAvailableEvent"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{6, nullptr, "GetInterfaceStateChangeEvent"},
|
2018-10-24 23:07:53 +00:00
|
|
|
{7, nullptr, "AcquireUsbIf"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{8, nullptr, "Unknown8"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IPdSession final : public ServiceFramework<IPdSession> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IPdSession(Core::System& system_) : ServiceFramework{system_, "IPdSession"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "BindNoticeEvent"},
|
2018-10-30 19:23:47 +00:00
|
|
|
{1, nullptr, "UnbindNoticeEvent"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{2, nullptr, "GetStatus"},
|
|
|
|
{3, nullptr, "GetNotice"},
|
2018-10-30 19:23:47 +00:00
|
|
|
{4, nullptr, "EnablePowerRequestNotice"},
|
|
|
|
{5, nullptr, "DisablePowerRequestNotice"},
|
2018-08-07 06:41:43 +00:00
|
|
|
{6, nullptr, "ReplyPowerRequest"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class USB_PD final : public ServiceFramework<USB_PD> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit USB_PD(Core::System& system_) : ServiceFramework{system_, "usb:pd"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &USB_PD::GetPdSession, "GetPdSession"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GetPdSession(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_USB, "called");
|
|
|
|
|
2018-08-07 06:41:43 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 20:19:08 +00:00
|
|
|
rb.PushIpcInterface<IPdSession>(system);
|
2018-08-07 06:41:43 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IPdCradleSession final : public ServiceFramework<IPdCradleSession> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IPdCradleSession(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "IPdCradleSession"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "VdmUserWrite"},
|
|
|
|
{1, nullptr, "VdmUserRead"},
|
|
|
|
{2, nullptr, "Vdm20Init"},
|
|
|
|
{3, nullptr, "GetFwType"},
|
|
|
|
{4, nullptr, "GetFwRevision"},
|
|
|
|
{5, nullptr, "GetManufacturerId"},
|
|
|
|
{6, nullptr, "GetDeviceId"},
|
2020-06-29 02:01:34 +00:00
|
|
|
{7, nullptr, "Unknown7"},
|
|
|
|
{8, nullptr, "Unknown8"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class USB_PD_C final : public ServiceFramework<USB_PD_C> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit USB_PD_C(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GetPdCradleSession(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 20:19:08 +00:00
|
|
|
rb.PushIpcInterface<IPdCradleSession>(system);
|
2018-08-07 06:41:43 +00:00
|
|
|
|
|
|
|
LOG_DEBUG(Service_USB, "called");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class USB_PM final : public ServiceFramework<USB_PM> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit USB_PM(Core::System& system_) : ServiceFramework{system_, "usb:pm"} {
|
2018-08-07 06:41:43 +00:00
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
2020-06-29 02:01:34 +00:00
|
|
|
{0, nullptr, "Unknown0"},
|
|
|
|
{1, nullptr, "Unknown1"},
|
|
|
|
{2, nullptr, "Unknown2"},
|
|
|
|
{3, nullptr, "Unknown3"},
|
|
|
|
{4, nullptr, "Unknown4"},
|
|
|
|
{5, nullptr, "Unknown5"},
|
2018-08-07 06:41:43 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-26 20:19:08 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
|
|
|
|
std::make_shared<USB_DS>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<USB_HS>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<USB_PD>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<USB_PD_C>(system)->InstallAsService(sm);
|
|
|
|
std::make_shared<USB_PM>(system)->InstallAsService(sm);
|
2018-08-07 06:41:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::USB
|