kernel: Add SyncObject primitive, use it for ClientSession.
This commit is contained in:
parent
6e021f22b8
commit
834fa5db65
|
@ -132,6 +132,7 @@ set(HEADERS
|
||||||
hle/kernel/server_session.h
|
hle/kernel/server_session.h
|
||||||
hle/kernel/session.h
|
hle/kernel/session.h
|
||||||
hle/kernel/shared_memory.h
|
hle/kernel/shared_memory.h
|
||||||
|
hle/kernel/sync_object.h
|
||||||
hle/kernel/thread.h
|
hle/kernel/thread.h
|
||||||
hle/kernel/timer.h
|
hle/kernel/timer.h
|
||||||
hle/kernel/vm_manager.h
|
hle/kernel/vm_manager.h
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/sync_object.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -16,7 +16,7 @@ class ServerSession;
|
||||||
class Session;
|
class Session;
|
||||||
class Thread;
|
class Thread;
|
||||||
|
|
||||||
class ClientSession final : public Object {
|
class ClientSession final : public SyncObject {
|
||||||
public:
|
public:
|
||||||
friend class ServerSession;
|
friend class ServerSession;
|
||||||
|
|
||||||
|
@ -33,12 +33,7 @@ public:
|
||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ResultCode SendSyncRequest(SharedPtr<Thread> thread) override;
|
||||||
* Sends an SyncRequest from the current emulated thread.
|
|
||||||
* @param thread Thread that initiated the request.
|
|
||||||
* @return ResultCode of the operation.
|
|
||||||
*/
|
|
||||||
ResultCode SendSyncRequest(SharedPtr<Thread> thread);
|
|
||||||
|
|
||||||
std::string name; ///< Name of client port (optional)
|
std::string name; ///< Name of client port (optional)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||||
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
class Thread;
|
||||||
|
|
||||||
|
/// Class that represents a Kernel object that svcSendSyncRequest can be called on
|
||||||
|
class SyncObject : public Object {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Handle a sync request from the emulated application.
|
||||||
|
* @param thread Thread that initiated the request.
|
||||||
|
* @returns ResultCode from the operation.
|
||||||
|
*/
|
||||||
|
virtual ResultCode SendSyncRequest(SharedPtr<Thread> thread) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Specialization of DynamicObjectCast for SyncObjects
|
||||||
|
template <>
|
||||||
|
inline SharedPtr<SyncObject> DynamicObjectCast<SyncObject>(SharedPtr<Object> object) {
|
||||||
|
if (object != nullptr && object->IsSyncable()) {
|
||||||
|
return boost::static_pointer_cast<SyncObject>(std::move(object));
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Kernel
|
|
@ -10,6 +10,7 @@
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/kernel/handle_table.h"
|
#include "core/hle/kernel/handle_table.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
#include "core/hle/kernel/sync_object.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
#include "core/hle/lock.h"
|
#include "core/hle/lock.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
@ -71,8 +72,7 @@ static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_addr
|
||||||
|
|
||||||
/// Makes a blocking IPC call to an OS service.
|
/// Makes a blocking IPC call to an OS service.
|
||||||
static ResultCode SendSyncRequest(Kernel::Handle handle) {
|
static ResultCode SendSyncRequest(Kernel::Handle handle) {
|
||||||
SharedPtr<Kernel::ClientSession> session =
|
SharedPtr<Kernel::SyncObject> session = Kernel::g_handle_table.Get<Kernel::SyncObject>(handle);
|
||||||
Kernel::g_handle_table.Get<Kernel::ClientSession>(handle);
|
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle);
|
LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle);
|
||||||
return ERR_INVALID_HANDLE;
|
return ERR_INVALID_HANDLE;
|
||||||
|
|
Reference in New Issue