2014-04-11 07:00:00 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-13 07:25:36 +05:30
|
|
|
#include "core/mem_map.h"
|
2014-04-11 07:00:00 +05:30
|
|
|
#include "core/hle/hle.h"
|
2014-04-12 04:14:21 +05:30
|
|
|
#include "core/hle/syscall.h"
|
2014-04-13 07:25:36 +05:30
|
|
|
#include "core/hle/service/service.h"
|
2014-04-11 07:00:00 +05:30
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace HLE {
|
|
|
|
|
2014-04-11 07:45:07 +05:30
|
|
|
static std::vector<ModuleDef> g_module_db;
|
2014-04-11 07:00:00 +05:30
|
|
|
|
2014-04-11 08:56:12 +05:30
|
|
|
const FunctionDef* GetSyscallInfo(u32 opcode) {
|
|
|
|
u32 func_num = opcode & 0xFFFFFF; // 8 bits
|
|
|
|
if (func_num > 0xFF) {
|
|
|
|
ERROR_LOG(HLE,"Unknown syscall: 0x%02X", func_num);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return &g_module_db[0].func_table[func_num];
|
|
|
|
}
|
|
|
|
|
|
|
|
void CallSyscall(u32 opcode) {
|
|
|
|
const FunctionDef *info = GetSyscallInfo(opcode);
|
|
|
|
|
|
|
|
if (!info) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (info->func) {
|
|
|
|
info->func();
|
|
|
|
} else {
|
2014-04-17 06:11:33 +05:30
|
|
|
ERROR_LOG(HLE, "Unimplemented SysCall function %s(..)", info->name.c_str());
|
2014-04-11 08:56:12 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-15 06:19:02 +05:30
|
|
|
void EatCycles(u32 cycles) {
|
|
|
|
// TODO: ImplementMe
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReSchedule(const char *reason) {
|
|
|
|
#ifdef _DEBUG
|
|
|
|
_dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "ReSchedule: Invalid or too long reason.");
|
|
|
|
#endif
|
|
|
|
// TODO: ImplementMe
|
|
|
|
}
|
|
|
|
|
2014-04-11 07:45:07 +05:30
|
|
|
void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) {
|
|
|
|
ModuleDef module = {name, num_functions, func_table};
|
2014-04-11 07:00:00 +05:30
|
|
|
g_module_db.push_back(module);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegisterAllModules() {
|
2014-04-12 04:14:21 +05:30
|
|
|
Syscall::Register();
|
2014-04-11 07:00:00 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void Init() {
|
2014-04-13 07:25:36 +05:30
|
|
|
Service::Init();
|
|
|
|
|
2014-04-11 07:00:00 +05:30
|
|
|
RegisterAllModules();
|
2014-04-13 07:25:36 +05:30
|
|
|
|
2014-04-11 08:56:12 +05:30
|
|
|
NOTICE_LOG(HLE, "initialized OK");
|
2014-04-11 07:00:00 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown() {
|
2014-04-13 09:01:39 +05:30
|
|
|
Service::Shutdown();
|
|
|
|
|
2014-04-11 08:56:12 +05:30
|
|
|
g_module_db.clear();
|
2014-04-13 09:01:39 +05:30
|
|
|
|
2014-04-11 08:56:12 +05:30
|
|
|
NOTICE_LOG(HLE, "shutdown OK");
|
2014-04-11 07:00:00 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|