yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

hle: kernel: Ensure all kernel objects with KAutoObject are properly created.

This commit is contained in:
bunnei 2021-04-09 16:56:11 -07:00
parent 722195cf70
commit ab704acab8
20 changed files with 55 additions and 0 deletions

View File

@ -793,6 +793,7 @@ void KScheduler::UpdateLastContextSwitchTime(KThread* thread, Process* process)
void KScheduler::Initialize() { void KScheduler::Initialize() {
idle_thread = std::make_unique<KThread>(system.Kernel()); idle_thread = std::make_unique<KThread>(system.Kernel());
KAutoObject::Create(idle_thread.get());
ASSERT(KThread::InitializeIdleThread(system, idle_thread.get(), core_id).IsSuccess()); ASSERT(KThread::InitializeIdleThread(system, idle_thread.get(), core_id).IsSuccess());
idle_thread->SetName(fmt::format("IdleThread:{}", core_id)); idle_thread->SetName(fmt::format("IdleThread:{}", core_id));
} }

View File

@ -196,6 +196,7 @@ struct KernelCore::Impl {
void InitializeSuspendThreads() { void InitializeSuspendThreads() {
for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
suspend_threads[core_id] = std::make_unique<KThread>(system.Kernel()); suspend_threads[core_id] = std::make_unique<KThread>(system.Kernel());
KAutoObject::Create(suspend_threads[core_id].get());
ASSERT(KThread::InitializeHighPriorityThread(system, suspend_threads[core_id].get(), {}, ASSERT(KThread::InitializeHighPriorityThread(system, suspend_threads[core_id].get(), {},
{}, core_id) {}, core_id)
.IsSuccess()); .IsSuccess());
@ -236,6 +237,7 @@ struct KernelCore::Impl {
KThread* GetHostDummyThread() { KThread* GetHostDummyThread() {
auto make_thread = [this]() { auto make_thread = [this]() {
std::unique_ptr<KThread> thread = std::make_unique<KThread>(system.Kernel()); std::unique_ptr<KThread> thread = std::make_unique<KThread>(system.Kernel());
KAutoObject::Create(thread.get());
ASSERT(KThread::InitializeDummyThread(thread.get()).IsSuccess()); ASSERT(KThread::InitializeDummyThread(thread.get()).IsSuccess());
thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId())); thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId()));
return std::move(thread); return std::move(thread);
@ -580,6 +582,11 @@ struct KernelCore::Impl {
irs_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); irs_shared_mem = std::make_unique<KSharedMemory>(system.Kernel());
time_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); time_shared_mem = std::make_unique<KSharedMemory>(system.Kernel());
KAutoObject::Create(hid_shared_mem.get());
KAutoObject::Create(font_shared_mem.get());
KAutoObject::Create(irs_shared_mem.get());
KAutoObject::Create(time_shared_mem.get());
hid_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, hid_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr,
{hid_phys_addr, hid_size / PageSize}, KMemoryPermission::None, {hid_phys_addr, hid_size / PageSize}, KMemoryPermission::None,
KMemoryPermission::Read, hid_phys_addr, hid_size, KMemoryPermission::Read, hid_phys_addr, hid_size,

View File

@ -307,6 +307,8 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(launchable_event));
launchable_event.Initialize("ISelfController:LaunchableEvent"); launchable_event.Initialize("ISelfController:LaunchableEvent");
// This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is
@ -315,6 +317,7 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
// suspended if the event has previously been created by a call to // suspended if the event has previously been created by a call to
// GetAccumulatedSuspendedTickChangedEvent. // GetAccumulatedSuspendedTickChangedEvent.
Kernel::KAutoObject::Create(std::addressof(accumulated_suspended_tick_changed_event));
accumulated_suspended_tick_changed_event.Initialize( accumulated_suspended_tick_changed_event.Initialize(
"ISelfController:AccumulatedSuspendedTickChangedEvent"); "ISelfController:AccumulatedSuspendedTickChangedEvent");
accumulated_suspended_tick_changed_event.GetWritableEvent()->Signal(); accumulated_suspended_tick_changed_event.GetWritableEvent()->Signal();
@ -579,6 +582,10 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo
AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel)
: on_new_message{kernel}, on_operation_mode_changed{kernel} { : on_new_message{kernel}, on_operation_mode_changed{kernel} {
Kernel::KAutoObject::Create(std::addressof(on_new_message));
Kernel::KAutoObject::Create(std::addressof(on_operation_mode_changed));
on_new_message.Initialize("AMMessageQueue:OnMessageReceived"); on_new_message.Initialize("AMMessageQueue:OnMessageReceived");
on_operation_mode_changed.Initialize("AMMessageQueue:OperationModeChanged"); on_operation_mode_changed.Initialize("AMMessageQueue:OperationModeChanged");
} }
@ -1333,6 +1340,11 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
RegisterHandlers(functions); RegisterHandlers(functions);
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
Kernel::KAutoObject::Create(std::addressof(gpu_error_detected_event));
Kernel::KAutoObject::Create(std::addressof(friend_invitation_storage_channel_event));
Kernel::KAutoObject::Create(std::addressof(health_warning_disappeared_system_event));
gpu_error_detected_event.Initialize("IApplicationFunctions:GpuErrorDetectedSystemEvent"); gpu_error_detected_event.Initialize("IApplicationFunctions:GpuErrorDetectedSystemEvent");
friend_invitation_storage_channel_event.Initialize( friend_invitation_storage_channel_event.Initialize(
"IApplicationFunctions:FriendInvitationStorageChannelEvent"); "IApplicationFunctions:FriendInvitationStorageChannelEvent");
@ -1798,6 +1810,7 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(pop_from_general_channel_event));
pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent"); pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent");
} }

View File

@ -32,6 +32,11 @@ namespace Service::AM::Applets {
AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_) AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_)
: system{system_}, applet_mode{applet_mode_}, state_changed_event{system.Kernel()}, : system{system_}, applet_mode{applet_mode_}, state_changed_event{system.Kernel()},
pop_out_data_event{system.Kernel()}, pop_interactive_out_data_event{system.Kernel()} { pop_out_data_event{system.Kernel()}, pop_interactive_out_data_event{system.Kernel()} {
Kernel::KAutoObject::Create(std::addressof(state_changed_event));
Kernel::KAutoObject::Create(std::addressof(pop_out_data_event));
Kernel::KAutoObject::Create(std::addressof(pop_interactive_out_data_event));
state_changed_event.Initialize("ILibraryAppletAccessor:StateChangedEvent"); state_changed_event.Initialize("ILibraryAppletAccessor:StateChangedEvent");
pop_out_data_event.Initialize("ILibraryAppletAccessor:PopDataOutEvent"); pop_out_data_event.Initialize("ILibraryAppletAccessor:PopDataOutEvent");
pop_interactive_out_data_event.Initialize("ILibraryAppletAccessor:PopInteractiveDataOutEvent"); pop_interactive_out_data_event.Initialize("ILibraryAppletAccessor:PopInteractiveDataOutEvent");

View File

@ -62,6 +62,7 @@ public:
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(purchased_event));
purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent"); purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent");
} }
@ -125,6 +126,7 @@ AOC_U::AOC_U(Core::System& system_)
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(aoc_change_event));
aoc_change_event.Initialize("GetAddOnContentListChanged:Event"); aoc_change_event.Initialize("GetAddOnContentListChanged:Event");
} }

View File

@ -67,6 +67,7 @@ public:
RegisterHandlers(functions); RegisterHandlers(functions);
// This is the event handle used to check if the audio buffer was released // This is the event handle used to check if the audio buffer was released
Kernel::KAutoObject::Create(std::addressof(buffer_event));
buffer_event.Initialize("IAudioOutBufferReleased"); buffer_event.Initialize("IAudioOutBufferReleased");
stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,

View File

@ -49,6 +49,7 @@ public:
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(system_event));
system_event.Initialize("IAudioRenderer:SystemEvent"); system_event.Initialize("IAudioRenderer:SystemEvent");
renderer = std::make_unique<AudioCore::AudioRenderer>( renderer = std::make_unique<AudioCore::AudioRenderer>(
system.CoreTiming(), system.Memory(), audren_params, system.CoreTiming(), system.Memory(), audren_params,
@ -189,13 +190,16 @@ public:
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(buffer_event));
buffer_event.Initialize("IAudioOutBufferReleasedEvent"); buffer_event.Initialize("IAudioOutBufferReleasedEvent");
// Should be similar to audio_output_device_switch_event // Should be similar to audio_output_device_switch_event
Kernel::KAutoObject::Create(std::addressof(audio_input_device_switch_event));
audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent"); audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent");
// Should only be signalled when an audio output device has been changed, example: speaker // Should only be signalled when an audio output device has been changed, example: speaker
// to headset // to headset
Kernel::KAutoObject::Create(std::addressof(audio_output_device_switch_event));
audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent"); audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent");
} }

View File

@ -15,6 +15,7 @@ namespace Service::BCAT {
ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel,
std::string_view event_name) std::string_view event_name)
: update_event{kernel} { : update_event{kernel} {
Kernel::KAutoObject::Create(std::addressof(update_event));
update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
} }

View File

@ -35,6 +35,7 @@ public:
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(register_event));
register_event.Initialize("BT:RegisterEvent"); register_event.Initialize("BT:RegisterEvent");
} }

View File

@ -60,6 +60,11 @@ public:
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(scan_event));
Kernel::KAutoObject::Create(std::addressof(connection_event));
Kernel::KAutoObject::Create(std::addressof(service_discovery));
Kernel::KAutoObject::Create(std::addressof(config_event));
scan_event.Initialize("IBtmUserCore:ScanEvent"); scan_event.Initialize("IBtmUserCore:ScanEvent");
connection_event.Initialize("IBtmUserCore:ConnectionEvent"); connection_event.Initialize("IBtmUserCore:ConnectionEvent");
service_discovery.Initialize("IBtmUserCore:Discovery"); service_discovery.Initialize("IBtmUserCore:Discovery");

View File

@ -197,6 +197,7 @@ public:
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(notification_event));
notification_event.Initialize("INotificationService:NotifyEvent"); notification_event.Initialize("INotificationService:NotifyEvent");
} }

View File

@ -254,6 +254,7 @@ void Controller_NPad::OnInit() {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) { for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) {
styleset_changed_events[i] = std::make_unique<Kernel::KEvent>(kernel); styleset_changed_events[i] = std::make_unique<Kernel::KEvent>(kernel);
Kernel::KAutoObject::Create(styleset_changed_events[i].get());
styleset_changed_events[i]->Initialize(fmt::format("npad:NpadStyleSetChanged_{}", i)); styleset_changed_events[i]->Initialize(fmt::format("npad:NpadStyleSetChanged_{}", i));
} }

View File

@ -24,6 +24,7 @@ constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_,
const char* name) const char* name)
: ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} { : ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} {
Kernel::KAutoObject::Create(std::addressof(nfc_tag_load));
nfc_tag_load.Initialize("IUser:NFCTagDetected"); nfc_tag_load.Initialize("IUser:NFCTagDetected");
} }
@ -63,6 +64,9 @@ public:
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(deactivate_event));
Kernel::KAutoObject::Create(std::addressof(availability_change_event));
deactivate_event.Initialize("IUser:DeactivateEvent"); deactivate_event.Initialize("IUser:DeactivateEvent");
availability_change_event.Initialize("IUser:AvailabilityChangeEvent"); availability_change_event.Initialize("IUser:AvailabilityChangeEvent");
} }

View File

@ -160,6 +160,9 @@ public:
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
Kernel::KAutoObject::Create(std::addressof(event1));
Kernel::KAutoObject::Create(std::addressof(event2));
event1.Initialize("IRequest:Event1"); event1.Initialize("IRequest:Event1");
event2.Initialize("IRequest:Event2"); event2.Initialize("IRequest:Event2");
} }

View File

@ -313,6 +313,7 @@ public:
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(finished_event));
finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent"); finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent");
} }

View File

@ -43,6 +43,7 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
for (u32 i = 0; i < MaxNvEvents; i++) { for (u32 i = 0; i < MaxNvEvents; i++) {
events_interface.events[i].event = std::make_unique<Kernel::KEvent>(kernel); events_interface.events[i].event = std::make_unique<Kernel::KEvent>(kernel);
Kernel::KAutoObject::Create(events_interface.events[i].event.get());
events_interface.events[i].event->Initialize(fmt::format("NVDRV::NvEvent_{}", i)); events_interface.events[i].event->Initialize(fmt::format("NVDRV::NvEvent_{}", i));
events_interface.status[i] = EventState::Free; events_interface.status[i] = EventState::Free;
events_interface.registered[i] = false; events_interface.registered[i] = false;

View File

@ -15,6 +15,7 @@ namespace Service::NVFlinger {
BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id)
: id(id), layer_id(layer_id), buffer_wait_event{kernel} { : id(id), layer_id(layer_id), buffer_wait_event{kernel} {
Kernel::KAutoObject::Create(std::addressof(buffer_wait_event));
buffer_wait_event.Initialize("BufferQueue:WaitEvent"); buffer_wait_event.Initialize("BufferQueue:WaitEvent");
} }

View File

@ -33,6 +33,7 @@ public:
RegisterHandlers(functions); RegisterHandlers(functions);
Kernel::KAutoObject::Create(std::addressof(state_change_event));
state_change_event.Initialize("IPsmSession::state_change_event"); state_change_event.Initialize("IPsmSession::state_change_event");
} }

View File

@ -18,6 +18,7 @@ StandardUserSystemClockCore::StandardUserSystemClockCore(
network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, network_system_clock_core{network_system_clock_core}, auto_correction_enabled{},
auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{
system.Kernel()} { system.Kernel()} {
Kernel::KAutoObject::Create(std::addressof(auto_correction_event));
auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent");
} }

View File

@ -19,6 +19,7 @@ namespace Service::VI {
Display::Display(u64 id, std::string name, Core::System& system) Display::Display(u64 id, std::string name, Core::System& system)
: id{id}, name{std::move(name)}, vsync_event{system.Kernel()} { : id{id}, name{std::move(name)}, vsync_event{system.Kernel()} {
Kernel::KAutoObject::Create(std::addressof(vsync_event));
vsync_event.Initialize(fmt::format("Display VSync Event {}", id)); vsync_event.Initialize(fmt::format("Display VSync Event {}", id));
} }