diff options
Diffstat (limited to 'src/core/hle/service/service.cpp')
| -rw-r--r-- | src/core/hle/service/service.cpp | 84 |
1 files changed, 4 insertions, 80 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 44c7c8627..799dbe90e 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -4,10 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/common.h" | 5 | #include "common/common.h" |
| 6 | #include "common/log.h" | 6 | #include "common/log.h" |
| 7 | #include "common/string_util.h" | ||
| 7 | 8 | ||
| 8 | #include "core/hle/hle.h" | 9 | #include "core/hle/hle.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | #include "core/hle/service/apt.h" | 11 | #include "core/hle/service/apt.h" |
| 12 | #include "core/hle/service/srv.h" | ||
| 11 | 13 | ||
| 12 | namespace Service { | 14 | namespace Service { |
| 13 | 15 | ||
| @@ -64,84 +66,6 @@ Interface* Manager::FetchFromPortName(std::string port_name) { | |||
| 64 | return FetchFromUID(itr->second); | 66 | return FetchFromUID(itr->second); |
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 68 | // Interface to "SRV" service | ||
| 69 | |||
| 70 | class SRV : public Interface { | ||
| 71 | |||
| 72 | public: | ||
| 73 | |||
| 74 | SRV() { | ||
| 75 | } | ||
| 76 | |||
| 77 | ~SRV() { | ||
| 78 | } | ||
| 79 | |||
| 80 | enum { | ||
| 81 | CMD_OFFSET = 0x80, | ||
| 82 | CMD_HEADER_INIT = 0x10002, ///< Command header to initialize SRV service | ||
| 83 | CMD_HEADER_GET_HANDLE = 0x50100, ///< Command header to get handle of other services | ||
| 84 | }; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * Gets the string name used by CTROS for a service | ||
| 88 | * @return String name of service | ||
| 89 | */ | ||
| 90 | std::string GetName() const { | ||
| 91 | return "ServiceManager"; | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Gets the string name used by CTROS for a service | ||
| 96 | * @return Port name of service | ||
| 97 | */ | ||
| 98 | std::string GetPortName() const { | ||
| 99 | return "srv:"; | ||
| 100 | } | ||
| 101 | |||
| 102 | /** | ||
| 103 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 104 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 105 | */ | ||
| 106 | Syscall::Result Sync() { | ||
| 107 | Syscall::Result res = 0; | ||
| 108 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + CMD_OFFSET); | ||
| 109 | |||
| 110 | switch (cmd_buff[0]) { | ||
| 111 | |||
| 112 | case CMD_HEADER_INIT: | ||
| 113 | NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); | ||
| 114 | break; | ||
| 115 | |||
| 116 | case CMD_HEADER_GET_HANDLE: | ||
| 117 | { | ||
| 118 | const char* port_name = (const char*)&cmd_buff[1]; | ||
| 119 | Interface* service = g_manager->FetchFromPortName(port_name); | ||
| 120 | |||
| 121 | NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name, | ||
| 122 | service->GetUID()); | ||
| 123 | |||
| 124 | if (NULL != service) { | ||
| 125 | cmd_buff[3] = service->GetUID(); | ||
| 126 | } else { | ||
| 127 | ERROR_LOG(OSHLE, "Service %s does not exist", port_name); | ||
| 128 | res = -1; | ||
| 129 | } | ||
| 130 | break; | ||
| 131 | } | ||
| 132 | |||
| 133 | default: | ||
| 134 | ERROR_LOG(OSHLE, "SRV::Sync - Unknown command 0x%08X", cmd_buff[0]); | ||
| 135 | res = -1; | ||
| 136 | break; | ||
| 137 | } | ||
| 138 | |||
| 139 | cmd_buff[1] = res; | ||
| 140 | |||
| 141 | return res; | ||
| 142 | } | ||
| 143 | |||
| 144 | }; | ||
| 145 | 69 | ||
| 146 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 70 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 147 | // Module interface | 71 | // Module interface |
| @@ -149,8 +73,8 @@ public: | |||
| 149 | /// Initialize ServiceManager | 73 | /// Initialize ServiceManager |
| 150 | void Init() { | 74 | void Init() { |
| 151 | g_manager = new Manager; | 75 | g_manager = new Manager; |
| 152 | g_manager->AddService(new SRV); | 76 | g_manager->AddService(new SRV::Interface); |
| 153 | g_manager->AddService(new APT); | 77 | g_manager->AddService(new APT_U); |
| 154 | NOTICE_LOG(HLE, "Services initialized OK"); | 78 | NOTICE_LOG(HLE, "Services initialized OK"); |
| 155 | } | 79 | } |
| 156 | 80 | ||