diff options
| author | 2018-08-07 02:41:43 -0400 | |
|---|---|---|
| committer | 2018-08-07 03:14:03 -0400 | |
| commit | 45bc449ff940879f556d191f51c0db705fe6634f (patch) | |
| tree | 5e8b30d0092ac74365b55c3acf869dc04bfc9a30 | |
| parent | Merge pull request #931 from DarkLordZach/nca-as-drd (diff) | |
| download | yuzu-45bc449ff940879f556d191f51c0db705fe6634f.tar.gz yuzu-45bc449ff940879f556d191f51c0db705fe6634f.tar.xz yuzu-45bc449ff940879f556d191f51c0db705fe6634f.zip | |
service: Add usb services
Adds basic skeleton for the usb services based off the information provided by Switch Brew.
| -rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/log.h | 1 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/usb/usb.cpp | 238 | ||||
| -rw-r--r-- | src/core/hle/service/usb/usb.h | 15 |
6 files changed, 259 insertions, 0 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 816414e8d..355abd682 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -200,6 +200,7 @@ void FileBackend::Write(const Entry& entry) { | |||
| 200 | SUB(Service, SPL) \ | 200 | SUB(Service, SPL) \ |
| 201 | SUB(Service, SSL) \ | 201 | SUB(Service, SSL) \ |
| 202 | SUB(Service, Time) \ | 202 | SUB(Service, Time) \ |
| 203 | SUB(Service, USB) \ | ||
| 203 | SUB(Service, VI) \ | 204 | SUB(Service, VI) \ |
| 204 | SUB(Service, WLAN) \ | 205 | SUB(Service, WLAN) \ |
| 205 | CLS(HW) \ | 206 | CLS(HW) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 7ab5277ea..a889ebefa 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -87,6 +87,7 @@ enum class Class : ClassType { | |||
| 87 | Service_SPL, ///< The SPL service | 87 | Service_SPL, ///< The SPL service |
| 88 | Service_SSL, ///< The SSL service | 88 | Service_SSL, ///< The SSL service |
| 89 | Service_Time, ///< The time service | 89 | Service_Time, ///< The time service |
| 90 | Service_USB, ///< The USB (Universal Serial Bus) service | ||
| 90 | Service_VI, ///< The VI (Video interface) service | 91 | Service_VI, ///< The VI (Video interface) service |
| 91 | Service_WLAN, ///< The WLAN (Wireless local area network) service | 92 | Service_WLAN, ///< The WLAN (Wireless local area network) service |
| 92 | HW, ///< Low-level hardware emulation | 93 | HW, ///< Low-level hardware emulation |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c11f017da..0abf7edc1 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -315,6 +315,8 @@ add_library(core STATIC | |||
| 315 | hle/service/time/interface.h | 315 | hle/service/time/interface.h |
| 316 | hle/service/time/time.cpp | 316 | hle/service/time/time.cpp |
| 317 | hle/service/time/time.h | 317 | hle/service/time/time.h |
| 318 | hle/service/usb/usb.cpp | ||
| 319 | hle/service/usb/usb.h | ||
| 318 | hle/service/vi/vi.cpp | 320 | hle/service/vi/vi.cpp |
| 319 | hle/service/vi/vi.h | 321 | hle/service/vi/vi.h |
| 320 | hle/service/vi/vi_m.cpp | 322 | hle/service/vi/vi_m.cpp |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 31ea79773..889cdd41a 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -63,6 +63,7 @@ | |||
| 63 | #include "core/hle/service/spl/module.h" | 63 | #include "core/hle/service/spl/module.h" |
| 64 | #include "core/hle/service/ssl/ssl.h" | 64 | #include "core/hle/service/ssl/ssl.h" |
| 65 | #include "core/hle/service/time/time.h" | 65 | #include "core/hle/service/time/time.h" |
| 66 | #include "core/hle/service/usb/usb.h" | ||
| 66 | #include "core/hle/service/vi/vi.h" | 67 | #include "core/hle/service/vi/vi.h" |
| 67 | #include "core/hle/service/wlan/wlan.h" | 68 | #include "core/hle/service/wlan/wlan.h" |
| 68 | 69 | ||
| @@ -249,6 +250,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 249 | SPL::InstallInterfaces(*sm); | 250 | SPL::InstallInterfaces(*sm); |
| 250 | SSL::InstallInterfaces(*sm); | 251 | SSL::InstallInterfaces(*sm); |
| 251 | Time::InstallInterfaces(*sm); | 252 | Time::InstallInterfaces(*sm); |
| 253 | USB::InstallInterfaces(*sm); | ||
| 252 | VI::InstallInterfaces(*sm, nv_flinger); | 254 | VI::InstallInterfaces(*sm, nv_flinger); |
| 253 | WLAN::InstallInterfaces(*sm); | 255 | WLAN::InstallInterfaces(*sm); |
| 254 | 256 | ||
diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp new file mode 100644 index 000000000..e7fb5a419 --- /dev/null +++ b/src/core/hle/service/usb/usb.cpp | |||
| @@ -0,0 +1,238 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <memory> | ||
| 6 | |||
| 7 | #include "common/logging/log.h" | ||
| 8 | #include "core/hle/ipc_helpers.h" | ||
| 9 | #include "core/hle/kernel/hle_ipc.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | #include "core/hle/service/sm/sm.h" | ||
| 12 | #include "core/hle/service/usb/usb.h" | ||
| 13 | |||
| 14 | namespace Service::USB { | ||
| 15 | |||
| 16 | class IDsInterface final : public ServiceFramework<IDsInterface> { | ||
| 17 | public: | ||
| 18 | explicit IDsInterface() : ServiceFramework{"IDsInterface"} { | ||
| 19 | // clang-format off | ||
| 20 | static const FunctionInfo functions[] = { | ||
| 21 | {0, nullptr, "GetDsEndpoint"}, | ||
| 22 | {1, nullptr, "GetSetupEvent"}, | ||
| 23 | {2, nullptr, "Unknown"}, | ||
| 24 | {3, nullptr, "EnableInterface"}, | ||
| 25 | {4, nullptr, "DisableInterface"}, | ||
| 26 | {5, nullptr, "CtrlInPostBufferAsync"}, | ||
| 27 | {6, nullptr, "CtrlOutPostBufferAsync"}, | ||
| 28 | {7, nullptr, "GetCtrlInCompletionEvent"}, | ||
| 29 | {8, nullptr, "GetCtrlInReportData"}, | ||
| 30 | {9, nullptr, "GetCtrlOutCompletionEvent"}, | ||
| 31 | {10, nullptr, "GetCtrlOutReportData"}, | ||
| 32 | {11, nullptr, "StallCtrl"}, | ||
| 33 | {12, nullptr, "AppendConfigurationData"}, | ||
| 34 | }; | ||
| 35 | // clang-format on | ||
| 36 | |||
| 37 | RegisterHandlers(functions); | ||
| 38 | } | ||
| 39 | }; | ||
| 40 | |||
| 41 | class USB_DS final : public ServiceFramework<USB_DS> { | ||
| 42 | public: | ||
| 43 | explicit USB_DS() : ServiceFramework{"usb:ds"} { | ||
| 44 | // clang-format off | ||
| 45 | static const FunctionInfo functions[] = { | ||
| 46 | {0, nullptr, "BindDevice"}, | ||
| 47 | {1, nullptr, "BindClientProcess"}, | ||
| 48 | {2, nullptr, "GetDsInterface"}, | ||
| 49 | {3, nullptr, "GetStateChangeEvent"}, | ||
| 50 | {4, nullptr, "GetState"}, | ||
| 51 | {5, nullptr, "ClearDeviceData"}, | ||
| 52 | {6, nullptr, "AddUsbStringDescriptor"}, | ||
| 53 | {7, nullptr, "DeleteUsbStringDescriptor"}, | ||
| 54 | {8, nullptr, "SetUsbDeviceDescriptor"}, | ||
| 55 | {9, nullptr, "SetBinaryObjectStore"}, | ||
| 56 | {10, nullptr, "Enable"}, | ||
| 57 | {11, nullptr, "Disable"}, | ||
| 58 | }; | ||
| 59 | // clang-format on | ||
| 60 | |||
| 61 | RegisterHandlers(functions); | ||
| 62 | } | ||
| 63 | }; | ||
| 64 | |||
| 65 | class IClientEpSession final : public ServiceFramework<IClientEpSession> { | ||
| 66 | public: | ||
| 67 | explicit IClientEpSession() : ServiceFramework{"IClientEpSession"} { | ||
| 68 | // clang-format off | ||
| 69 | static const FunctionInfo functions[] = { | ||
| 70 | {0, nullptr, "Unknown1"}, | ||
| 71 | {1, nullptr, "Unknown2"}, | ||
| 72 | {2, nullptr, "Unknown3"}, | ||
| 73 | {3, nullptr, "Unknown4"}, | ||
| 74 | {4, nullptr, "PostBufferAsync"}, | ||
| 75 | {5, nullptr, "Unknown5"}, | ||
| 76 | {6, nullptr, "Unknown6"}, | ||
| 77 | {7, nullptr, "Unknown7"}, | ||
| 78 | {8, nullptr, "Unknown8"}, | ||
| 79 | }; | ||
| 80 | // clang-format on | ||
| 81 | |||
| 82 | RegisterHandlers(functions); | ||
| 83 | } | ||
| 84 | }; | ||
| 85 | |||
| 86 | class IClientIfSession final : public ServiceFramework<IClientIfSession> { | ||
| 87 | public: | ||
| 88 | explicit IClientIfSession() : ServiceFramework{"IClientIfSession"} { | ||
| 89 | // clang-format off | ||
| 90 | static const FunctionInfo functions[] = { | ||
| 91 | {0, nullptr, "Unknown1"}, | ||
| 92 | {1, nullptr, "Unknown2"}, | ||
| 93 | {2, nullptr, "Unknown3"}, | ||
| 94 | {3, nullptr, "Unknown4"}, | ||
| 95 | {4, nullptr, "Unknown5"}, | ||
| 96 | {5, nullptr, "CtrlXferAsync"}, | ||
| 97 | {6, nullptr, "Unknown6"}, | ||
| 98 | {7, nullptr, "GetCtrlXferReport"}, | ||
| 99 | {8, nullptr, "Unknown7"}, | ||
| 100 | {9, nullptr, "GetClientEpSession"}, | ||
| 101 | }; | ||
| 102 | // clang-format on | ||
| 103 | |||
| 104 | RegisterHandlers(functions); | ||
| 105 | } | ||
| 106 | }; | ||
| 107 | |||
| 108 | class USB_HS final : public ServiceFramework<USB_HS> { | ||
| 109 | public: | ||
| 110 | explicit USB_HS() : ServiceFramework{"usb:hs"} { | ||
| 111 | // clang-format off | ||
| 112 | static const FunctionInfo functions[] = { | ||
| 113 | {0, nullptr, "BindClientProcess"}, | ||
| 114 | {1, nullptr, "Unknown1"}, | ||
| 115 | {2, nullptr, "Unknown2"}, | ||
| 116 | {3, nullptr, "Unknown3"}, | ||
| 117 | {4, nullptr, "Unknown4"}, | ||
| 118 | {5, nullptr, "Unknown5"}, | ||
| 119 | {6, nullptr, "GetInterfaceStateChangeEvent"}, | ||
| 120 | {7, nullptr, "GetClientIfSession"}, | ||
| 121 | }; | ||
| 122 | // clang-format on | ||
| 123 | |||
| 124 | RegisterHandlers(functions); | ||
| 125 | } | ||
| 126 | }; | ||
| 127 | |||
| 128 | class IPdSession final : public ServiceFramework<IPdSession> { | ||
| 129 | public: | ||
| 130 | explicit IPdSession() : ServiceFramework{"IPdSession"} { | ||
| 131 | // clang-format off | ||
| 132 | static const FunctionInfo functions[] = { | ||
| 133 | {0, nullptr, "BindNoticeEvent"}, | ||
| 134 | {1, nullptr, "Unknown1"}, | ||
| 135 | {2, nullptr, "GetStatus"}, | ||
| 136 | {3, nullptr, "GetNotice"}, | ||
| 137 | {4, nullptr, "Unknown2"}, | ||
| 138 | {5, nullptr, "Unknown3"}, | ||
| 139 | {6, nullptr, "ReplyPowerRequest"}, | ||
| 140 | }; | ||
| 141 | // clang-format on | ||
| 142 | |||
| 143 | RegisterHandlers(functions); | ||
| 144 | } | ||
| 145 | }; | ||
| 146 | |||
| 147 | class USB_PD final : public ServiceFramework<USB_PD> { | ||
| 148 | public: | ||
| 149 | explicit USB_PD() : ServiceFramework{"usb:pd"} { | ||
| 150 | // clang-format off | ||
| 151 | static const FunctionInfo functions[] = { | ||
| 152 | {0, &USB_PD::GetPdSession, "GetPdSession"}, | ||
| 153 | }; | ||
| 154 | // clang-format on | ||
| 155 | |||
| 156 | RegisterHandlers(functions); | ||
| 157 | } | ||
| 158 | |||
| 159 | private: | ||
| 160 | void GetPdSession(Kernel::HLERequestContext& ctx) { | ||
| 161 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 162 | rb.Push(RESULT_SUCCESS); | ||
| 163 | rb.PushIpcInterface<IPdSession>(); | ||
| 164 | |||
| 165 | LOG_DEBUG(Service_USB, "called"); | ||
| 166 | } | ||
| 167 | }; | ||
| 168 | |||
| 169 | class IPdCradleSession final : public ServiceFramework<IPdCradleSession> { | ||
| 170 | public: | ||
| 171 | explicit IPdCradleSession() : ServiceFramework{"IPdCradleSession"} { | ||
| 172 | // clang-format off | ||
| 173 | static const FunctionInfo functions[] = { | ||
| 174 | {0, nullptr, "VdmUserWrite"}, | ||
| 175 | {1, nullptr, "VdmUserRead"}, | ||
| 176 | {2, nullptr, "Vdm20Init"}, | ||
| 177 | {3, nullptr, "GetFwType"}, | ||
| 178 | {4, nullptr, "GetFwRevision"}, | ||
| 179 | {5, nullptr, "GetManufacturerId"}, | ||
| 180 | {6, nullptr, "GetDeviceId"}, | ||
| 181 | {7, nullptr, "Unknown1"}, | ||
| 182 | {8, nullptr, "Unknown2"}, | ||
| 183 | }; | ||
| 184 | // clang-format on | ||
| 185 | |||
| 186 | RegisterHandlers(functions); | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | |||
| 190 | class USB_PD_C final : public ServiceFramework<USB_PD_C> { | ||
| 191 | public: | ||
| 192 | explicit USB_PD_C() : ServiceFramework{"usb:pd:c"} { | ||
| 193 | // clang-format off | ||
| 194 | static const FunctionInfo functions[] = { | ||
| 195 | {0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"}, | ||
| 196 | }; | ||
| 197 | // clang-format on | ||
| 198 | |||
| 199 | RegisterHandlers(functions); | ||
| 200 | } | ||
| 201 | |||
| 202 | private: | ||
| 203 | void GetPdCradleSession(Kernel::HLERequestContext& ctx) { | ||
| 204 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 205 | rb.Push(RESULT_SUCCESS); | ||
| 206 | rb.PushIpcInterface<IPdCradleSession>(); | ||
| 207 | |||
| 208 | LOG_DEBUG(Service_USB, "called"); | ||
| 209 | } | ||
| 210 | }; | ||
| 211 | |||
| 212 | class USB_PM final : public ServiceFramework<USB_PM> { | ||
| 213 | public: | ||
| 214 | explicit USB_PM() : ServiceFramework{"usb:pm"} { | ||
| 215 | // clang-format off | ||
| 216 | static const FunctionInfo functions[] = { | ||
| 217 | {0, nullptr, "Unknown1"}, | ||
| 218 | {1, nullptr, "Unknown2"}, | ||
| 219 | {2, nullptr, "Unknown3"}, | ||
| 220 | {3, nullptr, "Unknown4"}, | ||
| 221 | {4, nullptr, "Unknown5"}, | ||
| 222 | {5, nullptr, "Unknown6"}, | ||
| 223 | }; | ||
| 224 | // clang-format on | ||
| 225 | |||
| 226 | RegisterHandlers(functions); | ||
| 227 | } | ||
| 228 | }; | ||
| 229 | |||
| 230 | void InstallInterfaces(SM::ServiceManager& sm) { | ||
| 231 | std::make_shared<USB_DS>()->InstallAsService(sm); | ||
| 232 | std::make_shared<USB_HS>()->InstallAsService(sm); | ||
| 233 | std::make_shared<USB_PD>()->InstallAsService(sm); | ||
| 234 | std::make_shared<USB_PD_C>()->InstallAsService(sm); | ||
| 235 | std::make_shared<USB_PM>()->InstallAsService(sm); | ||
| 236 | } | ||
| 237 | |||
| 238 | } // namespace Service::USB | ||
diff --git a/src/core/hle/service/usb/usb.h b/src/core/hle/service/usb/usb.h new file mode 100644 index 000000000..970a11fe8 --- /dev/null +++ b/src/core/hle/service/usb/usb.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Service::SM { | ||
| 8 | class ServiceManager; | ||
| 9 | } | ||
| 10 | |||
| 11 | namespace Service::USB { | ||
| 12 | |||
| 13 | void InstallInterfaces(SM::ServiceManager& sm); | ||
| 14 | |||
| 15 | } // namespace Service::USB | ||