summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/glue
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/glue/arp.cpp7
-rw-r--r--src/core/hle/service/glue/arp.h5
-rw-r--r--src/core/hle/service/glue/bgtc.cpp5
-rw-r--r--src/core/hle/service/glue/bgtc.h5
-rw-r--r--src/core/hle/service/glue/ectx.cpp5
-rw-r--r--src/core/hle/service/glue/ectx.h5
-rw-r--r--src/core/hle/service/glue/errors.h13
-rw-r--r--src/core/hle/service/glue/glue.cpp5
-rw-r--r--src/core/hle/service/glue/glue.h5
-rw-r--r--src/core/hle/service/glue/glue_manager.cpp11
-rw-r--r--src/core/hle/service/glue/glue_manager.h9
-rw-r--r--src/core/hle/service/glue/notif.cpp137
-rw-r--r--src/core/hle/service/glue/notif.h53
13 files changed, 208 insertions, 57 deletions
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index 2feead2aa..49b6d45fe 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
@@ -154,7 +153,7 @@ class IRegistrar final : public ServiceFramework<IRegistrar> {
friend class ARP_W;
public:
- using IssuerFn = std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)>;
+ using IssuerFn = std::function<Result(u64, ApplicationLaunchProperty, std::vector<u8>)>;
explicit IRegistrar(Core::System& system_, IssuerFn&& issuer)
: ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} {
diff --git a/src/core/hle/service/glue/arp.h b/src/core/hle/service/glue/arp.h
index 0df3c5e1f..06c992e88 100644
--- a/src/core/hle/service/glue/arp.h
+++ b/src/core/hle/service/glue/arp.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/core/hle/service/glue/bgtc.cpp b/src/core/hle/service/glue/bgtc.cpp
index 564c3b750..3248091c3 100644
--- a/src/core/hle/service/glue/bgtc.cpp
+++ b/src/core/hle/service/glue/bgtc.cpp
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
#include "core/core.h"
diff --git a/src/core/hle/service/glue/bgtc.h b/src/core/hle/service/glue/bgtc.h
index 4c0142fd5..d6e2baec1 100644
--- a/src/core/hle/service/glue/bgtc.h
+++ b/src/core/hle/service/glue/bgtc.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/core/hle/service/glue/ectx.cpp b/src/core/hle/service/glue/ectx.cpp
index 249c6f003..1bd9314ae 100644
--- a/src/core/hle/service/glue/ectx.cpp
+++ b/src/core/hle/service/glue/ectx.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/glue/ectx.h"
diff --git a/src/core/hle/service/glue/ectx.h b/src/core/hle/service/glue/ectx.h
index b275e808a..a608de053 100644
--- a/src/core/hle/service/glue/ectx.h
+++ b/src/core/hle/service/glue/ectx.h
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/core/hle/service/glue/errors.h b/src/core/hle/service/glue/errors.h
index f6647f724..d4ce7f44e 100644
--- a/src/core/hle/service/glue/errors.h
+++ b/src/core/hle/service/glue/errors.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -8,9 +7,9 @@
namespace Service::Glue {
-constexpr ResultCode ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
-constexpr ResultCode ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
-constexpr ResultCode ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
-constexpr ResultCode ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
+constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
+constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
+constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
+constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/glue.cpp b/src/core/hle/service/glue/glue.cpp
index b24d469cf..717f2562b 100644
--- a/src/core/hle/service/glue/glue.cpp
+++ b/src/core/hle/service/glue/glue.cpp
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include "core/core.h"
diff --git a/src/core/hle/service/glue/glue.h b/src/core/hle/service/glue/glue.h
index 112cd238b..ae7c6d235 100644
--- a/src/core/hle/service/glue/glue.h
+++ b/src/core/hle/service/glue/glue.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/core/hle/service/glue/glue_manager.cpp b/src/core/hle/service/glue/glue_manager.cpp
index 48e133b48..8a654cdca 100644
--- a/src/core/hle/service/glue/glue_manager.cpp
+++ b/src/core/hle/service/glue/glue_manager.cpp
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/glue/errors.h"
#include "core/hle/service/glue/glue_manager.h"
@@ -42,8 +41,8 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
return iter->second.control;
}
-ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
- std::vector<u8> control) {
+Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
+ std::vector<u8> control) {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
}
@@ -57,7 +56,7 @@ ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
return ResultSuccess;
}
-ResultCode ARPManager::Unregister(u64 title_id) {
+Result ARPManager::Unregister(u64 title_id) {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
}
diff --git a/src/core/hle/service/glue/glue_manager.h b/src/core/hle/service/glue/glue_manager.h
index 4bc5297c6..cd0b092ac 100644
--- a/src/core/hle/service/glue/glue_manager.h
+++ b/src/core/hle/service/glue/glue_manager.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -43,12 +42,12 @@ public:
// Adds a new entry to the internal database with the provided parameters, returning
// ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
// step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
- ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
+ Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
// Removes the registration for the provided title ID from the database, returning
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
// title ID is 0.
- ResultCode Unregister(u64 title_id);
+ Result Unregister(u64 title_id);
// Removes all entries from the database, always succeeds. Should only be used when resetting
// system state.
diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp
index c559ec9df..3ace2dabd 100644
--- a/src/core/hle/service/glue/notif.cpp
+++ b/src/core/hle/service/glue/notif.cpp
@@ -1,7 +1,11 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <algorithm>
+#include <cstring>
+
+#include "common/assert.h"
+#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/glue/notif.h"
@@ -10,11 +14,11 @@ namespace Service::Glue {
NOTIF_A::NOTIF_A(Core::System& system_) : ServiceFramework{system_, "notif:a"} {
// clang-format off
static const FunctionInfo functions[] = {
- {500, nullptr, "RegisterAlarmSetting"},
- {510, nullptr, "UpdateAlarmSetting"},
+ {500, &NOTIF_A::RegisterAlarmSetting, "RegisterAlarmSetting"},
+ {510, &NOTIF_A::UpdateAlarmSetting, "UpdateAlarmSetting"},
{520, &NOTIF_A::ListAlarmSettings, "ListAlarmSettings"},
- {530, nullptr, "LoadApplicationParameter"},
- {540, nullptr, "DeleteAlarmSetting"},
+ {530, &NOTIF_A::LoadApplicationParameter, "LoadApplicationParameter"},
+ {540, &NOTIF_A::DeleteAlarmSetting, "DeleteAlarmSetting"},
{1000, &NOTIF_A::Initialize, "Initialize"},
};
// clang-format on
@@ -24,21 +28,132 @@ NOTIF_A::NOTIF_A(Core::System& system_) : ServiceFramework{system_, "notif:a"} {
NOTIF_A::~NOTIF_A() = default;
+void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) {
+ const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
+ const auto application_parameter_size = ctx.GetReadBufferSize(1);
+
+ ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
+ "alarm_setting_buffer_size is not 0x40 bytes");
+ ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
+ "application_parameter_size is bigger than 0x400 bytes");
+
+ AlarmSetting new_alarm{};
+ memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
+
+ // TODO: Count alarms per game id
+ if (alarms.size() >= max_alarms) {
+ LOG_ERROR(Service_NOTIF, "Alarm limit reached");
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultUnknown);
+ return;
+ }
+
+ new_alarm.alarm_setting_id = last_alarm_setting_id++;
+ alarms.push_back(new_alarm);
+
+ // TODO: Save application parameter data
+
+ LOG_WARNING(Service_NOTIF,
+ "(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
+ application_parameter_size, new_alarm.alarm_setting_id, new_alarm.kind,
+ new_alarm.muted);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ rb.Push(new_alarm.alarm_setting_id);
+}
+
+void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) {
+ const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
+ const auto application_parameter_size = ctx.GetReadBufferSize(1);
+
+ ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
+ "alarm_setting_buffer_size is not 0x40 bytes");
+ ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
+ "application_parameter_size is bigger than 0x400 bytes");
+
+ AlarmSetting alarm_setting{};
+ memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
+
+ const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id);
+ if (alarm_it != alarms.end()) {
+ LOG_DEBUG(Service_NOTIF, "Alarm updated");
+ *alarm_it = alarm_setting;
+ // TODO: Save application parameter data
+ }
+
+ LOG_WARNING(Service_NOTIF,
+ "(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
+ application_parameter_size, alarm_setting.alarm_setting_id, alarm_setting.kind,
+ alarm_setting.muted);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+}
+
void NOTIF_A::ListAlarmSettings(Kernel::HLERequestContext& ctx) {
- // Returns an array of AlarmSetting
- constexpr s32 alarm_count = 0;
+ LOG_INFO(Service_NOTIF, "called, alarm_count={}", alarms.size());
- LOG_WARNING(Service_NOTIF, "(STUBBED) called");
+ // TODO: Only return alarms of this game id
+ ctx.WriteBuffer(alarms);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
- rb.Push(alarm_count);
+ rb.Push(static_cast<u32>(alarms.size()));
+}
+
+void NOTIF_A::LoadApplicationParameter(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
+
+ const auto alarm_it = GetAlarmFromId(alarm_setting_id);
+ if (alarm_it == alarms.end()) {
+ LOG_ERROR(Service_NOTIF, "Invalid alarm setting id={}", alarm_setting_id);
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultUnknown);
+ return;
+ }
+
+ // TODO: Read application parameter related to this setting id
+ ApplicationParameter application_parameter{};
+
+ LOG_WARNING(Service_NOTIF, "(STUBBED) called, alarm_setting_id={}", alarm_setting_id);
+
+ ctx.WriteBuffer(application_parameter);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ rb.Push(static_cast<u32>(application_parameter.size()));
+}
+
+void NOTIF_A::DeleteAlarmSetting(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
+
+ std::erase_if(alarms, [alarm_setting_id](const AlarmSetting& alarm) {
+ return alarm.alarm_setting_id == alarm_setting_id;
+ });
+
+ LOG_INFO(Service_NOTIF, "called, alarm_setting_id={}", alarm_setting_id);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
}
void NOTIF_A::Initialize(Kernel::HLERequestContext& ctx) {
+ // TODO: Load previous alarms from config
+
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
+std::vector<NOTIF_A::AlarmSetting>::iterator NOTIF_A::GetAlarmFromId(
+ AlarmSettingId alarm_setting_id) {
+ return std::find_if(alarms.begin(), alarms.end(),
+ [alarm_setting_id](const AlarmSetting& alarm) {
+ return alarm.alarm_setting_id == alarm_setting_id;
+ });
+}
+
} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/notif.h b/src/core/hle/service/glue/notif.h
index 6ecf2015c..4467e1f35 100644
--- a/src/core/hle/service/glue/notif.h
+++ b/src/core/hle/service/glue/notif.h
@@ -1,9 +1,12 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
+#include <array>
+#include <vector>
+
+#include "common/uuid.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -18,8 +21,52 @@ public:
~NOTIF_A() override;
private:
+ static constexpr std::size_t max_alarms = 8;
+
+ // This is nn::notification::AlarmSettingId
+ using AlarmSettingId = u16;
+ static_assert(sizeof(AlarmSettingId) == 0x2, "AlarmSettingId is an invalid size");
+
+ using ApplicationParameter = std::array<u8, 0x400>;
+ static_assert(sizeof(ApplicationParameter) == 0x400, "ApplicationParameter is an invalid size");
+
+ struct DailyAlarmSetting {
+ s8 hour;
+ s8 minute;
+ };
+ static_assert(sizeof(DailyAlarmSetting) == 0x2, "DailyAlarmSetting is an invalid size");
+
+ struct WeeklyScheduleAlarmSetting {
+ INSERT_PADDING_BYTES(0xA);
+ std::array<DailyAlarmSetting, 0x7> day_of_week;
+ };
+ static_assert(sizeof(WeeklyScheduleAlarmSetting) == 0x18,
+ "WeeklyScheduleAlarmSetting is an invalid size");
+
+ // This is nn::notification::AlarmSetting
+ struct AlarmSetting {
+ AlarmSettingId alarm_setting_id;
+ u8 kind;
+ u8 muted;
+ INSERT_PADDING_BYTES(0x4);
+ Common::UUID account_id;
+ u64 application_id;
+ INSERT_PADDING_BYTES(0x8);
+ WeeklyScheduleAlarmSetting schedule;
+ };
+ static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size");
+
+ void RegisterAlarmSetting(Kernel::HLERequestContext& ctx);
+ void UpdateAlarmSetting(Kernel::HLERequestContext& ctx);
void ListAlarmSettings(Kernel::HLERequestContext& ctx);
+ void LoadApplicationParameter(Kernel::HLERequestContext& ctx);
+ void DeleteAlarmSetting(Kernel::HLERequestContext& ctx);
void Initialize(Kernel::HLERequestContext& ctx);
+
+ std::vector<AlarmSetting>::iterator GetAlarmFromId(AlarmSettingId alarm_setting_id);
+
+ std::vector<AlarmSetting> alarms{};
+ AlarmSettingId last_alarm_setting_id{};
};
} // namespace Service::Glue