yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

renamed "UID" to "Handle" where appropriate

This commit is contained in:
bunnei 2014-05-18 18:24:24 -04:00
parent 772abad778
commit 725d240bf7
4 changed files with 22 additions and 24 deletions

View File

@ -32,27 +32,27 @@ Manager::~Manager() {
/// Add a service to the manager (does not create it though) /// Add a service to the manager (does not create it though)
void Manager::AddService(Interface* service) { void Manager::AddService(Interface* service) {
int index = m_services.size(); int index = m_services.size();
u32 new_uid = GetUIDFromIndex(index); Handle handle = GetHandleFromIndex(index);
m_services.push_back(service); m_services.push_back(service);
m_port_map[service->GetPortName()] = new_uid; m_port_map[service->GetPortName()] = handle;
service->m_uid = new_uid; service->m_handle = handle;
} }
/// Removes a service from the manager, also frees memory /// Removes a service from the manager, also frees memory
void Manager::DeleteService(std::string port_name) { void Manager::DeleteService(std::string port_name) {
auto service = FetchFromPortName(port_name); auto service = FetchFromPortName(port_name);
m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); m_services.erase(m_services.begin() + GetIndexFromHandle(service->m_handle));
m_port_map.erase(port_name); m_port_map.erase(port_name);
delete service; delete service;
} }
/// Get a Service Interface from its UID /// Get a Service Interface from its Handle
Interface* Manager::FetchFromUID(u32 uid) { Interface* Manager::FetchFromHandle(Handle handle) {
int index = GetIndexFromUID(uid); int index = GetIndexFromHandle(handle);
if (index < (int)m_services.size()) { if (index < (int)m_services.size()) {
return m_services[index]; return m_services[index];
} }
@ -65,7 +65,7 @@ Interface* Manager::FetchFromPortName(std::string port_name) {
if (itr == m_port_map.end()) { if (itr == m_port_map.end()) {
return NULL; return NULL;
} }
return FetchFromUID(itr->second); return FetchFromHandle(itr->second);
} }

View File

@ -20,8 +20,6 @@
namespace Service { namespace Service {
typedef s32 NativeUID; ///< Native handle for a service
static const int kMaxPortSize = 0x08; ///< Maximum size of a port name (8 characters) static const int kMaxPortSize = 0x08; ///< Maximum size of a port name (8 characters)
static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header
@ -56,11 +54,11 @@ public:
}; };
/** /**
* Gets the UID for the serice * Gets the Handle for the serice
* @return UID of service in native format * @return Handle of service in native format
*/ */
NativeUID GetUID() const { Handle GetHandle() const {
return (NativeUID)m_uid; return m_handle;
} }
/** /**
@ -73,7 +71,7 @@ public:
/// Allocates a new handle for the service /// Allocates a new handle for the service
Handle NewHandle() { Handle NewHandle() {
Handle handle = (m_handles.size() << 16) | m_uid; Handle handle = (m_handles.size() << 16) | m_handle;
m_handles.push_back(handle); m_handles.push_back(handle);
return handle; return handle;
} }
@ -124,7 +122,7 @@ protected:
} }
private: private:
u32 m_uid; u32 m_handle;
std::vector<Handle> m_handles; std::vector<Handle> m_handles;
std::map<u32, FunctionInfo> m_functions; std::map<u32, FunctionInfo> m_functions;
@ -145,7 +143,7 @@ public:
void DeleteService(std::string port_name); void DeleteService(std::string port_name);
/// Get a Service Interface from its UID /// Get a Service Interface from its UID
Interface* FetchFromUID(u32 uid); Interface* FetchFromHandle(u32 uid);
/// Get a Service Interface from its port /// Get a Service Interface from its port
Interface* FetchFromPortName(std::string port_name); Interface* FetchFromPortName(std::string port_name);
@ -153,13 +151,13 @@ public:
private: private:
/// Convert an index into m_services vector into a UID /// Convert an index into m_services vector into a UID
static u32 GetUIDFromIndex(const int index) { static Handle GetHandleFromIndex(const int index) {
return index | 0x10000000; return index | 0x10000000;
} }
/// Convert a UID into an index into m_services /// Convert a UID into an index into m_services
static int GetIndexFromUID(const u32 uid) { static int GetIndexFromHandle(const Handle handle) {
return uid & 0x0FFFFFFF; return handle & 0x0FFFFFFF;
} }
std::vector<Interface*> m_services; std::vector<Interface*> m_services;

View File

@ -30,10 +30,10 @@ void GetServiceHandle(Service::Interface* self) {
Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name.c_str(), NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name.c_str(),
service->GetUID()); service->GetHandle());
if (NULL != service) { if (NULL != service) {
cmd_buff[3] = service->GetUID(); cmd_buff[3] = service->GetHandle();
} else { } else {
ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str()); ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str());
res = -1; res = -1;

View File

@ -83,7 +83,7 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper
/// Connect to an OS service given the port name, returns the handle to the port to out /// Connect to an OS service given the port name, returns the handle to the port to out
Result ConnectToPort(void* out, const char* port_name) { Result ConnectToPort(void* out, const char* port_name) {
Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
Core::g_app_core->SetReg(1, service->GetUID()); Core::g_app_core->SetReg(1, service->GetHandle());
DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name);
return 0; return 0;
} }
@ -91,7 +91,7 @@ Result ConnectToPort(void* out, const char* port_name) {
/// Synchronize to an OS service /// Synchronize to an OS service
Result SendSyncRequest(Handle session) { Result SendSyncRequest(Handle session) {
DEBUG_LOG(SVC, "SendSyncRequest called session=0x%08X"); DEBUG_LOG(SVC, "SendSyncRequest called session=0x%08X");
Service::Interface* service = Service::g_manager->FetchFromUID(session); Service::Interface* service = Service::g_manager->FetchFromHandle(session);
service->Sync(); service->Sync();
return 0; return 0;
} }