Kernel: pass Kernel ref in Event
This commit is contained in:
parent
734be98966
commit
eec11a94cb
33 changed files with 104 additions and 80 deletions
|
@ -7,16 +7,16 @@
|
|||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/object.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
Event::Event() {}
|
||||
Event::Event(KernelSystem& kernel) {}
|
||||
Event::~Event() {}
|
||||
|
||||
SharedPtr<Event> Event::Create(ResetType reset_type, std::string name) {
|
||||
SharedPtr<Event> evt(new Event);
|
||||
SharedPtr<Event> KernelSystem::CreateEvent(ResetType reset_type, std::string name) {
|
||||
SharedPtr<Event> evt(new Event(*this));
|
||||
|
||||
evt->signaled = false;
|
||||
evt->reset_type = reset_type;
|
||||
|
|
|
@ -12,13 +12,6 @@ namespace Kernel {
|
|||
|
||||
class Event final : public WaitObject {
|
||||
public:
|
||||
/**
|
||||
* Creates an event
|
||||
* @param reset_type ResetType describing how to create event
|
||||
* @param name Optional name of event
|
||||
*/
|
||||
static SharedPtr<Event> Create(ResetType reset_type, std::string name = "Unknown");
|
||||
|
||||
std::string GetTypeName() const override {
|
||||
return "Event";
|
||||
}
|
||||
|
@ -47,13 +40,15 @@ public:
|
|||
void Clear();
|
||||
|
||||
private:
|
||||
Event();
|
||||
explicit Event(KernelSystem& kernel);
|
||||
~Event() override;
|
||||
|
||||
ResetType reset_type; ///< Current ResetType
|
||||
|
||||
bool signaled; ///< Whether the event has already been signaled
|
||||
std::string name; ///< Name of event (optional)
|
||||
|
||||
friend class KernelSystem;
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/handle_table.h"
|
||||
#include "core/hle/kernel/hle_ipc.h"
|
||||
|
@ -55,7 +56,8 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread,
|
|||
cmd_buff.size() * sizeof(u32));
|
||||
};
|
||||
|
||||
auto event = Kernel::Event::Create(Kernel::ResetType::OneShot, "HLE Pause Event: " + reason);
|
||||
auto event = Core::System::GetInstance().Kernel().CreateEvent(Kernel::ResetType::OneShot,
|
||||
"HLE Pause Event: " + reason);
|
||||
thread->status = ThreadStatus::WaitHleEvent;
|
||||
thread->wait_objects = {event};
|
||||
event->AddWaitingThread(thread);
|
||||
|
|
|
@ -11,6 +11,13 @@
|
|||
namespace Kernel {
|
||||
|
||||
class AddressArbiter;
|
||||
class Event;
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
Sticky,
|
||||
Pulse,
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using SharedPtr = boost::intrusive_ptr<T>;
|
||||
|
@ -27,6 +34,13 @@ public:
|
|||
* @returns The created AddressArbiter.
|
||||
*/
|
||||
SharedPtr<AddressArbiter> CreateAddressArbiter(std::string name = "Unknown");
|
||||
|
||||
/**
|
||||
* Creates an event
|
||||
* @param reset_type ResetType describing how to create event
|
||||
* @param name Optional name of event
|
||||
*/
|
||||
SharedPtr<Event> CreateEvent(ResetType reset_type, std::string name = "Unknown");
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -35,12 +35,6 @@ enum {
|
|||
DEFAULT_STACK_SIZE = 0x4000,
|
||||
};
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
Sticky,
|
||||
Pulse,
|
||||
};
|
||||
|
||||
class Object : NonCopyable {
|
||||
public:
|
||||
virtual ~Object();
|
||||
|
|
|
@ -942,8 +942,8 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
|
|||
|
||||
/// Create an event
|
||||
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
|
||||
SharedPtr<Event> evt = Event::Create(static_cast<ResetType>(reset_type),
|
||||
fmt::format("event-{:08x}", Core::CPU().GetReg(14)));
|
||||
SharedPtr<Event> evt = Core::System::GetInstance().Kernel().CreateEvent(
|
||||
static_cast<ResetType>(reset_type), fmt::format("event-{:08x}", Core::CPU().GetReg(14)));
|
||||
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt)));
|
||||
|
||||
LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue