Merge branch 'threading'

This commit is contained in:
bunnei 2014-06-01 10:42:51 -04:00
commit f299e29c17
32 changed files with 729 additions and 234 deletions

View file

@ -259,14 +259,17 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
switch (Level) switch (Level)
{ {
case OS_LEVEL: // light yellow
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case NOTICE_LEVEL: // light green case NOTICE_LEVEL: // light green
Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break; break;
case ERROR_LEVEL: // light red case ERROR_LEVEL: // light red
Color = FOREGROUND_RED | FOREGROUND_INTENSITY; Color = FOREGROUND_RED | FOREGROUND_INTENSITY;
break; break;
case WARNING_LEVEL: // light yellow case WARNING_LEVEL: // light purple
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; Color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break; break;
case INFO_LEVEL: // cyan case INFO_LEVEL: // cyan
Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
@ -278,15 +281,8 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
break; break;
} }
if (strlen(Text) > 10)
{
// First 10 chars white
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
WriteConsole(hConsole, Text, 10, &cCharsWritten, NULL);
Text += 10;
}
SetConsoleTextAttribute(hConsole, Color); SetConsoleTextAttribute(hConsole, Color);
WriteConsole(hConsole, Text, (DWORD)strlen(Text), &cCharsWritten, NULL); printf(Text);
#else #else
char ColorAttr[16] = ""; char ColorAttr[16] = "";
char ResetAttr[16] = ""; char ResetAttr[16] = "";

View file

@ -7,11 +7,14 @@
#define LOGGING #define LOGGING
#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports. enum {
#define ERROR_LEVEL 2 // Critical errors OS_LEVEL, // Printed by the emulated operating system
#define WARNING_LEVEL 3 // Something is suspicious. NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
#define INFO_LEVEL 4 // General information. ERROR_LEVEL, // Critical errors
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. WARNING_LEVEL, // Something is suspicious.
INFO_LEVEL, // General information.
DEBUG_LEVEL, // Detailed debugging - might make things slow.
};
namespace LogTypes namespace LogTypes
{ {
@ -70,6 +73,7 @@ enum LOG_TYPE {
// FIXME: should this be removed? // FIXME: should this be removed?
enum LOG_LEVELS { enum LOG_LEVELS {
LOS = OS_LEVEL,
LNOTICE = NOTICE_LEVEL, LNOTICE = NOTICE_LEVEL,
LERROR = ERROR_LEVEL, LERROR = ERROR_LEVEL,
LWARNING = WARNING_LEVEL, LWARNING = WARNING_LEVEL,
@ -82,8 +86,8 @@ enum LOG_LEVELS {
} // namespace } // namespace
void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
const char *file, int line, const char *fmt, ...) const char* function, const char* fmt, ...)
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((format(printf, 5, 6))) __attribute__((format(printf, 5, 6)))
#endif #endif
@ -97,16 +101,19 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
#endif // loglevel #endif // loglevel
#endif // logging #endif // logging
#ifdef GEKKO #ifdef _WIN32
#define GENERIC_LOG(t, v, ...) #ifndef __func__
#else #define __func__ __FUNCTION__
#endif
#endif
// Let the compiler optimize this out // Let the compiler optimize this out
#define GENERIC_LOG(t, v, ...) { \ #define GENERIC_LOG(t, v, ...) { \
if (v <= MAX_LOGLEVEL) \ if (v <= MAX_LOGLEVEL) \
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \
} }
#endif
#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0)
#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0) #define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0)
#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0) #define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0)
#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0) #define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0)

View file

@ -10,14 +10,16 @@
#include "common/thread.h" #include "common/thread.h"
#include "common/file_util.h" #include "common/file_util.h"
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char *file, int line, const char* fmt, ...) const char* function, const char* fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
if (LogManager::GetInstance())
if (LogManager::GetInstance()) {
LogManager::GetInstance()->Log(level, type, LogManager::GetInstance()->Log(level, type,
file, line, fmt, args); file, line, function, fmt, args);
}
va_end(args); va_end(args);
} }
@ -88,6 +90,8 @@ LogManager::LogManager()
m_Log[i]->AddListener(m_debuggerLog); m_Log[i]->AddListener(m_debuggerLog);
#endif #endif
} }
m_consoleLog->Open();
} }
LogManager::~LogManager() LogManager::~LogManager()
@ -107,8 +111,8 @@ LogManager::~LogManager()
delete m_debuggerLog; delete m_debuggerLog;
} }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
const char *file, int line, const char *format, va_list args) int line, const char* function, const char *fmt, va_list args)
{ {
char temp[MAX_MSGLEN]; char temp[MAX_MSGLEN];
char msg[MAX_MSGLEN * 2]; char msg[MAX_MSGLEN * 2];
@ -117,17 +121,15 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
return; return;
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
static const char level_to_char[7] = "-NEWID"; static const char level_to_char[7] = "ONEWID";
sprintf(msg, "%s %s:%u %c[%s]: %s\n", sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line,
Common::Timer::GetTimeFormatted().c_str(), level_to_char[(int)level], log->GetShortName(), function, temp);
file, line, level_to_char[(int)level],
log->GetShortName(), temp);
#ifdef ANDROID #ifdef ANDROID
Host_SysMessage(msg); Host_SysMessage(msg);
#endif #endif
printf(msg); // TODO(ShizZy): RemoveMe when I no longer need this
log->Trigger(level, msg); log->Trigger(level, msg);
} }

View file

@ -99,8 +99,8 @@ public:
static u32 GetMaxLevel() { return MAX_LOGLEVEL; } static u32 GetMaxLevel() { return MAX_LOGLEVEL; }
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char *file, int line, const char *fmt, va_list args); const char* function, const char *fmt, va_list args);
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
{ {

View file

@ -34,12 +34,14 @@ set(SRCS core.cpp
hle/config_mem.cpp hle/config_mem.cpp
hle/coprocessor.cpp hle/coprocessor.cpp
hle/svc.cpp hle/svc.cpp
hle/kernel/event.cpp
hle/kernel/kernel.cpp hle/kernel/kernel.cpp
hle/kernel/mutex.cpp hle/kernel/mutex.cpp
hle/kernel/thread.cpp hle/kernel/thread.cpp
hle/service/apt.cpp hle/service/apt.cpp
hle/service/gsp.cpp hle/service/gsp.cpp
hle/service/hid.cpp hle/service/hid.cpp
hle/service/ndm.cpp
hle/service/service.cpp hle/service/service.cpp
hle/service/srv.cpp hle/service/srv.cpp
hw/hw.cpp hw/hw.cpp

View file

@ -4533,23 +4533,7 @@ ARMul_Emulate26 (ARMul_State * state)
case 0xfd: case 0xfd:
case 0xfe: case 0xfe:
case 0xff: case 0xff:
if (instr == ARMul_ABORTWORD
&& state->AbortAddr == pc) {
/* A prefetch abort. */
XScale_set_fsr_far (state,
ARMul_CP15_R5_MMU_EXCPT,
pc);
ARMul_Abort (state,
ARMul_PrefetchAbortV);
break;
}
//sky_pref_t* pref = get_skyeye_pref();
//if(pref->user_mode_sim){
// ARMul_OSHandleSWI (state, BITS (0, 23));
// break;
//}
HLE::CallSVC(instr); HLE::CallSVC(instr);
ARMul_Abort (state, ARMul_SWIV);
break; break;
} }
} }

View file

@ -9,6 +9,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/mem_map.h" #include "core/mem_map.h"
#include "core/hw/hw.h" #include "core/hw/hw.h"
#include "core/hw/lcd.h"
#include "core/arm/disassembler/arm_disasm.h" #include "core/arm/disassembler/arm_disasm.h"
#include "core/arm/interpreter/arm_interpreter.h" #include "core/arm/interpreter/arm_interpreter.h"
@ -23,7 +24,7 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core
/// Run the core CPU loop /// Run the core CPU loop
void RunLoop() { void RunLoop() {
for (;;){ for (;;){
g_app_core->Run(100); g_app_core->Run(LCD::kFrameTicks / 2);
HW::Update(); HW::Update();
Kernel::Reschedule(); Kernel::Reschedule();
} }
@ -31,9 +32,17 @@ void RunLoop() {
/// Step the CPU one instruction /// Step the CPU one instruction
void SingleStep() { void SingleStep() {
static int ticks = 0;
g_app_core->Step(); g_app_core->Step();
HW::Update();
Kernel::Reschedule(); if (ticks >= LCD::kFrameTicks / 2) {
HW::Update();
Kernel::Reschedule();
ticks = 0;
} else {
ticks++;
}
} }
/// Halt the core /// Halt the core

View file

@ -168,12 +168,14 @@
<ClCompile Include="hle\config_mem.cpp" /> <ClCompile Include="hle\config_mem.cpp" />
<ClCompile Include="hle\coprocessor.cpp" /> <ClCompile Include="hle\coprocessor.cpp" />
<ClCompile Include="hle\hle.cpp" /> <ClCompile Include="hle\hle.cpp" />
<ClCompile Include="hle\kernel\event.cpp" />
<ClCompile Include="hle\kernel\kernel.cpp" /> <ClCompile Include="hle\kernel\kernel.cpp" />
<ClCompile Include="hle\kernel\mutex.cpp" /> <ClCompile Include="hle\kernel\mutex.cpp" />
<ClCompile Include="hle\kernel\thread.cpp" /> <ClCompile Include="hle\kernel\thread.cpp" />
<ClCompile Include="hle\service\apt.cpp" /> <ClCompile Include="hle\service\apt.cpp" />
<ClCompile Include="hle\service\gsp.cpp" /> <ClCompile Include="hle\service\gsp.cpp" />
<ClCompile Include="hle\service\hid.cpp" /> <ClCompile Include="hle\service\hid.cpp" />
<ClCompile Include="hle\service\ndm.cpp" />
<ClCompile Include="hle\service\service.cpp" /> <ClCompile Include="hle\service\service.cpp" />
<ClCompile Include="hle\service\srv.cpp" /> <ClCompile Include="hle\service\srv.cpp" />
<ClCompile Include="hle\svc.cpp" /> <ClCompile Include="hle\svc.cpp" />
@ -217,12 +219,14 @@
<ClInclude Include="hle\coprocessor.h" /> <ClInclude Include="hle\coprocessor.h" />
<ClInclude Include="hle\function_wrappers.h" /> <ClInclude Include="hle\function_wrappers.h" />
<ClInclude Include="hle\hle.h" /> <ClInclude Include="hle\hle.h" />
<ClInclude Include="hle\kernel\event.h" />
<ClInclude Include="hle\kernel\kernel.h" /> <ClInclude Include="hle\kernel\kernel.h" />
<ClInclude Include="hle\kernel\mutex.h" /> <ClInclude Include="hle\kernel\mutex.h" />
<ClInclude Include="hle\kernel\thread.h" /> <ClInclude Include="hle\kernel\thread.h" />
<ClInclude Include="hle\service\apt.h" /> <ClInclude Include="hle\service\apt.h" />
<ClInclude Include="hle\service\gsp.h" /> <ClInclude Include="hle\service\gsp.h" />
<ClInclude Include="hle\service\hid.h" /> <ClInclude Include="hle\service\hid.h" />
<ClInclude Include="hle\service\ndm.h" />
<ClInclude Include="hle\service\service.h" /> <ClInclude Include="hle\service\service.h" />
<ClInclude Include="hle\service\srv.h" /> <ClInclude Include="hle\service\srv.h" />
<ClInclude Include="hle\svc.h" /> <ClInclude Include="hle\svc.h" />

View file

@ -165,6 +165,12 @@
<ClCompile Include="arm\interpreter\armcopro.cpp"> <ClCompile Include="arm\interpreter\armcopro.cpp">
<Filter>arm\interpreter</Filter> <Filter>arm\interpreter</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="hle\kernel\event.cpp">
<Filter>hle\kernel</Filter>
</ClCompile>
<ClCompile Include="hle\service\ndm.cpp">
<Filter>hle\service</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="arm\disassembler\arm_disasm.h"> <ClInclude Include="arm\disassembler\arm_disasm.h">
@ -295,6 +301,12 @@
<ClInclude Include="hle\kernel\mutex.h"> <ClInclude Include="hle\kernel\mutex.h">
<Filter>hle\kernel</Filter> <Filter>hle\kernel</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="hle\kernel\event.h">
<Filter>hle\kernel</Filter>
</ClInclude>
<ClInclude Include="hle\service\ndm.h">
<Filter>hle\service</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Text Include="CMakeLists.txt" /> <Text Include="CMakeLists.txt" />

View file

@ -55,7 +55,7 @@ inline void Read(T &var, const u32 addr) {
break; break;
default: default:
ERROR_LOG(HLE, "unknown ConfigMem::Read%d @ 0x%08X", sizeof(var) * 8, addr); ERROR_LOG(HLE, "unknown addr=0x%08X", addr);
} }
} }

View file

@ -627,6 +627,10 @@ template<void func(const char*)> void WrapV_C() {
func(Memory::GetCharPointer(PARAM(0))); func(Memory::GetCharPointer(PARAM(0)));
} }
template<void func(s64)> void WrapV_S64() {
func(((s64)PARAM(1) << 32) | PARAM(0));
}
template<void func(const char *, int)> void WrapV_CI() { template<void func(const char *, int)> void WrapV_CI() {
func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
} }
@ -735,11 +739,17 @@ template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){
} }
template<int func(u32, s64)> void WrapI_US64() { template<int func(u32, s64)> void WrapI_US64() {
int retval = func(PARAM(0), PARAM64(1)); int retval = func(PARAM(0), (((u64)PARAM(3) << 32) | PARAM(2)));
RETURN(retval); RETURN(retval);
} }
template<int func(void*, void*, u32, u32, s64)> void WrapI_VVUUS64() { template<int func(void*, void*, u32, u32, s64)> void WrapI_VVUUS64() {
int retval = func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); int retval = func(Memory::GetPointer(PARAM(5)), Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0)));
RETURN(retval);
}
// TODO(bunne): Is this correct? Probably not
template<int func(u32, u32, u32, u32, s64)> void WrapI_UUUUS64() {
int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0)));
RETURN(retval); RETURN(retval);
} }

View file

@ -18,7 +18,7 @@ static std::vector<ModuleDef> g_module_db;
const FunctionDef* GetSVCInfo(u32 opcode) { const FunctionDef* GetSVCInfo(u32 opcode) {
u32 func_num = opcode & 0xFFFFFF; // 8 bits u32 func_num = opcode & 0xFFFFFF; // 8 bits
if (func_num > 0xFF) { if (func_num > 0xFF) {
ERROR_LOG(HLE,"Unknown SVC: 0x%02X", func_num); ERROR_LOG(HLE,"unknown svc=0x%02X", func_num);
return NULL; return NULL;
} }
return &g_module_db[0].func_table[func_num]; return &g_module_db[0].func_table[func_num];
@ -33,7 +33,7 @@ void CallSVC(u32 opcode) {
if (info->func) { if (info->func) {
info->func(); info->func();
} else { } else {
ERROR_LOG(HLE, "Unimplemented SVC function %s(..)", info->name.c_str()); ERROR_LOG(HLE, "unimplemented SVC function %s(..)", info->name.c_str());
} }
} }
@ -43,7 +43,7 @@ void EatCycles(u32 cycles) {
void ReSchedule(const char *reason) { void ReSchedule(const char *reason) {
#ifdef _DEBUG #ifdef _DEBUG
_dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "ReSchedule: Invalid or too long reason."); _dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "Reschedule: Invalid or too long reason.");
#endif #endif
// TODO: ImplementMe // TODO: ImplementMe
} }

View file

@ -10,7 +10,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#define PARAM(n) Core::g_app_core->GetReg(n) #define PARAM(n) Core::g_app_core->GetReg(n)
#define PARAM64(n) (Core::g_app_core->GetReg(n) | ((u64)Core::g_app_core->GetReg(n + 1) << 32))
#define RETURN(n) Core::g_app_core->SetReg(0, n) #define RETURN(n) Core::g_app_core->SetReg(0, n)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -0,0 +1,126 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <map>
#include <vector>
#include "common/common.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/event.h"
namespace Kernel {
class Event : public Object {
public:
const char* GetTypeName() { return "Event"; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; }
ResetType intitial_reset_type; ///< ResetType specified at Event initialization
ResetType reset_type; ///< Current ResetType
bool locked; ///< Current locked state
bool permanent_locked; ///< Hack - to set event permanent state (for easy passthrough)
/**
* Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result SyncRequest(bool* wait) {
// TODO(bunnei): ImplementMe
ERROR_LOG(KERNEL, "(UMIMPLEMENTED) call");
return 0;
}
/**
* Wait for kernel object to synchronize
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result WaitSynchronization(bool* wait) {
// TODO(bunnei): ImplementMe
*wait = locked;
if (reset_type != RESETTYPE_STICKY && !permanent_locked) {
locked = true;
}
return 0;
}
};
/**
* Changes whether an event is locked or not
* @param handle Handle to event to change
* @param locked Boolean locked value to set event
* @return Result of operation, 0 on success, otherwise error code
*/
Result SetEventLocked(const Handle handle, const bool locked) {
Event* evt = g_object_pool.GetFast<Event>(handle);
if (!evt) {
ERROR_LOG(KERNEL, "called with unknown handle=0x%08X", handle);
return -1;
}
if (!evt->permanent_locked) {
evt->locked = locked;
}
return 0;
}
/**
* Hackish function to set an events permanent lock state, used to pass through synch blocks
* @param handle Handle to event to change
* @param permanent_locked Boolean permanent locked value to set event
* @return Result of operation, 0 on success, otherwise error code
*/
Result SetPermanentLock(Handle handle, const bool permanent_locked) {
Event* evt = g_object_pool.GetFast<Event>(handle);
if (!evt) {
ERROR_LOG(KERNEL, "called with unknown handle=0x%08X", handle);
return -1;
}
evt->permanent_locked = permanent_locked;
return 0;
}
/**
* Clears an event
* @param handle Handle to event to clear
* @return Result of operation, 0 on success, otherwise error code
*/
Result ClearEvent(Handle handle) {
return SetEventLocked(handle, true);
}
/**
* Creates an event
* @param handle Reference to handle for the newly created mutex
* @param reset_type ResetType describing how to create event
* @return Newly created Event object
*/
Event* CreateEvent(Handle& handle, const ResetType reset_type) {
Event* evt = new Event;
handle = Kernel::g_object_pool.Create(evt);
evt->locked = true;
evt->permanent_locked = false;
evt->reset_type = evt->intitial_reset_type = reset_type;
return evt;
}
/**
* Creates an event
* @param reset_type ResetType describing how to create event
* @return Handle to newly created Event object
*/
Handle CreateEvent(const ResetType reset_type) {
Handle handle;
Event* evt = CreateEvent(handle, reset_type);
return handle;
}
} // namespace

View file

@ -0,0 +1,44 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/svc.h"
namespace Kernel {
/**
* Changes whether an event is locked or not
* @param handle Handle to event to change
* @param locked Boolean locked value to set event
* @return Result of operation, 0 on success, otherwise error code
*/
Result SetEventLocked(const Handle handle, const bool locked);
/**
* Hackish function to set an events permanent lock state, used to pass through synch blocks
* @param handle Handle to event to change
* @param permanent_locked Boolean permanent locked value to set event
* @return Result of operation, 0 on success, otherwise error code
*/
Result SetPermanentLock(Handle handle, const bool permanent_locked);
/**
* Clears an event
* @param handle Handle to event to clear
* @return Result of operation, 0 on success, otherwise error code
*/
Result ClearEvent(Handle handle);
/**
* Creates an event
* @param reset_type ResetType describing how to create event
* @return Handle to newly created Event object
*/
Handle CreateEvent(const ResetType reset_type);
} // namespace

View file

@ -11,6 +11,11 @@ typedef s32 Result;
namespace Kernel { namespace Kernel {
enum KernelHandle {
CurrentThread = 0xFFFF8000,
CurrentProcess = 0xFFFF8001,
};
enum class HandleType : u32 { enum class HandleType : u32 {
Unknown = 0, Unknown = 0,
Port = 1, Port = 1,
@ -42,6 +47,21 @@ public:
virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; }
virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; }
virtual Kernel::HandleType GetHandleType() const = 0; virtual Kernel::HandleType GetHandleType() const = 0;
/**
* Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
virtual Result SyncRequest(bool* wait) = 0;
/**
* Wait for kernel object to synchronize
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
virtual Result WaitSynchronization(bool* wait) = 0;
}; };
class ObjectPool : NonCopyable { class ObjectPool : NonCopyable {

View file

@ -8,6 +8,7 @@
#include "common/common.h" #include "common/common.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
namespace Kernel { namespace Kernel {
@ -23,6 +24,28 @@ public:
bool locked; ///< Current locked state bool locked; ///< Current locked state
Handle lock_thread; ///< Handle to thread that currently has mutex Handle lock_thread; ///< Handle to thread that currently has mutex
std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex
/**
* Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result SyncRequest(bool* wait) {
// TODO(bunnei): ImplementMe
locked = true;
return 0;
}
/**
* Wait for kernel object to synchronize
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result WaitSynchronization(bool* wait) {
// TODO(bunnei): ImplementMe
*wait = locked;
return 0;
}
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -70,10 +93,11 @@ bool ReleaseMutexForThread(Mutex* mutex, Handle thread) {
bool ReleaseMutex(Mutex* mutex) { bool ReleaseMutex(Mutex* mutex) {
MutexEraseLock(mutex); MutexEraseLock(mutex);
bool woke_threads = false; bool woke_threads = false;
auto iter = mutex->waiting_threads.begin(); std::vector<Handle>::iterator iter;
// Find the next waiting thread for the mutex... // Find the next waiting thread for the mutex...
while (!woke_threads && !mutex->waiting_threads.empty()) { while (!woke_threads && !mutex->waiting_threads.empty()) {
iter = mutex->waiting_threads.begin();
woke_threads |= ReleaseMutexForThread(mutex, *iter); woke_threads |= ReleaseMutexForThread(mutex, *iter);
mutex->waiting_threads.erase(iter); mutex->waiting_threads.erase(iter);
} }
@ -91,6 +115,9 @@ bool ReleaseMutex(Mutex* mutex) {
*/ */
Result ReleaseMutex(Handle handle) { Result ReleaseMutex(Handle handle) {
Mutex* mutex = Kernel::g_object_pool.GetFast<Mutex>(handle); Mutex* mutex = Kernel::g_object_pool.GetFast<Mutex>(handle);
_assert_msg_(KERNEL, mutex, "ReleaseMutex tried to release a NULL mutex!");
if (!ReleaseMutex(mutex)) { if (!ReleaseMutex(mutex)) {
return -1; return -1;
} }
@ -101,6 +128,7 @@ Result ReleaseMutex(Handle handle) {
* Creates a mutex * Creates a mutex
* @param handle Reference to handle for the newly created mutex * @param handle Reference to handle for the newly created mutex
* @param initial_locked Specifies if the mutex should be locked initially * @param initial_locked Specifies if the mutex should be locked initially
* @return Pointer to new Mutex object
*/ */
Mutex* CreateMutex(Handle& handle, bool initial_locked) { Mutex* CreateMutex(Handle& handle, bool initial_locked) {
Mutex* mutex = new Mutex; Mutex* mutex = new Mutex;

View file

@ -13,13 +13,14 @@ namespace Kernel {
/** /**
* Releases a mutex * Releases a mutex
* @param handle Handle to mutex to release * @param handle Handle to mutex to release
* @return Result of operation, 0 on success, otherwise error code
*/ */
Result ReleaseMutex(Handle handle); Result ReleaseMutex(Handle handle);
/** /**
* Creates a mutex * Creates a mutex
* @param handle Reference to handle for the newly created mutex
* @param initial_locked Specifies if the mutex should be locked initially * @param initial_locked Specifies if the mutex should be locked initially
* @return Handle to newly created object
*/ */
Handle CreateMutex(bool initial_locked); Handle CreateMutex(bool initial_locked);

View file

@ -36,6 +36,26 @@ public:
inline bool IsWaiting() const { return (status & THREADSTATUS_WAIT) != 0; } inline bool IsWaiting() const { return (status & THREADSTATUS_WAIT) != 0; }
inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; }
/**
* Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result SyncRequest(bool* wait) {
// TODO(bunnei): ImplementMe
return 0;
}
/**
* Wait for kernel object to synchronize
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result WaitSynchronization(bool* wait) {
// TODO(bunnei): ImplementMe
return 0;
}
ThreadContext context; ThreadContext context;
u32 status; u32 status;
@ -303,11 +323,29 @@ void Reschedule() {
Thread* prev = GetCurrentThread(); Thread* prev = GetCurrentThread();
Thread* next = NextThread(); Thread* next = NextThread();
if (next > 0) { if (next > 0) {
INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
SwitchContext(next); SwitchContext(next);
// Hack - automatically change previous thread (which would have been in "wait" state) to // Hack - automatically change previous thread (which would have been in "wait" state) to
// "ready" state, so that we can immediately resume to it when new thread yields. FixMe to // "ready" state, so that we can immediately resume to it when new thread yields. FixMe to
// actually wait for whatever event it is supposed to be waiting on. // actually wait for whatever event it is supposed to be waiting on.
ChangeReadyState(prev, true);
} else {
INFO_LOG(KERNEL, "no ready threads, staying on 0x%08X", prev->GetHandle());
// Hack - no other threads are available, so decrement current PC to the last instruction,
// and then resume current thread. This should always be called on a blocking instruction
// (e.g. svcWaitSynchronization), and the result should be that the instruction is repeated
// until it no longer blocks.
// TODO(bunnei): A better solution: Have the CPU switch to an idle thread
ThreadContext ctx;
SaveContext(ctx);
ctx.pc -= 4;
LoadContext(ctx);
ChangeReadyState(prev, true); ChangeReadyState(prev, true);
} }
} }

View file

@ -6,6 +6,7 @@
#include "common/common.h" #include "common/common.h"
#include "core/hle/hle.h" #include "core/hle/hle.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/mutex.h" #include "core/hle/kernel/mutex.h"
#include "core/hle/service/apt.h" #include "core/hle/service/apt.h"
@ -15,7 +16,16 @@
namespace APT_U { namespace APT_U {
void Initialize(Service::Interface* self) { void Initialize(Service::Interface* self) {
NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); u32* cmd_buff = Service::GetCommandBuffer();
DEBUG_LOG(KERNEL, "called");
cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT); // APT menu event handle
cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT); // APT pause event handle
Kernel::SetEventLocked(cmd_buff[3], true);
Kernel::SetEventLocked(cmd_buff[4], false); // Fire start event
cmd_buff[1] = 0; // No error
} }
void GetLockHandle(Service::Interface* self) { void GetLockHandle(Service::Interface* self) {
@ -23,88 +33,103 @@ void GetLockHandle(Service::Interface* self) {
u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field
cmd_buff[1] = 0; // No error cmd_buff[1] = 0; // No error
cmd_buff[5] = Kernel::CreateMutex(false); cmd_buff[5] = Kernel::CreateMutex(false);
DEBUG_LOG(KERNEL, "APT_U::GetLockHandle called : created handle 0x%08X", cmd_buff[5]); DEBUG_LOG(KERNEL, "called handle=0x%08X", cmd_buff[5]);
}
void Enable(Service::Interface* self) {
u32* cmd_buff = Service::GetCommandBuffer();
u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for?
cmd_buff[1] = 0; // No error
ERROR_LOG(KERNEL, "(UNIMPEMENTED) called unk=0x%08X", unk);
}
void InquireNotification(Service::Interface* self) {
u32* cmd_buff = Service::GetCommandBuffer();
u32 app_id = cmd_buff[2];
cmd_buff[1] = 0; // No error
cmd_buff[3] = 0; // Signal type
ERROR_LOG(KERNEL, "(UNIMPEMENTED) called app_id=0x%08X", app_id);
} }
const Interface::FunctionInfo FunctionTable[] = { const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle"}, {0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"}, {0x00020080, Initialize, "Initialize"},
{0x00030040, NULL, "Enable"}, {0x00030040, Enable, "Enable"},
{0x00040040, NULL, "Finalize"}, {0x00040040, NULL, "Finalize"},
{0x00050040, NULL, "GetAppletManInfo"}, {0x00050040, NULL, "GetAppletManInfo"},
{0x00060040, NULL, "GetAppletInfo"}, {0x00060040, NULL, "GetAppletInfo"},
{0x00070000, NULL, "GetLastSignaledAppletId"}, {0x00070000, NULL, "GetLastSignaledAppletId"},
{0x00080000, NULL, "CountRegisteredApplet"}, {0x00080000, NULL, "CountRegisteredApplet"},
{0x00090040, NULL, "IsRegistered"}, {0x00090040, NULL, "IsRegistered"},
{0x000A0040, NULL, "GetAttribute"}, {0x000A0040, NULL, "GetAttribute"},
{0x000B0040, NULL, "InquireNotification"}, {0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, NULL, "SendParameter"}, {0x000C0104, NULL, "SendParameter"},
{0x000D0080, NULL, "ReceiveParameter"}, {0x000D0080, NULL, "ReceiveParameter"},
{0x000E0080, NULL, "GlanceParameter"}, {0x000E0080, NULL, "GlanceParameter"},
{0x000F0100, NULL, "CancelParameter"}, {0x000F0100, NULL, "CancelParameter"},
{0x001000C2, NULL, "DebugFunc"}, {0x001000C2, NULL, "DebugFunc"},
{0x001100C0, NULL, "MapProgramIdForDebug"}, {0x001100C0, NULL, "MapProgramIdForDebug"},
{0x00120040, NULL, "SetHomeMenuAppletIdForDebug"}, {0x00120040, NULL, "SetHomeMenuAppletIdForDebug"},
{0x00130000, NULL, "GetPreparationState"}, {0x00130000, NULL, "GetPreparationState"},
{0x00140040, NULL, "SetPreparationState"}, {0x00140040, NULL, "SetPreparationState"},
{0x00150140, NULL, "PrepareToStartApplication"}, {0x00150140, NULL, "PrepareToStartApplication"},
{0x00160040, NULL, "PreloadLibraryApplet"}, {0x00160040, NULL, "PreloadLibraryApplet"},
{0x00170040, NULL, "FinishPreloadingLibraryApplet"}, {0x00170040, NULL, "FinishPreloadingLibraryApplet"},
{0x00180040, NULL, "PrepareToStartLibraryApplet"}, {0x00180040, NULL, "PrepareToStartLibraryApplet"},
{0x00190040, NULL, "PrepareToStartSystemApplet"}, {0x00190040, NULL, "PrepareToStartSystemApplet"},
{0x001A0000, NULL, "PrepareToStartNewestHomeMenu"}, {0x001A0000, NULL, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, NULL, "StartApplication"}, {0x001B00C4, NULL, "StartApplication"},
{0x001C0000, NULL, "WakeupApplication"}, {0x001C0000, NULL, "WakeupApplication"},
{0x001D0000, NULL, "CancelApplication"}, {0x001D0000, NULL, "CancelApplication"},
{0x001E0084, NULL, "StartLibraryApplet"}, {0x001E0084, NULL, "StartLibraryApplet"},
{0x001F0084, NULL, "StartSystemApplet"}, {0x001F0084, NULL, "StartSystemApplet"},
{0x00200044, NULL, "StartNewestHomeMenu"}, {0x00200044, NULL, "StartNewestHomeMenu"},
{0x00210000, NULL, "OrderToCloseApplication"}, {0x00210000, NULL, "OrderToCloseApplication"},
{0x00220040, NULL, "PrepareToCloseApplication"}, {0x00220040, NULL, "PrepareToCloseApplication"},
{0x00230040, NULL, "PrepareToJumpToApplication"}, {0x00230040, NULL, "PrepareToJumpToApplication"},
{0x00240044, NULL, "JumpToApplication"}, {0x00240044, NULL, "JumpToApplication"},
{0x002500C0, NULL, "PrepareToCloseLibraryApplet"}, {0x002500C0, NULL, "PrepareToCloseLibraryApplet"},
{0x00260000, NULL, "PrepareToCloseSystemApplet"}, {0x00260000, NULL, "PrepareToCloseSystemApplet"},
{0x00270044, NULL, "CloseApplication"}, {0x00270044, NULL, "CloseApplication"},
{0x00280044, NULL, "CloseLibraryApplet"}, {0x00280044, NULL, "CloseLibraryApplet"},
{0x00290044, NULL, "CloseSystemApplet"}, {0x00290044, NULL, "CloseSystemApplet"},
{0x002A0000, NULL, "OrderToCloseSystemApplet"}, {0x002A0000, NULL, "OrderToCloseSystemApplet"},
{0x002B0000, NULL, "PrepareToJumpToHomeMenu"}, {0x002B0000, NULL, "PrepareToJumpToHomeMenu"},
{0x002C0044, NULL, "JumpToHomeMenu"}, {0x002C0044, NULL, "JumpToHomeMenu"},
{0x002D0000, NULL, "PrepareToLeaveHomeMenu"}, {0x002D0000, NULL, "PrepareToLeaveHomeMenu"},
{0x002E0044, NULL, "LeaveHomeMenu"}, {0x002E0044, NULL, "LeaveHomeMenu"},
{0x002F0040, NULL, "PrepareToLeaveResidentApplet"}, {0x002F0040, NULL, "PrepareToLeaveResidentApplet"},
{0x00300044, NULL, "LeaveResidentApplet"}, {0x00300044, NULL, "LeaveResidentApplet"},
{0x00310100, NULL, "PrepareToDoApplicationJump"}, {0x00310100, NULL, "PrepareToDoApplicationJump"},
{0x00320084, NULL, "DoApplicationJump"}, {0x00320084, NULL, "DoApplicationJump"},
{0x00330000, NULL, "GetProgramIdOnApplicationJump"}, {0x00330000, NULL, "GetProgramIdOnApplicationJump"},
{0x00340084, NULL, "SendDeliverArg"}, {0x00340084, NULL, "SendDeliverArg"},
{0x00350080, NULL, "ReceiveDeliverArg"}, {0x00350080, NULL, "ReceiveDeliverArg"},
{0x00360040, NULL, "LoadSysMenuArg"}, {0x00360040, NULL, "LoadSysMenuArg"},
{0x00370042, NULL, "StoreSysMenuArg"}, {0x00370042, NULL, "StoreSysMenuArg"},
{0x00380040, NULL, "PreloadResidentApplet"}, {0x00380040, NULL, "PreloadResidentApplet"},
{0x00390040, NULL, "PrepareToStartResidentApplet"}, {0x00390040, NULL, "PrepareToStartResidentApplet"},
{0x003A0044, NULL, "StartResidentApplet"}, {0x003A0044, NULL, "StartResidentApplet"},
{0x003B0040, NULL, "CancelLibraryApplet"}, {0x003B0040, NULL, "CancelLibraryApplet"},
{0x003C0042, NULL, "SendDspSleep"}, {0x003C0042, NULL, "SendDspSleep"},
{0x003D0042, NULL, "SendDspWakeUp"}, {0x003D0042, NULL, "SendDspWakeUp"},
{0x003E0080, NULL, "ReplySleepQuery"}, {0x003E0080, NULL, "ReplySleepQuery"},
{0x003F0040, NULL, "ReplySleepNotificationComplete"}, {0x003F0040, NULL, "ReplySleepNotificationComplete"},
{0x00400042, NULL, "SendCaptureBufferInfo"}, {0x00400042, NULL, "SendCaptureBufferInfo"},
{0x00410040, NULL, "ReceiveCaptureBufferInfo"}, {0x00410040, NULL, "ReceiveCaptureBufferInfo"},
{0x00420080, NULL, "SleepSystem"}, {0x00420080, NULL, "SleepSystem"},
{0x00430040, NULL, "NotifyToWait"}, {0x00430040, NULL, "NotifyToWait"},
{0x00440000, NULL, "GetSharedFont"}, {0x00440000, NULL, "GetSharedFont"},
{0x00450040, NULL, "GetWirelessRebootInfo"}, {0x00450040, NULL, "GetWirelessRebootInfo"},
{0x00460104, NULL, "Wrap"}, {0x00460104, NULL, "Wrap"},
{0x00470104, NULL, "Unwrap"}, {0x00470104, NULL, "Unwrap"},
{0x00480100, NULL, "GetProgramInfo"}, {0x00480100, NULL, "GetProgramInfo"},
{0x00490180, NULL, "Reboot"}, {0x00490180, NULL, "Reboot"},
{0x004A0040, NULL, "GetCaptureInfo"}, {0x004A0040, NULL, "GetCaptureInfo"},
{0x004B00C2, NULL, "AppletUtility"}, {0x004B00C2, NULL, "AppletUtility"},
{0x004C0000, NULL, "SetFatalErrDispMode"}, {0x004C0000, NULL, "SetFatalErrDispMode"},
{0x004D0080, NULL, "GetAppletProgramInfo"}, {0x004D0080, NULL, "GetAppletProgramInfo"},
{0x004E0000, NULL, "HardwareResetAsync"}, {0x004E0000, NULL, "HardwareResetAsync"},
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -8,6 +8,7 @@
#include "core/mem_map.h" #include "core/mem_map.h"
#include "core/hle/hle.h" #include "core/hle/hle.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/gsp.h" #include "core/hle/service/gsp.h"
#include "core/hw/lcd.h" #include "core/hw/lcd.h"
@ -52,6 +53,7 @@ void GX_FinishCommand(u32 thread_id) {
namespace GSP_GPU { namespace GSP_GPU {
Handle g_event_handle = 0;
u32 g_thread_id = 0; u32 g_thread_id = 0;
enum { enum {
@ -92,7 +94,7 @@ void ReadHWRegs(Service::Interface* self) {
break; break;
default: default:
ERROR_LOG(GSP, "ReadHWRegs unknown register read at address %08X", reg_addr); ERROR_LOG(GSP, "unknown register read at address %08X", reg_addr);
} }
} }
@ -100,7 +102,20 @@ void ReadHWRegs(Service::Interface* self) {
void RegisterInterruptRelayQueue(Service::Interface* self) { void RegisterInterruptRelayQueue(Service::Interface* self) {
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
u32 flags = cmd_buff[1]; u32 flags = cmd_buff[1];
u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling u32 event_handle = cmd_buff[3];
_assert_msg_(GSP, event_handle, "called, but event is NULL!");
g_event_handle = event_handle;
Kernel::SetEventLocked(event_handle, false);
// Hack - This function will permanently set the state of the GSP event such that GPU command
// synchronization barriers always passthrough. Correct solution would be to set this after the
// GPU as processed all queued up commands, but due to the emulator being single-threaded they
// will always be ready.
Kernel::SetPermanentLock(event_handle, true);
cmd_buff[2] = g_thread_id; // ThreadID cmd_buff[2] = g_thread_id; // ThreadID
} }
@ -117,7 +132,7 @@ void TriggerCmdReqQueue(Service::Interface* self) {
break; break;
default: default:
ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]); ERROR_LOG(GSP, "unknown command 0x%08X", cmd_buff[0]);
} }
GX_FinishCommand(g_thread_id); GX_FinishCommand(g_thread_id);

View file

@ -0,0 +1,32 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "common/log.h"
#include "core/hle/hle.h"
#include "core/hle/service/ndm.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace NDM_U
namespace NDM_U {
const Interface::FunctionInfo FunctionTable[] = {
{0x00060040, NULL, "SuspendDaemons"},
{0x00080040, NULL, "DisableWifiUsage"},
{0x00090000, NULL, "EnableWifiUsage"},
{0x00140040, NULL, "OverrideDefaultDaemons"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class
Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable));
}
Interface::~Interface() {
}
} // namespace

View file

@ -0,0 +1,33 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace NDM
// No idea what this is
namespace NDM_U {
class Interface : public Service::Interface {
public:
Interface();
~Interface();
/**
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
const char *GetPortName() const {
return "ndm:u";
}
};
} // namespace

View file

@ -12,6 +12,7 @@
#include "core/hle/service/apt.h" #include "core/hle/service/apt.h"
#include "core/hle/service/gsp.h" #include "core/hle/service/gsp.h"
#include "core/hle/service/hid.h" #include "core/hle/service/hid.h"
#include "core/hle/service/ndm.h"
#include "core/hle/service/srv.h" #include "core/hle/service/srv.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
@ -72,14 +73,15 @@ void Init() {
g_manager->AddService(new APT_U::Interface); g_manager->AddService(new APT_U::Interface);
g_manager->AddService(new GSP_GPU::Interface); g_manager->AddService(new GSP_GPU::Interface);
g_manager->AddService(new HID_User::Interface); g_manager->AddService(new HID_User::Interface);
g_manager->AddService(new NDM_U::Interface);
NOTICE_LOG(HLE, "Services initialized OK"); NOTICE_LOG(HLE, "initialized OK");
} }
/// Shutdown ServiceManager /// Shutdown ServiceManager
void Shutdown() { void Shutdown() {
delete g_manager; delete g_manager;
NOTICE_LOG(HLE, "Services shutdown OK"); NOTICE_LOG(HLE, "shutdown OK");
} }

View file

@ -76,22 +76,31 @@ public:
} }
/** /**
* Called when svcSendSyncRequest is called, loads command buffer and executes comand * Synchronize kernel object
* @return Return result of svcSendSyncRequest passed back to user app * @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/ */
Result Sync() { Result SyncRequest(bool* wait) {
u32* cmd_buff = GetCommandBuffer(); u32* cmd_buff = GetCommandBuffer();
auto itr = m_functions.find(cmd_buff[0]); auto itr = m_functions.find(cmd_buff[0]);
if (itr == m_functions.end()) { if (itr == m_functions.end()) {
ERROR_LOG(OSHLE, "Unknown/unimplemented function: port = %s, command = 0x%08X!", ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X",
GetPortName(), cmd_buff[0]); GetPortName(), cmd_buff[0]);
return -1;
// TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[1] = 0;
return 0;
} }
if (itr->second.func == NULL) { if (itr->second.func == NULL) {
ERROR_LOG(OSHLE, "Unimplemented function: port = %s, name = %s!", ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s",
GetPortName(), itr->second.name.c_str()); GetPortName(), itr->second.name.c_str());
return -1;
// TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[1] = 0;
return 0;
} }
itr->second.func(this); itr->second.func(this);
@ -99,6 +108,16 @@ public:
return 0; // TODO: Implement return from actual function return 0; // TODO: Implement return from actual function
} }
/**
* Wait for kernel object to synchronize
* @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code
*/
Result WaitSynchronization(bool* wait) {
// TODO(bunnei): ImplementMe
return 0;
}
protected: protected:
/** /**

View file

@ -5,21 +5,28 @@
#include "core/hle/hle.h" #include "core/hle/hle.h"
#include "core/hle/service/srv.h" #include "core/hle/service/srv.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/kernel/mutex.h"
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SRV // Namespace SRV
namespace SRV { namespace SRV {
Handle g_mutex = 0;
void Initialize(Service::Interface* self) { void Initialize(Service::Interface* self) {
NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); DEBUG_LOG(OSHLE, "called");
if (!g_mutex) {
g_mutex = Kernel::CreateMutex(false);
}
} }
void GetProcSemaphore(Service::Interface* self) { void GetProcSemaphore(Service::Interface* self) {
DEBUG_LOG(OSHLE, "called");
// Get process semaphore? // Get process semaphore?
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[3] = 0xDEADBEEF; // Return something... 0 == NULL, raises an exception cmd_buff[1] = 0; // No error
cmd_buff[3] = g_mutex; // Return something... 0 == NULL, raises an exception
} }
void GetServiceHandle(Service::Interface* self) { void GetServiceHandle(Service::Interface* self) {
@ -29,18 +36,14 @@ void GetServiceHandle(Service::Interface* self) {
std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize);
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(),
service->GetHandle());
if (NULL != service) { if (NULL != service) {
cmd_buff[3] = service->GetHandle(); cmd_buff[3] = service->GetHandle();
DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
} else { } else {
ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str()); ERROR_LOG(OSHLE, "(UNIMPLEMENTED) called port=%s", port_name.c_str());
res = -1; res = -1;
} }
cmd_buff[1] = res; cmd_buff[1] = res;
//return res;
} }
const Interface::FunctionInfo FunctionTable[] = { const Interface::FunctionInfo FunctionTable[] = {

View file

@ -26,12 +26,6 @@ public:
return "srv:"; return "srv:";
} }
/**
* Called when svcSendSyncRequest is called, loads command buffer and executes comand
* @return Return result of svcSendSyncRequest passed back to user app
*/
Result Sync();
}; };
} // namespace } // namespace

View file

@ -9,6 +9,7 @@
#include "core/mem_map.h" #include "core/mem_map.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/mutex.h" #include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
@ -16,7 +17,6 @@
#include "core/hle/function_wrappers.h" #include "core/hle/function_wrappers.h"
#include "core/hle/svc.h" #include "core/hle/svc.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/kernel/thread.h"
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SVC // Namespace SVC
@ -35,10 +35,9 @@ enum MapMemoryPermission {
/// Map application or GSP heap memory /// Map application or GSP heap memory
Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
u32* outaddr = (u32*)_outaddr;
u32 virtual_address = 0x00000000; u32 virtual_address = 0x00000000;
DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
operation, addr0, addr1, size, permissions); operation, addr0, addr1, size, permissions);
switch (operation) { switch (operation) {
@ -55,11 +54,9 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si
// Unknown ControlMemory operation // Unknown ControlMemory operation
default: default:
ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation); ERROR_LOG(SVC, "unknown operation=0x%08X", operation);
}
if (NULL != outaddr) {
*outaddr = virtual_address;
} }
Core::g_app_core->SetReg(1, virtual_address); Core::g_app_core->SetReg(1, virtual_address);
return 0; return 0;
@ -67,7 +64,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si
/// Maps a memory block to specified address /// Maps a memory block to specified address
Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) { Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) {
DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", DEBUG_LOG(SVC, "called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
memblock, addr, mypermissions, otherpermission); memblock, addr, mypermissions, otherpermission);
switch (mypermissions) { switch (mypermissions) {
case MEMORY_PERMISSION_NORMAL: case MEMORY_PERMISSION_NORMAL:
@ -76,72 +73,139 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper
Memory::MapBlock_Shared(memblock, addr, mypermissions); Memory::MapBlock_Shared(memblock, addr, mypermissions);
break; break;
default: default:
ERROR_LOG(OSHLE, "MapMemoryBlock unknown permissions=0x%08X", mypermissions); ERROR_LOG(OSHLE, "unknown permissions=0x%08X", mypermissions);
} }
return 0; return 0;
} }
/// 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);
if (service) { DEBUG_LOG(SVC, "called port_name=%s", port_name);
Core::g_app_core->SetReg(1, service->GetHandle()); _assert_msg_(KERNEL, service, "called, but service is not implemented!");
} else { Core::g_app_core->SetReg(1, service->GetHandle());
PanicYesNo("ConnectToPort called port_name=%s, but it is not implemented!", port_name);
}
DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name);
return 0; return 0;
} }
/// Synchronize to an OS service /// Synchronize to an OS service
Result SendSyncRequest(Handle handle) { Result SendSyncRequest(Handle handle) {
DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); bool wait = false;
Service::Interface* service = Service::g_manager->FetchFromHandle(handle); Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
service->Sync();
return 0; DEBUG_LOG(SVC, "called handle=0x%08X", handle);
_assert_msg_(KERNEL, object, "called, but kernel object is NULL!");
Result res = object->SyncRequest(&wait);
if (wait) {
Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct?
}
return res;
} }
/// Close a handle /// Close a handle
Result CloseHandle(Handle handle) { Result CloseHandle(Handle handle) {
// ImplementMe // ImplementMe
DEBUG_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle); ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle);
return 0; return 0;
} }
/// Wait for a handle to synchronize, timeout after the specified nanoseconds /// Wait for a handle to synchronize, timeout after the specified nanoseconds
Result WaitSynchronization1(Handle handle, s64 nano_seconds) { Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronization1 called handle=0x%08X, nanoseconds=%d", // TODO(bunnei): Do something with nano_seconds, currently ignoring this
handle, nano_seconds); bool wait = false;
Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct?
return 0; Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
DEBUG_LOG(SVC, "called handle=0x%08X, nanoseconds=%d", handle,
nano_seconds);
_assert_msg_(KERNEL, object, "called, but kernel object is NULL!");
Result res = object->WaitSynchronization(&wait);
if (wait) {
Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct?
Kernel::Reschedule();
// Context switch - Function blocked, is not actually returning (will be "called" again)
// TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch
// (otherwise R0 will be set to whatever is returned, and handle will be invalid when this
// thread is resumed). There is probably a better way of keeping track of state so that we
// don't necessarily have to do this.
return (Result)PARAM(0);
}
return res;
} }
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds /// Wait for the given handles to synchronize, timeout after the specified nanoseconds
Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wait_all, s64 nano_seconds) { Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wait_all,
s32* out = (s32*)_out; s64 nano_seconds) {
Handle* handles = (Handle*)_handles; // TODO(bunnei): Do something with nano_seconds, currently ignoring this
DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronizationN called handle_count=%d, wait_all=%s, nanoseconds=%d %s", Handle* handles = (Handle*)_handles;
bool unlock_all = true;
DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%d",
handle_count, (wait_all ? "true" : "false"), nano_seconds); handle_count, (wait_all ? "true" : "false"), nano_seconds);
// Iterate through each handle, synchronize kernel object
for (u32 i = 0; i < handle_count; i++) { for (u32 i = 0; i < handle_count; i++) {
DEBUG_LOG(SVC, "\thandle[%d]=0x%08X", i, handles[i]); bool wait = false;
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handles[i]); // 0 handle
_assert_msg_(KERNEL, object, "called handle=0x%08X, but kernel object "
"is NULL!", handles[i]);
DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X", i, handles[i]);
Result res = object->WaitSynchronization(&wait);
if (!wait && !wait_all) {
Core::g_app_core->SetReg(1, i);
return 0;
} else {
unlock_all = false;
}
} }
if (wait_all && unlock_all) {
Core::g_app_core->SetReg(1, handle_count);
return 0;
}
// Set current thread to wait state if not all handles were unlocked
Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct?
return 0; Kernel::Reschedule();
// Context switch - Function blocked, is not actually returning (will be "called" again)
// TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch
// (otherwise R0 will be set to whatever is returned, and handle will be invalid when this
// thread is resumed). There is probably a better way of keeping track of state so that we
// don't necessarily have to do this.
return (Result)PARAM(0);
} }
/// Create an address arbiter (to allocate access to shared resources) /// Create an address arbiter (to allocate access to shared resources)
Result CreateAddressArbiter(void* arbiter) { Result CreateAddressArbiter(void* arbiter) {
// ImplementMe ERROR_LOG(SVC, "(UNIMPLEMENTED) called");
DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called");
Core::g_app_core->SetReg(1, 0xFABBDADD); Core::g_app_core->SetReg(1, 0xFABBDADD);
return 0; return 0;
} }
/// Arbitrate address
Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nanoseconds) {
ERROR_LOG(SVC, "(UNIMPLEMENTED) called");
ArbitrationType type = (ArbitrationType)_type;
Memory::Write32(addr, type);
return 0;
}
/// Used to output a message on a debug hardware unit - does nothing on a retail unit /// Used to output a message on a debug hardware unit - does nothing on a retail unit
void OutputDebugString(const char* string) { void OutputDebugString(const char* string) {
NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string); OS_LOG(SVC, "%s", string);
} }
/// Get resource limit /// Get resource limit
@ -149,15 +213,15 @@ Result GetResourceLimit(void* resource_limit, Handle process) {
// With regards to proceess values: // With regards to proceess values:
// 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
// the current KThread. // the current KThread.
DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process); ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
Core::g_app_core->SetReg(1, 0xDEADBEEF); Core::g_app_core->SetReg(1, 0xDEADBEEF);
return 0; return 0;
} }
/// Get resource limit current values /// Get resource limit current values
Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names,
//s64* values = (s64*)_values; s32 name_count) {
DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d",
resource_limit, names, name_count); resource_limit, names, name_count);
Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
return 0; return 0;
@ -180,8 +244,8 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
Core::g_app_core->SetReg(1, thread); Core::g_app_core->SetReg(1, thread);
DEBUG_LOG(SVC, "CreateThread called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
"threadpriority=0x%08X, processorid=0x%08X : created handle 0x%08X", entry_point, "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
name.c_str(), arg, stack_top, priority, processor_id, thread); name.c_str(), arg, stack_top, priority, processor_id, thread);
return 0; return 0;
@ -189,43 +253,61 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
/// Create a mutex /// Create a mutex
Result CreateMutex(void* _mutex, u32 initial_locked) { Result CreateMutex(void* _mutex, u32 initial_locked) {
Handle* mutex = (Handle*)_mutex; Handle mutex = Kernel::CreateMutex((initial_locked != 0));
*mutex = Kernel::CreateMutex((initial_locked != 0)); Core::g_app_core->SetReg(1, mutex);
Core::g_app_core->SetReg(1, *mutex); DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X",
DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle 0x%08X", initial_locked ? "true" : "false", mutex);
initial_locked ? "true" : "false", *mutex);
return 0; return 0;
} }
/// Release a mutex /// Release a mutex
Result ReleaseMutex(Handle handle) { Result ReleaseMutex(Handle handle) {
DEBUG_LOG(SVC, "ReleaseMutex called handle=0x%08X", handle); DEBUG_LOG(SVC, "called handle=0x%08X", handle);
_assert_msg_(KERNEL, handle, "called, but handle is NULL!");
Kernel::ReleaseMutex(handle); Kernel::ReleaseMutex(handle);
return 0; return 0;
} }
/// Get current thread ID /// Get current thread ID
Result GetThreadId(void* thread_id, u32 thread) { Result GetThreadId(void* thread_id, u32 thread) {
DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetThreadId called thread=0x%08X", thread); ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread);
return 0; return 0;
} }
/// Query memory /// Query memory
Result QueryMemory(void *_info, void *_out, u32 addr) { Result QueryMemory(void *_info, void *_out, u32 addr) {
MemoryInfo* info = (MemoryInfo*) _info; ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr);
PageInfo* out = (PageInfo*) _out;
DEBUG_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr);
return 0; return 0;
} }
/// Create an event /// Create an event
Result CreateEvent(void* _event, u32 reset_type) { Result CreateEvent(void* _event, u32 reset_type) {
Handle* event = (Handle*)_event; Handle evt = Kernel::CreateEvent((ResetType)reset_type);
DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateEvent called reset_type=0x%08X", reset_type); Core::g_app_core->SetReg(1, evt);
Core::g_app_core->SetReg(1, 0xBADC0DE0); DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X",
reset_type, evt);
return 0; return 0;
} }
/// Duplicates a kernel handle
Result DuplicateHandle(void* _out, Handle handle) {
Handle* out = (Handle*)_out;
ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle);
return 0;
}
/// Clears an event
Result ClearEvent(Handle evt) {
Result res = Kernel::ClearEvent(evt);
DEBUG_LOG(SVC, "called event=0x%08X", evt);
return res;
}
/// Sleep the current thread
void SleepThread(s64 nanoseconds) {
DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds);
}
const HLE::FunctionDef SVC_Table[] = { const HLE::FunctionDef SVC_Table[] = {
{0x00, NULL, "Unknown"}, {0x00, NULL, "Unknown"},
{0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"},
@ -237,7 +319,7 @@ const HLE::FunctionDef SVC_Table[] = {
{0x07, NULL, "SetProcessIdealProcessor"}, {0x07, NULL, "SetProcessIdealProcessor"},
{0x08, WrapI_UUUUU<CreateThread>, "CreateThread"}, {0x08, WrapI_UUUUU<CreateThread>, "CreateThread"},
{0x09, NULL, "ExitThread"}, {0x09, NULL, "ExitThread"},
{0x0A, NULL, "SleepThread"}, {0x0A, WrapV_S64<SleepThread>, "SleepThread"},
{0x0B, NULL, "GetThreadPriority"}, {0x0B, NULL, "GetThreadPriority"},
{0x0C, NULL, "SetThreadPriority"}, {0x0C, NULL, "SetThreadPriority"},
{0x0D, NULL, "GetThreadAffinityMask"}, {0x0D, NULL, "GetThreadAffinityMask"},
@ -252,7 +334,7 @@ const HLE::FunctionDef SVC_Table[] = {
{0x16, NULL, "ReleaseSemaphore"}, {0x16, NULL, "ReleaseSemaphore"},
{0x17, WrapI_VU<CreateEvent>, "CreateEvent"}, {0x17, WrapI_VU<CreateEvent>, "CreateEvent"},
{0x18, NULL, "SignalEvent"}, {0x18, NULL, "SignalEvent"},
{0x19, NULL, "ClearEvent"}, {0x19, WrapI_U<ClearEvent>, "ClearEvent"},
{0x1A, NULL, "CreateTimer"}, {0x1A, NULL, "CreateTimer"},
{0x1B, NULL, "SetTimer"}, {0x1B, NULL, "SetTimer"},
{0x1C, NULL, "CancelTimer"}, {0x1C, NULL, "CancelTimer"},
@ -261,12 +343,12 @@ const HLE::FunctionDef SVC_Table[] = {
{0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"},
{0x20, NULL, "UnmapMemoryBlock"}, {0x20, NULL, "UnmapMemoryBlock"},
{0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"}, {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"},
{0x22, NULL, "ArbitrateAddress"}, {0x22, WrapI_UUUUS64<ArbitrateAddress>, "ArbitrateAddress"},
{0x23, WrapI_U<CloseHandle>, "CloseHandle"}, {0x23, WrapI_U<CloseHandle>, "CloseHandle"},
{0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"},
{0x25, WrapI_VVUUS64<WaitSynchronizationN>, "WaitSynchronizationN"}, {0x25, WrapI_VVUUS64<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, NULL, "SignalAndWait"}, {0x26, NULL, "SignalAndWait"},
{0x27, NULL, "DuplicateHandle"}, {0x27, WrapI_VU<DuplicateHandle>, "DuplicateHandle"},
{0x28, NULL, "GetSystemTick"}, {0x28, NULL, "GetSystemTick"},
{0x29, NULL, "GetHandleInfo"}, {0x29, NULL, "GetHandleInfo"},
{0x2A, NULL, "GetSystemInfo"}, {0x2A, NULL, "GetSystemInfo"},

View file

@ -38,6 +38,15 @@ enum ResetType {
RESETTYPE_MAX_BIT = (1u << 31), RESETTYPE_MAX_BIT = (1u << 31),
}; };
enum ArbitrationType {
ARBITRATIONTYPE_SIGNAL,
ARBITRATIONTYPE_WAIT_IF_LESS_THAN,
ARBITRATIONTYPE_DECREMENT_AND_WAIT_IF_LESS_THAN,
ARBITRATIONTYPE_WAIT_IF_LESS_THAN_WITH_TIMEOUT,
ARBITRATIONTYPE_DECREMENT_AND_WAIT_IF_LESS_THAN_WITH_TIMEOUT,
ARBITRATIONTYPE_MAX_BIT = (1u << 31)
};
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SVC // Namespace SVC

View file

@ -17,8 +17,6 @@ namespace LCD {
Registers g_regs; Registers g_regs;
static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second
u64 g_last_ticks = 0; ///< Last CPU ticks u64 g_last_ticks = 0; ///< Last CPU ticks
/** /**

View file

@ -8,6 +8,8 @@
namespace LCD { namespace LCD {
static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second
struct Registers { struct Registers {
u32 framebuffer_top_left_1; u32 framebuffer_top_left_1;
u32 framebuffer_top_left_2; u32 framebuffer_top_left_2;

View file

@ -86,7 +86,7 @@ inline void _Read(T &var, const u32 addr) {
var = *((const T*)&g_vram[vaddr & VRAM_MASK]); var = *((const T*)&g_vram[vaddr & VRAM_MASK]);
} else { } else {
//_assert_msg_(MEMMAP, false, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr); ERROR_LOG(MEMMAP, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr);
} }
} }
@ -136,8 +136,7 @@ inline void _Write(u32 addr, const T data) {
// Error out... // Error out...
} else { } else {
_assert_msg_(MEMMAP, false, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, ERROR_LOG(MEMMAP, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, vaddr);
data, vaddr);
} }
} }