citra-emu
/
citra-canary
Archived
1
0
Fork 0

Kernel: pass Kernel ref in Event

This commit is contained in:
Weiyi Wang 2018-10-11 15:48:16 -04:00
parent 734be98966
commit eec11a94cb
33 changed files with 104 additions and 80 deletions

View File

@ -7,16 +7,16 @@
#include <vector> #include <vector>
#include "common/assert.h" #include "common/assert.h"
#include "core/hle/kernel/event.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" #include "core/hle/kernel/thread.h"
namespace Kernel { namespace Kernel {
Event::Event() {} Event::Event(KernelSystem& kernel) {}
Event::~Event() {} Event::~Event() {}
SharedPtr<Event> Event::Create(ResetType reset_type, std::string name) { SharedPtr<Event> KernelSystem::CreateEvent(ResetType reset_type, std::string name) {
SharedPtr<Event> evt(new Event); SharedPtr<Event> evt(new Event(*this));
evt->signaled = false; evt->signaled = false;
evt->reset_type = reset_type; evt->reset_type = reset_type;

View File

@ -12,13 +12,6 @@ namespace Kernel {
class Event final : public WaitObject { class Event final : public WaitObject {
public: 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 { std::string GetTypeName() const override {
return "Event"; return "Event";
} }
@ -47,13 +40,15 @@ public:
void Clear(); void Clear();
private: private:
Event(); explicit Event(KernelSystem& kernel);
~Event() override; ~Event() override;
ResetType reset_type; ///< Current ResetType ResetType reset_type; ///< Current ResetType
bool signaled; ///< Whether the event has already been signaled bool signaled; ///< Whether the event has already been signaled
std::string name; ///< Name of event (optional) std::string name; ///< Name of event (optional)
friend class KernelSystem;
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/hle_ipc.h"
@ -55,7 +56,8 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread,
cmd_buff.size() * sizeof(u32)); 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->status = ThreadStatus::WaitHleEvent;
thread->wait_objects = {event}; thread->wait_objects = {event};
event->AddWaitingThread(thread); event->AddWaitingThread(thread);

View File

@ -11,6 +11,13 @@
namespace Kernel { namespace Kernel {
class AddressArbiter; class AddressArbiter;
class Event;
enum class ResetType {
OneShot,
Sticky,
Pulse,
};
template <typename T> template <typename T>
using SharedPtr = boost::intrusive_ptr<T>; using SharedPtr = boost::intrusive_ptr<T>;
@ -27,6 +34,13 @@ public:
* @returns The created AddressArbiter. * @returns The created AddressArbiter.
*/ */
SharedPtr<AddressArbiter> CreateAddressArbiter(std::string name = "Unknown"); 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 } // namespace Kernel

View File

@ -35,12 +35,6 @@ enum {
DEFAULT_STACK_SIZE = 0x4000, DEFAULT_STACK_SIZE = 0x4000,
}; };
enum class ResetType {
OneShot,
Sticky,
Pulse,
};
class Object : NonCopyable { class Object : NonCopyable {
public: public:
virtual ~Object(); virtual ~Object();

View File

@ -942,8 +942,8 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
/// Create an event /// Create an event
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
SharedPtr<Event> evt = Event::Create(static_cast<ResetType>(reset_type), SharedPtr<Event> evt = Core::System::GetInstance().Kernel().CreateEvent(
fmt::format("event-{:08x}", Core::CPU().GetReg(14))); static_cast<ResetType>(reset_type), fmt::format("event-{:08x}", Core::CPU().GetReg(14)));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt))); 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, LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type,

View File

@ -572,9 +572,9 @@ AppletManager::AppletManager(Core::System& system) : system(system) {
slot_data.registered = false; slot_data.registered = false;
slot_data.loaded = false; slot_data.loaded = false;
slot_data.notification_event = slot_data.notification_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Notification"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "APT:Notification");
slot_data.parameter_event = slot_data.parameter_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Parameter"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "APT:Parameter");
} }
HLE::Applets::Init(); HLE::Applets::Init();
} }

View File

@ -903,15 +903,16 @@ void Module::Interface::GetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ct
Module::Interface::Interface(std::shared_ptr<Module> boss, const char* name, u32 max_session) Module::Interface::Interface(std::shared_ptr<Module> boss, const char* name, u32 max_session)
: ServiceFramework(name, max_session), boss(std::move(boss)) {} : ServiceFramework(name, max_session), boss(std::move(boss)) {}
Module::Module() { Module::Module(Core::System& system) {
using namespace Kernel; using namespace Kernel;
// TODO: verify ResetType // TODO: verify ResetType
task_finish_event = Event::Create(Kernel::ResetType::OneShot, "BOSS::task_finish_event"); task_finish_event =
system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "BOSS::task_finish_event");
} }
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto boss = std::make_shared<Module>(); auto boss = std::make_shared<Module>(system);
std::make_shared<BOSS_P>(boss)->InstallAsService(service_manager); std::make_shared<BOSS_P>(boss)->InstallAsService(service_manager);
std::make_shared<BOSS_U>(boss)->InstallAsService(service_manager); std::make_shared<BOSS_U>(boss)->InstallAsService(service_manager);
} }

View File

@ -15,7 +15,7 @@ namespace Service::BOSS {
class Module final { class Module final {
public: public:
Module(); explicit Module(Core::System& system);
~Module() = default; ~Module() = default;
class Interface : public ServiceFramework<Interface> { class Interface : public ServiceFramework<Interface> {

View File

@ -1019,14 +1019,15 @@ void Module::Interface::DriverFinalize(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_CAM, "called"); LOG_DEBUG(Service_CAM, "called");
} }
Module::Module() { Module::Module(Core::System& system) {
using namespace Kernel; using namespace Kernel;
for (PortConfig& port : ports) { for (PortConfig& port : ports) {
port.completion_event = Event::Create(ResetType::Sticky, "CAM::completion_event"); port.completion_event =
system.Kernel().CreateEvent(ResetType::Sticky, "CAM::completion_event");
port.buffer_error_interrupt_event = port.buffer_error_interrupt_event =
Event::Create(ResetType::OneShot, "CAM::buffer_error_interrupt_event"); system.Kernel().CreateEvent(ResetType::OneShot, "CAM::buffer_error_interrupt_event");
port.vsync_interrupt_event = port.vsync_interrupt_event =
Event::Create(ResetType::OneShot, "CAM::vsync_interrupt_event"); system.Kernel().CreateEvent(ResetType::OneShot, "CAM::vsync_interrupt_event");
} }
completion_event_callback = CoreTiming::RegisterEvent( completion_event_callback = CoreTiming::RegisterEvent(
"CAM::CompletionEventCallBack", "CAM::CompletionEventCallBack",
@ -1061,7 +1062,7 @@ std::shared_ptr<Module> GetModule(Core::System& system) {
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto cam = std::make_shared<Module>(); auto cam = std::make_shared<Module>(system);
std::make_shared<CAM_U>(cam)->InstallAsService(service_manager); std::make_shared<CAM_U>(cam)->InstallAsService(service_manager);
std::make_shared<CAM_S>(cam)->InstallAsService(service_manager); std::make_shared<CAM_S>(cam)->InstallAsService(service_manager);

View File

@ -241,7 +241,7 @@ static_assert(sizeof(PackageParameterWithContextDetail) == 28,
class Module final { class Module final {
public: public:
Module(); explicit Module(Core::System& system);
~Module(); ~Module();
void ReloadCameraDevices(); void ReloadCameraDevices();

View File

@ -1351,10 +1351,11 @@ Module::SessionData::~SessionData() {
Module::Interface::Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session) Module::Interface::Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session)
: ServiceFramework(name, max_session), cecd(std::move(cecd)) {} : ServiceFramework(name, max_session), cecd(std::move(cecd)) {}
Module::Module() { Module::Module(Core::System& system) {
using namespace Kernel; using namespace Kernel;
cecinfo_event = Event::Create(Kernel::ResetType::OneShot, "CECD::cecinfo_event"); cecinfo_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "CECD::cecinfo_event");
change_state_event = Event::Create(Kernel::ResetType::OneShot, "CECD::change_state_event"); change_state_event =
system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "CECD::change_state_event");
std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory);
@ -1433,7 +1434,7 @@ Module::~Module() = default;
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto cecd = std::make_shared<Module>(); auto cecd = std::make_shared<Module>(system);
std::make_shared<CECD_NDM>(cecd)->InstallAsService(service_manager); std::make_shared<CECD_NDM>(cecd)->InstallAsService(service_manager);
std::make_shared<CECD_S>(cecd)->InstallAsService(service_manager); std::make_shared<CECD_S>(cecd)->InstallAsService(service_manager);
std::make_shared<CECD_U>(cecd)->InstallAsService(service_manager); std::make_shared<CECD_U>(cecd)->InstallAsService(service_manager);

View File

@ -23,7 +23,7 @@ namespace Service::CECD {
class Module final { class Module final {
public: public:
Module(); explicit Module(Core::System& system);
~Module(); ~Module();
enum class CecCommand : u32 { enum class CecCommand : u32 {

View File

@ -350,7 +350,7 @@ bool DSP_DSP::HasTooManyEventsRegistered() const {
return number >= max_number_of_interrupt_events; return number >= max_number_of_interrupt_events;
} }
DSP_DSP::DSP_DSP() : ServiceFramework("dsp::DSP", DefaultMaxSessions) { DSP_DSP::DSP_DSP(Core::System& system) : ServiceFramework("dsp::DSP", DefaultMaxSessions) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
// clang-format off // clang-format off
{0x00010040, &DSP_DSP::RecvData, "RecvData"}, {0x00010040, &DSP_DSP::RecvData, "RecvData"},
@ -391,7 +391,8 @@ DSP_DSP::DSP_DSP() : ServiceFramework("dsp::DSP", DefaultMaxSessions) {
RegisterHandlers(functions); RegisterHandlers(functions);
semaphore_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "DSP_DSP::semaphore_event"); semaphore_event =
system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "DSP_DSP::semaphore_event");
} }
DSP_DSP::~DSP_DSP() { DSP_DSP::~DSP_DSP() {
@ -401,7 +402,7 @@ DSP_DSP::~DSP_DSP() {
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto dsp = std::make_shared<DSP_DSP>(); auto dsp = std::make_shared<DSP_DSP>(system);
dsp->InstallAsService(service_manager); dsp->InstallAsService(service_manager);
Core::DSP().SetServiceToInterrupt(std::move(dsp)); Core::DSP().SetServiceToInterrupt(std::move(dsp));
} }

View File

@ -17,7 +17,7 @@ namespace Service::DSP {
class DSP_DSP final : public ServiceFramework<DSP_DSP> { class DSP_DSP final : public ServiceFramework<DSP_DSP> {
public: public:
DSP_DSP(); explicit DSP_DSP(Core::System& system);
~DSP_DSP(); ~DSP_DSP();
/// There are three types of interrupts /// There are three types of interrupts

View File

@ -364,11 +364,11 @@ Module::Module(Core::System& system) : system(system) {
0, MemoryRegion::BASE, "HID:SharedMemory"); 0, MemoryRegion::BASE, "HID:SharedMemory");
// Create event handles // Create event handles
event_pad_or_touch_1 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch1"); event_pad_or_touch_1 = system.Kernel().CreateEvent(ResetType::OneShot, "HID:EventPadOrTouch1");
event_pad_or_touch_2 = Event::Create(ResetType::OneShot, "HID:EventPadOrTouch2"); event_pad_or_touch_2 = system.Kernel().CreateEvent(ResetType::OneShot, "HID:EventPadOrTouch2");
event_accelerometer = Event::Create(ResetType::OneShot, "HID:EventAccelerometer"); event_accelerometer = system.Kernel().CreateEvent(ResetType::OneShot, "HID:EventAccelerometer");
event_gyroscope = Event::Create(ResetType::OneShot, "HID:EventGyroscope"); event_gyroscope = system.Kernel().CreateEvent(ResetType::OneShot, "HID:EventGyroscope");
event_debug_pad = Event::Create(ResetType::OneShot, "HID:EventDebugPad"); event_debug_pad = system.Kernel().CreateEvent(ResetType::OneShot, "HID:EventDebugPad");
// Register update callbacks // Register update callbacks
pad_update_event = pad_update_event =

View File

@ -16,10 +16,10 @@ void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
std::make_shared<IR_U>()->InstallAsService(service_manager); std::make_shared<IR_U>()->InstallAsService(service_manager);
auto ir_user = std::make_shared<IR_USER>(); auto ir_user = std::make_shared<IR_USER>(system);
ir_user->InstallAsService(service_manager); ir_user->InstallAsService(service_manager);
auto ir_rst = std::make_shared<IR_RST>(); auto ir_rst = std::make_shared<IR_RST>(system);
ir_rst->InstallAsService(service_manager); ir_rst->InstallAsService(service_manager);
} }

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
@ -144,14 +145,14 @@ void IR_RST::Shutdown(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_IR, "called"); LOG_DEBUG(Service_IR, "called");
} }
IR_RST::IR_RST() : ServiceFramework("ir:rst", 1) { IR_RST::IR_RST(Core::System& system) : ServiceFramework("ir:rst", 1) {
using namespace Kernel; using namespace Kernel;
// Note: these two kernel objects are even available before Initialize service function is // Note: these two kernel objects are even available before Initialize service function is
// called. // called.
shared_memory = shared_memory =
SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite, MemoryPermission::Read, SharedMemory::Create(nullptr, 0x1000, MemoryPermission::ReadWrite, MemoryPermission::Read,
0, MemoryRegion::BASE, "IRRST:SharedMemory"); 0, MemoryRegion::BASE, "IRRST:SharedMemory");
update_event = Event::Create(ResetType::OneShot, "IRRST:UpdateEvent"); update_event = system.Kernel().CreateEvent(ResetType::OneShot, "IRRST:UpdateEvent");
update_callback_id = update_callback_id =
CoreTiming::RegisterEvent("IRRST:UpdateCallBack", [this](u64 userdata, s64 cycles_late) { CoreTiming::RegisterEvent("IRRST:UpdateCallBack", [this](u64 userdata, s64 cycles_late) {

View File

@ -39,7 +39,7 @@ union PadState {
/// Interface to "ir:rst" service /// Interface to "ir:rst" service
class IR_RST final : public ServiceFramework<IR_RST> { class IR_RST final : public ServiceFramework<IR_RST> {
public: public:
IR_RST(); explicit IR_RST(Core::System& system);
~IR_RST(); ~IR_RST();
void ReloadInputDevices(); void ReloadInputDevices();

View File

@ -6,6 +6,7 @@
#include <boost/crc.hpp> #include <boost/crc.hpp>
#include "common/string_util.h" #include "common/string_util.h"
#include "common/swap.h" #include "common/swap.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/shared_memory.h"
@ -380,7 +381,7 @@ void IR_USER::ReleaseReceivedData(Kernel::HLERequestContext& ctx) {
LOG_TRACE(Service_IR, "called, count={}", count); LOG_TRACE(Service_IR, "called, count={}", count);
} }
IR_USER::IR_USER() : ServiceFramework("ir:USER", 1) { IR_USER::IR_USER(Core::System& system) : ServiceFramework("ir:USER", 1) {
const FunctionInfo functions[] = { const FunctionInfo functions[] = {
{0x00010182, nullptr, "InitializeIrNop"}, {0x00010182, nullptr, "InitializeIrNop"},
{0x00020000, &IR_USER::FinalizeIrNop, "FinalizeIrNop"}, {0x00020000, &IR_USER::FinalizeIrNop, "FinalizeIrNop"},
@ -413,9 +414,9 @@ IR_USER::IR_USER() : ServiceFramework("ir:USER", 1) {
using namespace Kernel; using namespace Kernel;
conn_status_event = Event::Create(ResetType::OneShot, "IR:ConnectionStatusEvent"); conn_status_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:ConnectionStatusEvent");
send_event = Event::Create(ResetType::OneShot, "IR:SendEvent"); send_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:SendEvent");
receive_event = Event::Create(ResetType::OneShot, "IR:ReceiveEvent"); receive_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:ReceiveEvent");
extra_hid = extra_hid =
std::make_unique<ExtraHID>([this](const std::vector<u8>& data) { PutToReceive(data); }); std::make_unique<ExtraHID>([this](const std::vector<u8>& data) { PutToReceive(data); });

View File

@ -55,7 +55,7 @@ private:
/// Interface to "ir:USER" service /// Interface to "ir:USER" service
class IR_USER final : public ServiceFramework<IR_USER> { class IR_USER final : public ServiceFramework<IR_USER> {
public: public:
IR_USER(); explicit IR_USER(Core::System& system);
~IR_USER(); ~IR_USER();
void ReloadInputDevices(); void ReloadInputDevices();

View File

@ -29,6 +29,11 @@ enum class SampleRate : u8 {
}; };
struct MIC_U::Impl { struct MIC_U::Impl {
explicit Impl(Core::System& system) {
buffer_full_event =
system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "MIC_U::buffer_full_event");
}
void MapSharedMem(Kernel::HLERequestContext& ctx) { void MapSharedMem(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx, 0x01, 1, 2}; IPC::RequestParser rp{ctx, 0x01, 1, 2};
const u32 size = rp.Pop<u32>(); const u32 size = rp.Pop<u32>();
@ -187,8 +192,7 @@ struct MIC_U::Impl {
} }
u32 client_version = 0; u32 client_version = 0;
Kernel::SharedPtr<Kernel::Event> buffer_full_event = Kernel::SharedPtr<Kernel::Event> buffer_full_event;
Kernel::Event::Create(Kernel::ResetType::OneShot, "MIC_U::buffer_full_event");
Kernel::SharedPtr<Kernel::SharedMemory> shared_memory; Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;
u8 mic_gain = 0; u8 mic_gain = 0;
bool mic_power = false; bool mic_power = false;
@ -266,7 +270,8 @@ void MIC_U::SetClientVersion(Kernel::HLERequestContext& ctx) {
impl->SetClientVersion(ctx); impl->SetClientVersion(ctx);
} }
MIC_U::MIC_U() : ServiceFramework{"mic:u", 1}, impl{std::make_unique<Impl>()} { MIC_U::MIC_U(Core::System& system)
: ServiceFramework{"mic:u", 1}, impl{std::make_unique<Impl>(system)} {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0x00010042, &MIC_U::MapSharedMem, "MapSharedMem"}, {0x00010042, &MIC_U::MapSharedMem, "MapSharedMem"},
{0x00020000, &MIC_U::UnmapSharedMem, "UnmapSharedMem"}, {0x00020000, &MIC_U::UnmapSharedMem, "UnmapSharedMem"},
@ -293,7 +298,7 @@ MIC_U::~MIC_U() = default;
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
std::make_shared<MIC_U>()->InstallAsService(service_manager); std::make_shared<MIC_U>(system)->InstallAsService(service_manager);
} }
} // namespace Service::MIC } // namespace Service::MIC

View File

@ -16,7 +16,7 @@ namespace Service::MIC {
class MIC_U final : public ServiceFramework<MIC_U> { class MIC_U final : public ServiceFramework<MIC_U> {
public: public:
MIC_U(); explicit MIC_U(Core::System& system);
~MIC_U(); ~MIC_U();
private: private:

View File

@ -140,18 +140,18 @@ Module::Interface::Interface(std::shared_ptr<Module> nfc, const char* name, u32
Module::Interface::~Interface() = default; Module::Interface::~Interface() = default;
Module::Module() { Module::Module(Core::System& system) {
tag_in_range_event = tag_in_range_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_in_range_event"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "NFC::tag_in_range_event");
tag_out_of_range_event = tag_out_of_range_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_out_range_event"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "NFC::tag_out_range_event");
} }
Module::~Module() = default; Module::~Module() = default;
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto nfc = std::make_shared<Module>(); auto nfc = std::make_shared<Module>(system);
std::make_shared<NFC_M>(nfc)->InstallAsService(service_manager); std::make_shared<NFC_M>(nfc)->InstallAsService(service_manager);
std::make_shared<NFC_U>(nfc)->InstallAsService(service_manager); std::make_shared<NFC_U>(nfc)->InstallAsService(service_manager);
} }

View File

@ -41,7 +41,7 @@ enum class CommunicationStatus : u8 {
class Module final { class Module final {
public: public:
Module(); explicit Module(Core::System& system);
~Module(); ~Module();
class Interface : public ServiceFramework<Interface> { class Interface : public ServiceFramework<Interface> {

View File

@ -14,7 +14,7 @@ void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
std::make_shared<NIM_AOC>()->InstallAsService(service_manager); std::make_shared<NIM_AOC>()->InstallAsService(service_manager);
std::make_shared<NIM_S>()->InstallAsService(service_manager); std::make_shared<NIM_S>()->InstallAsService(service_manager);
std::make_shared<NIM_U>()->InstallAsService(service_manager); std::make_shared<NIM_U>(system)->InstallAsService(service_manager);
} }
} // namespace Service::NIM } // namespace Service::NIM

View File

@ -2,13 +2,14 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/core.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/service/nim/nim_u.h" #include "core/hle/service/nim/nim_u.h"
namespace Service::NIM { namespace Service::NIM {
NIM_U::NIM_U() : ServiceFramework("nim:u", 2) { NIM_U::NIM_U(Core::System& system) : ServiceFramework("nim:u", 2) {
const FunctionInfo functions[] = { const FunctionInfo functions[] = {
{0x00010000, nullptr, "StartSysUpdate"}, {0x00010000, nullptr, "StartSysUpdate"},
{0x00020000, nullptr, "GetUpdateDownloadProgress"}, {0x00020000, nullptr, "GetUpdateDownloadProgress"},
@ -20,7 +21,7 @@ NIM_U::NIM_U() : ServiceFramework("nim:u", 2) {
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
nim_system_update_event = nim_system_update_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "NIM System Update Event"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "NIM System Update Event");
} }
NIM_U::~NIM_U() = default; NIM_U::~NIM_U() = default;

View File

@ -6,11 +6,15 @@
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Service::NIM { namespace Service::NIM {
class NIM_U final : public ServiceFramework<NIM_U> { class NIM_U final : public ServiceFramework<NIM_U> {
public: public:
NIM_U(); explicit NIM_U(Core::System& system);
~NIM_U(); ~NIM_U();
private: private:

View File

@ -839,8 +839,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
} }
// Create a new event for this bind node. // Create a new event for this bind node.
auto event = Kernel::Event::Create(Kernel::ResetType::OneShot, auto event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot,
"NWM::BindNodeEvent" + std::to_string(bind_node_id)); "NWM::BindNodeEvent" + std::to_string(bind_node_id));
std::lock_guard<std::mutex> lock(connection_status_mutex); std::lock_guard<std::mutex> lock(connection_status_mutex);
ASSERT(channel_data.find(data_channel) == channel_data.end()); ASSERT(channel_data.find(data_channel) == channel_data.end());
@ -1355,7 +1355,7 @@ static void BeaconBroadcastCallback(u64 userdata, s64 cycles_late) {
beacon_broadcast_event, 0); beacon_broadcast_event, 0);
} }
NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS") { NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS"), system(system) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0x000102C2, nullptr, "Initialize (deprecated)"}, {0x000102C2, nullptr, "Initialize (deprecated)"},
{0x00020000, nullptr, "Scrap"}, {0x00020000, nullptr, "Scrap"},
@ -1388,7 +1388,7 @@ NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS") {
{0x00220402, nullptr, "ScanOnConnection"}, {0x00220402, nullptr, "ScanOnConnection"},
}; };
connection_status_event = connection_status_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "NWM::connection_status_event"); system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "NWM::connection_status_event");
RegisterHandlers(functions); RegisterHandlers(functions);

View File

@ -112,6 +112,8 @@ public:
~NWM_UDS(); ~NWM_UDS();
private: private:
Core::System& system;
void UpdateNetworkAttribute(Kernel::HLERequestContext& ctx); void UpdateNetworkAttribute(Kernel::HLERequestContext& ctx);
/** /**

View File

@ -632,7 +632,7 @@ void Y2R_U::GetPackageParameter(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
Y2R_U::Y2R_U() : ServiceFramework("y2r:u", 1) { Y2R_U::Y2R_U(Core::System& system) : ServiceFramework("y2r:u", 1) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0x00010040, &Y2R_U::SetInputFormat, "SetInputFormat"}, {0x00010040, &Y2R_U::SetInputFormat, "SetInputFormat"},
{0x00020000, &Y2R_U::GetInputFormat, "GetInputFormat"}, {0x00020000, &Y2R_U::GetInputFormat, "GetInputFormat"},
@ -682,14 +682,14 @@ Y2R_U::Y2R_U() : ServiceFramework("y2r:u", 1) {
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
completion_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "Y2R:Completed"); completion_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "Y2R:Completed");
} }
Y2R_U::~Y2R_U() = default; Y2R_U::~Y2R_U() = default;
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
std::make_shared<Y2R_U>()->InstallAsService(service_manager); std::make_shared<Y2R_U>(system)->InstallAsService(service_manager);
} }
} // namespace Service::Y2R } // namespace Service::Y2R

View File

@ -149,7 +149,7 @@ static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct h
class Y2R_U final : public ServiceFramework<Y2R_U> { class Y2R_U final : public ServiceFramework<Y2R_U> {
public: public:
Y2R_U(); explicit Y2R_U(Core::System& system);
~Y2R_U() override; ~Y2R_U() override;
private: private:

View File

@ -15,7 +15,8 @@
namespace Kernel { namespace Kernel {
static SharedPtr<Object> MakeObject() { static SharedPtr<Object> MakeObject() {
return Event::Create(ResetType::OneShot); static Kernel::KernelSystem kernel(0);
return kernel.CreateEvent(ResetType::OneShot);
} }
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") { TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {