diff options
| author | 2014-04-12 21:55:36 -0400 | |
|---|---|---|
| committer | 2014-04-12 21:55:36 -0400 | |
| commit | 68e198476f17a026fed88f3c9a271aa768694354 (patch) | |
| tree | c8b368e45afd8fd70c69ce7be7e28879eda8d8aa /src/core/hle/service/service.cpp | |
| parent | hacked CPU interpreter to ignore branch on SVC instruction (as we are HLEing ... (diff) | |
| download | yuzu-68e198476f17a026fed88f3c9a271aa768694354.tar.gz yuzu-68e198476f17a026fed88f3c9a271aa768694354.tar.xz yuzu-68e198476f17a026fed88f3c9a271aa768694354.zip | |
- added HLE to connect to "srv:" service
- added a manager for keeping track of services/ports
- added a memory mapped region for memory accessed by HLE
- added HLE for GetThreadCommandBuffer function
Diffstat (limited to 'src/core/hle/service/service.cpp')
| -rw-r--r-- | src/core/hle/service/service.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp new file mode 100644 index 000000000..4bc96cc18 --- /dev/null +++ b/src/core/hle/service/service.cpp | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common.h" | ||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace Service | ||
| 12 | |||
| 13 | namespace Service { | ||
| 14 | |||
| 15 | Manager* g_manager = NULL; ///< Service manager | ||
| 16 | |||
| 17 | Manager::Manager() { | ||
| 18 | } | ||
| 19 | |||
| 20 | Manager::~Manager() { | ||
| 21 | for(Interface* service : m_services) { | ||
| 22 | DeleteService(service->GetPortName()); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | /// Add a service to the manager (does not create it though) | ||
| 27 | void Manager::AddService(Interface* service) { | ||
| 28 | int index = m_services.size(); | ||
| 29 | u32 new_uid = GetUIDFromIndex(index); | ||
| 30 | |||
| 31 | m_services.push_back(service); | ||
| 32 | |||
| 33 | m_port_map[service->GetPortName()] = new_uid; | ||
| 34 | service->m_uid = new_uid; | ||
| 35 | } | ||
| 36 | |||
| 37 | /// Removes a service from the manager, also frees memory | ||
| 38 | void Manager::DeleteService(std::string port_name) { | ||
| 39 | auto service = FetchFromPortName(port_name); | ||
| 40 | |||
| 41 | m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); | ||
| 42 | m_port_map.erase(port_name); | ||
| 43 | |||
| 44 | delete service; | ||
| 45 | } | ||
| 46 | |||
| 47 | /// Get a Service Interface from its UID | ||
| 48 | Interface* Manager::FetchFromUID(u32 uid) { | ||
| 49 | int index = GetIndexFromUID(uid); | ||
| 50 | if (index < (int)m_services.size()) { | ||
| 51 | return m_services[index]; | ||
| 52 | } | ||
| 53 | return NULL; | ||
| 54 | } | ||
| 55 | |||
| 56 | /// Get a Service Interface from its port | ||
| 57 | Interface* Manager::FetchFromPortName(std::string port_name) { | ||
| 58 | auto itr = m_port_map.find(port_name); | ||
| 59 | if (itr == m_port_map.end()) { | ||
| 60 | return NULL; | ||
| 61 | } | ||
| 62 | return FetchFromUID(itr->second); | ||
| 63 | } | ||
| 64 | |||
| 65 | class Interface_SRV : public Interface { | ||
| 66 | public: | ||
| 67 | |||
| 68 | Interface_SRV() { | ||
| 69 | } | ||
| 70 | |||
| 71 | ~Interface_SRV() { | ||
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 75 | * Gets the string name used by CTROS for a service | ||
| 76 | * @return String name of service | ||
| 77 | */ | ||
| 78 | std::string GetName() { | ||
| 79 | return "ServiceManager"; | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * Gets the string name used by CTROS for a service | ||
| 84 | * @return Port name of service | ||
| 85 | */ | ||
| 86 | std::string GetPortName() { | ||
| 87 | return "srv:"; | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 92 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 93 | */ | ||
| 94 | Syscall::Result Sync() { | ||
| 95 | ERROR_LOG(HLE, "Unimplemented function ServiceManager::Sync"); | ||
| 96 | return -1; | ||
| 97 | } | ||
| 98 | |||
| 99 | }; | ||
| 100 | |||
| 101 | /// Initialize ServiceManager | ||
| 102 | void Init() { | ||
| 103 | g_manager = new Manager; | ||
| 104 | g_manager->AddService(new Interface_SRV); | ||
| 105 | NOTICE_LOG(HLE, "ServiceManager initialized OK"); | ||
| 106 | } | ||
| 107 | |||
| 108 | /// Shutdown ServiceManager | ||
| 109 | void Shutdown() { | ||
| 110 | delete g_manager; | ||
| 111 | NOTICE_LOG(HLE, "ServiceManager shutdown OK"); | ||
| 112 | } | ||
| 113 | |||
| 114 | |||
| 115 | } | ||