mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-24 18:10:04 +00:00
svc: added optional name field to Event and Mutex (used for debugging)
This commit is contained in:
parent
8c0f02a70c
commit
b78aff8585
@ -15,6 +15,7 @@ namespace Kernel {
|
||||
class Event : public Object {
|
||||
public:
|
||||
const char* GetTypeName() { return "Event"; }
|
||||
const char* GetName() { return name.c_str(); }
|
||||
|
||||
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; }
|
||||
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; }
|
||||
@ -24,6 +25,7 @@ public:
|
||||
|
||||
bool locked; ///< Current locked state
|
||||
bool permanent_locked; ///< Hack - to set event permanent state (for easy passthrough)
|
||||
std::string name; ///< Name of event (optional)
|
||||
|
||||
/**
|
||||
* Synchronize kernel object
|
||||
@ -98,9 +100,10 @@ Result ClearEvent(Handle handle) {
|
||||
* Creates an event
|
||||
* @param handle Reference to handle for the newly created mutex
|
||||
* @param reset_type ResetType describing how to create event
|
||||
* @param name Optional name of event
|
||||
* @return Newly created Event object
|
||||
*/
|
||||
Event* CreateEvent(Handle& handle, const ResetType reset_type) {
|
||||
Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string name) {
|
||||
Event* evt = new Event;
|
||||
|
||||
handle = Kernel::g_object_pool.Create(evt);
|
||||
@ -108,6 +111,7 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type) {
|
||||
evt->locked = true;
|
||||
evt->permanent_locked = false;
|
||||
evt->reset_type = evt->intitial_reset_type = reset_type;
|
||||
evt->name = name;
|
||||
|
||||
return evt;
|
||||
}
|
||||
@ -115,11 +119,12 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type) {
|
||||
/**
|
||||
* Creates an event
|
||||
* @param reset_type ResetType describing how to create event
|
||||
* @param name Optional name of event
|
||||
* @return Handle to newly created Event object
|
||||
*/
|
||||
Handle CreateEvent(const ResetType reset_type) {
|
||||
Handle CreateEvent(const ResetType reset_type, const std::string name) {
|
||||
Handle handle;
|
||||
Event* evt = CreateEvent(handle, reset_type);
|
||||
Event* evt = CreateEvent(handle, reset_type, name);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,9 @@ Result ClearEvent(Handle handle);
|
||||
/**
|
||||
* Creates an event
|
||||
* @param reset_type ResetType describing how to create event
|
||||
* @param name Optional name of event
|
||||
* @return Handle to newly created Event object
|
||||
*/
|
||||
Handle CreateEvent(const ResetType reset_type);
|
||||
Handle CreateEvent(const ResetType reset_type, const std::string name="Unknown");
|
||||
|
||||
} // namespace
|
||||
|
@ -16,6 +16,7 @@ namespace Kernel {
|
||||
class Mutex : public Object {
|
||||
public:
|
||||
const char* GetTypeName() { return "Mutex"; }
|
||||
const char* GetName() { return name.c_str(); }
|
||||
|
||||
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; }
|
||||
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; }
|
||||
@ -24,6 +25,7 @@ public:
|
||||
bool locked; ///< Current locked state
|
||||
Handle lock_thread; ///< Handle to thread that currently has mutex
|
||||
std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex
|
||||
std::string name; ///< Name of mutex (optional)
|
||||
|
||||
/**
|
||||
* Synchronize kernel object
|
||||
@ -128,13 +130,15 @@ Result ReleaseMutex(Handle handle) {
|
||||
* 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 name Optional name of mutex
|
||||
* @return Pointer to new Mutex object
|
||||
*/
|
||||
Mutex* CreateMutex(Handle& handle, bool initial_locked) {
|
||||
Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string name) {
|
||||
Mutex* mutex = new Mutex;
|
||||
handle = Kernel::g_object_pool.Create(mutex);
|
||||
|
||||
mutex->locked = mutex->initial_locked = initial_locked;
|
||||
mutex->name = name;
|
||||
|
||||
// Acquire mutex with current thread if initialized as locked...
|
||||
if (mutex->locked) {
|
||||
@ -150,10 +154,12 @@ Mutex* CreateMutex(Handle& handle, bool initial_locked) {
|
||||
/**
|
||||
* Creates a mutex
|
||||
* @param initial_locked Specifies if the mutex should be locked initially
|
||||
* @param name Optional name of mutex
|
||||
* @return Handle to newly created object
|
||||
*/
|
||||
Handle CreateMutex(bool initial_locked) {
|
||||
Handle CreateMutex(bool initial_locked, std::string name) {
|
||||
Handle handle;
|
||||
Mutex* mutex = CreateMutex(handle, initial_locked);
|
||||
Mutex* mutex = CreateMutex(handle, initial_locked, name);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,9 @@ Result ReleaseMutex(Handle handle);
|
||||
/**
|
||||
* Creates a mutex
|
||||
* @param initial_locked Specifies if the mutex should be locked initially
|
||||
* @param name Optional name of mutex
|
||||
* @return Handle to newly created object
|
||||
*/
|
||||
Handle CreateMutex(bool initial_locked);
|
||||
Handle CreateMutex(bool initial_locked, const std::string name="Unknown");
|
||||
|
||||
} // namespace
|
||||
|
@ -19,8 +19,8 @@ void Initialize(Service::Interface* self) {
|
||||
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
|
||||
cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Menu"); // APT menu event handle
|
||||
cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Pause"); // APT pause event handle
|
||||
|
||||
Kernel::SetEventLocked(cmd_buff[3], true);
|
||||
Kernel::SetEventLocked(cmd_buff[4], false); // Fire start event
|
||||
@ -32,7 +32,7 @@ void GetLockHandle(Service::Interface* self) {
|
||||
u32* cmd_buff = Service::GetCommandBuffer();
|
||||
u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field
|
||||
cmd_buff[1] = 0; // No error
|
||||
cmd_buff[5] = Kernel::CreateMutex(false);
|
||||
cmd_buff[5] = Kernel::CreateMutex(false, "APT_U:Lock");
|
||||
DEBUG_LOG(KERNEL, "called handle=0x%08X", cmd_buff[5]);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ Handle g_mutex = 0;
|
||||
void Initialize(Service::Interface* self) {
|
||||
DEBUG_LOG(OSHLE, "called");
|
||||
if (!g_mutex) {
|
||||
g_mutex = Kernel::CreateMutex(false);
|
||||
g_mutex = Kernel::CreateMutex(true, "SRV:Lock");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user