citra-emu
/
citra
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)
void Manager::AddService(Interface* service) {
int index = m_services.size();
u32 new_uid = GetUIDFromIndex(index);
Handle handle = GetHandleFromIndex(index);
m_services.push_back(service);
m_port_map[service->GetPortName()] = new_uid;
service->m_uid = new_uid;
m_port_map[service->GetPortName()] = handle;
service->m_handle = handle;
}
/// Removes a service from the manager, also frees memory
void Manager::DeleteService(std::string 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);
delete service;
}
/// Get a Service Interface from its UID
Interface* Manager::FetchFromUID(u32 uid) {
int index = GetIndexFromUID(uid);
/// Get a Service Interface from its Handle
Interface* Manager::FetchFromHandle(Handle handle) {
int index = GetIndexFromHandle(handle);
if (index < (int)m_services.size()) {
return m_services[index];
}
@ -65,7 +65,7 @@ Interface* Manager::FetchFromPortName(std::string port_name) {
if (itr == m_port_map.end()) {
return NULL;
}
return FetchFromUID(itr->second);
return FetchFromHandle(itr->second);
}

View File

@ -20,8 +20,6 @@
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 kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header
@ -56,11 +54,11 @@ public:
};
/**
* Gets the UID for the serice
* @return UID of service in native format
* Gets the Handle for the serice
* @return Handle of service in native format
*/
NativeUID GetUID() const {
return (NativeUID)m_uid;
Handle GetHandle() const {
return m_handle;
}
/**
@ -73,7 +71,7 @@ public:
/// Allocates a new handle for the service
Handle NewHandle() {
Handle handle = (m_handles.size() << 16) | m_uid;
Handle handle = (m_handles.size() << 16) | m_handle;
m_handles.push_back(handle);
return handle;
}
@ -124,7 +122,7 @@ protected:
}
private:
u32 m_uid;
u32 m_handle;
std::vector<Handle> m_handles;
std::map<u32, FunctionInfo> m_functions;
@ -145,7 +143,7 @@ public:
void DeleteService(std::string port_name);
/// Get a Service Interface from its UID
Interface* FetchFromUID(u32 uid);
Interface* FetchFromHandle(u32 uid);
/// Get a Service Interface from its port
Interface* FetchFromPortName(std::string port_name);
@ -153,13 +151,13 @@ public:
private:
/// 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;
}
/// Convert a UID into an index into m_services
static int GetIndexFromUID(const u32 uid) {
return uid & 0x0FFFFFFF;
static int GetIndexFromHandle(const Handle handle) {
return handle & 0x0FFFFFFF;
}
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);
NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name.c_str(),
service->GetUID());
service->GetHandle());
if (NULL != service) {
cmd_buff[3] = service->GetUID();
cmd_buff[3] = service->GetHandle();
} else {
ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str());
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
Result ConnectToPort(void* out, const char* 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);
return 0;
}
@ -91,7 +91,7 @@ Result ConnectToPort(void* out, const char* port_name) {
/// Synchronize to an OS service
Result SendSyncRequest(Handle session) {
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();
return 0;
}