citra-emu
/
citra
Archived
1
0
Fork 0

Service: Clean-up Interface

This commit is contained in:
Yuri Kunde Schlesner 2015-01-30 16:56:49 -02:00
parent 8779b31fe6
commit a79d21c83e
46 changed files with 54 additions and 67 deletions

View File

@ -53,7 +53,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace ACT_U {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace AM_APP {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -38,7 +38,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace AM_SYS {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -39,7 +39,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -117,7 +117,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -520,7 +520,7 @@ Interface::Interface() {
lock = Kernel::Mutex::Create(false, "APT_U:Lock").MoveFrom(); lock = Kernel::Mutex::Create(false, "APT_U:Lock").MoveFrom();
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace BOSS_P {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace CAM_U {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace CECD_S {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace CECD_U {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -104,7 +104,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -92,7 +92,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -186,7 +186,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -29,7 +29,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -206,7 +206,7 @@ Interface::Interface() {
interrupt_event = nullptr; interrupt_event = nullptr;
read_pipe_count = 0; read_pipe_count = 0;
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -18,7 +18,7 @@ namespace FRD_A {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -591,7 +591,7 @@ const FSUserInterface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
FSUserInterface::FSUserInterface() { FSUserInterface::FSUserInterface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace FS } // namespace FS

View File

@ -389,7 +389,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
g_interrupt_event = 0; g_interrupt_event = 0;
g_shared_memory = 0; g_shared_memory = 0;

View File

@ -20,7 +20,7 @@ namespace GSP_LCD {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
//Register(FunctionTable, ARRAY_SIZE(FunctionTable)); //Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -32,7 +32,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -72,7 +72,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -58,7 +58,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -36,7 +36,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -34,7 +34,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -24,7 +24,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -19,7 +19,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -25,7 +25,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -21,7 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -26,7 +26,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -26,7 +26,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -50,7 +50,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -137,7 +137,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
// Create the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file // Create the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file
// TODO(Subv): In the future we should use the FS service to query this archive // TODO(Subv): In the future we should use the FS service to query this archive
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);

View File

@ -5,11 +5,12 @@
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <map>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <boost/container/flat_map.hpp>
#include "common/common.h" #include "common/common.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/mem_map.h" #include "core/mem_map.h"
@ -69,21 +70,6 @@ public:
return "[UNKNOWN SERVICE PORT]"; return "[UNKNOWN SERVICE PORT]";
} }
/// Allocates a new handle for the service
Handle CreateHandle(Kernel::Object *obj) {
// TODO(yuriks): Fix error reporting
Handle handle = Kernel::g_handle_table.Create(obj).ValueOr(INVALID_HANDLE);
m_handles.push_back(handle);
return handle;
}
/// Frees a handle from the service
template <class T>
void DeleteHandle(const Handle handle) {
Kernel::g_handle_table.Close(handle);
m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());
}
ResultVal<bool> SyncRequest() override { ResultVal<bool> SyncRequest() override {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
auto itr = m_functions.find(cmd_buff[0]); auto itr = m_functions.find(cmd_buff[0]);
@ -109,16 +95,17 @@ protected:
/** /**
* Registers the functions in the service * Registers the functions in the service
*/ */
void Register(const FunctionInfo* functions, int len) { template <size_t N>
for (int i = 0; i < len; i++) { void Register(const FunctionInfo (&functions)[N]) {
m_functions[functions[i].id] = functions[i]; m_functions.reserve(N);
for (auto& fn : functions) {
// Usually this array is sorted by id already, so hint to instead at the end
m_functions.emplace_hint(m_functions.cend(), fn.id, fn);
} }
} }
private: private:
boost::container::flat_map<u32, FunctionInfo> m_functions;
std::vector<Handle> m_handles;
std::map<u32, FunctionInfo> m_functions;
}; };

View File

@ -734,7 +734,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
Interface::~Interface() { Interface::~Interface() {

View File

@ -63,7 +63,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -22,7 +22,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace

View File

@ -54,7 +54,7 @@ const Interface::FunctionInfo FunctionTable[] = {
// Interface class // Interface class
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable);
} }
} // namespace } // namespace