summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp8
-rw-r--r--src/core/hle/kernel/k_process.cpp11
-rw-r--r--src/core/hle/kernel/k_process.h3
-rw-r--r--src/core/hle/kernel/svc.cpp130
-rw-r--r--src/core/hle/service/set/set.cpp9
-rw-r--r--src/core/hle/service/set/set.h1
-rw-r--r--src/core/hle/service/set/set_sys.cpp10
-rw-r--r--src/core/hle/service/set/set_sys.h1
8 files changed, 91 insertions, 82 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 06010b8d1..e6479c131 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -167,6 +167,9 @@ void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32
}
if (incoming) {
// Populate the object lists with the data in the IPC request.
+ incoming_copy_handles.reserve(handle_descriptor_header->num_handles_to_copy);
+ incoming_move_handles.reserve(handle_descriptor_header->num_handles_to_move);
+
for (u32 handle = 0; handle < handle_descriptor_header->num_handles_to_copy; ++handle) {
incoming_copy_handles.push_back(rp.Pop<Handle>());
}
@@ -181,6 +184,11 @@ void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32
}
}
+ buffer_x_desciptors.reserve(command_header->num_buf_x_descriptors);
+ buffer_a_desciptors.reserve(command_header->num_buf_a_descriptors);
+ buffer_b_desciptors.reserve(command_header->num_buf_b_descriptors);
+ buffer_w_desciptors.reserve(command_header->num_buf_w_descriptors);
+
for (u32 i = 0; i < command_header->num_buf_x_descriptors; ++i) {
buffer_x_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorX>());
}
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index d1dc62401..a1abf5d68 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -285,6 +285,17 @@ void KProcess::UnregisterThread(KThread* thread) {
thread_list.remove(thread);
}
+u64 KProcess::GetFreeThreadCount() const {
+ if (resource_limit != nullptr) {
+ const auto current_value =
+ resource_limit->GetCurrentValue(LimitableResource::ThreadCountMax);
+ const auto limit_value = resource_limit->GetLimitValue(LimitableResource::ThreadCountMax);
+ return limit_value - current_value;
+ } else {
+ return 0;
+ }
+}
+
Result KProcess::Reset() {
// Lock the process and the scheduler.
KScopedLightLock lk(state_lock);
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index 2e0cc3d0b..09bf2f1d0 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -304,6 +304,9 @@ public:
/// from this process' thread list.
void UnregisterThread(KThread* thread);
+ /// Retrieves the number of available threads for this process.
+ u64 GetFreeThreadCount() const;
+
/// Clears the signaled state of the process if and only if it's signaled.
///
/// @pre The process must not be already terminated. If this is called on a
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index e520cab47..788ee2160 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -784,63 +784,29 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
info_sub_id, handle);
- enum class GetInfoType : u64 {
- // 1.0.0+
- AllowedCPUCoreMask = 0,
- AllowedThreadPriorityMask = 1,
- MapRegionBaseAddr = 2,
- MapRegionSize = 3,
- HeapRegionBaseAddr = 4,
- HeapRegionSize = 5,
- TotalPhysicalMemoryAvailable = 6,
- TotalPhysicalMemoryUsed = 7,
- IsCurrentProcessBeingDebugged = 8,
- RegisterResourceLimit = 9,
- IdleTickCount = 10,
- RandomEntropy = 11,
- ThreadTickCount = 0xF0000002,
- // 2.0.0+
- ASLRRegionBaseAddr = 12,
- ASLRRegionSize = 13,
- StackRegionBaseAddr = 14,
- StackRegionSize = 15,
- // 3.0.0+
- SystemResourceSize = 16,
- SystemResourceUsage = 17,
- TitleId = 18,
- // 4.0.0+
- PrivilegedProcessId = 19,
- // 5.0.0+
- UserExceptionContextAddr = 20,
- // 6.0.0+
- TotalPhysicalMemoryAvailableWithoutSystemResource = 21,
- TotalPhysicalMemoryUsedWithoutSystemResource = 22,
-
- // Homebrew only
- MesosphereCurrentProcess = 65001,
- };
-
- const auto info_id_type = static_cast<GetInfoType>(info_id);
+ const auto info_id_type = static_cast<InfoType>(info_id);
switch (info_id_type) {
- case GetInfoType::AllowedCPUCoreMask:
- case GetInfoType::AllowedThreadPriorityMask:
- case GetInfoType::MapRegionBaseAddr:
- case GetInfoType::MapRegionSize:
- case GetInfoType::HeapRegionBaseAddr:
- case GetInfoType::HeapRegionSize:
- case GetInfoType::ASLRRegionBaseAddr:
- case GetInfoType::ASLRRegionSize:
- case GetInfoType::StackRegionBaseAddr:
- case GetInfoType::StackRegionSize:
- case GetInfoType::TotalPhysicalMemoryAvailable:
- case GetInfoType::TotalPhysicalMemoryUsed:
- case GetInfoType::SystemResourceSize:
- case GetInfoType::SystemResourceUsage:
- case GetInfoType::TitleId:
- case GetInfoType::UserExceptionContextAddr:
- case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource:
- case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: {
+ case InfoType::CoreMask:
+ case InfoType::PriorityMask:
+ case InfoType::AliasRegionAddress:
+ case InfoType::AliasRegionSize:
+ case InfoType::HeapRegionAddress:
+ case InfoType::HeapRegionSize:
+ case InfoType::AslrRegionAddress:
+ case InfoType::AslrRegionSize:
+ case InfoType::StackRegionAddress:
+ case InfoType::StackRegionSize:
+ case InfoType::TotalMemorySize:
+ case InfoType::UsedMemorySize:
+ case InfoType::SystemResourceSizeTotal:
+ case InfoType::SystemResourceSizeUsed:
+ case InfoType::ProgramId:
+ case InfoType::UserExceptionContextAddress:
+ case InfoType::TotalNonSystemMemorySize:
+ case InfoType::UsedNonSystemMemorySize:
+ case InfoType::IsApplication:
+ case InfoType::FreeThreadCount: {
if (info_sub_id != 0) {
LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id,
info_sub_id);
@@ -856,79 +822,83 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
}
switch (info_id_type) {
- case GetInfoType::AllowedCPUCoreMask:
+ case InfoType::CoreMask:
*result = process->GetCoreMask();
return ResultSuccess;
- case GetInfoType::AllowedThreadPriorityMask:
+ case InfoType::PriorityMask:
*result = process->GetPriorityMask();
return ResultSuccess;
- case GetInfoType::MapRegionBaseAddr:
+ case InfoType::AliasRegionAddress:
*result = process->PageTable().GetAliasRegionStart();
return ResultSuccess;
- case GetInfoType::MapRegionSize:
+ case InfoType::AliasRegionSize:
*result = process->PageTable().GetAliasRegionSize();
return ResultSuccess;
- case GetInfoType::HeapRegionBaseAddr:
+ case InfoType::HeapRegionAddress:
*result = process->PageTable().GetHeapRegionStart();
return ResultSuccess;
- case GetInfoType::HeapRegionSize:
+ case InfoType::HeapRegionSize:
*result = process->PageTable().GetHeapRegionSize();
return ResultSuccess;
- case GetInfoType::ASLRRegionBaseAddr:
+ case InfoType::AslrRegionAddress:
*result = process->PageTable().GetAliasCodeRegionStart();
return ResultSuccess;
- case GetInfoType::ASLRRegionSize:
+ case InfoType::AslrRegionSize:
*result = process->PageTable().GetAliasCodeRegionSize();
return ResultSuccess;
- case GetInfoType::StackRegionBaseAddr:
+ case InfoType::StackRegionAddress:
*result = process->PageTable().GetStackRegionStart();
return ResultSuccess;
- case GetInfoType::StackRegionSize:
+ case InfoType::StackRegionSize:
*result = process->PageTable().GetStackRegionSize();
return ResultSuccess;
- case GetInfoType::TotalPhysicalMemoryAvailable:
+ case InfoType::TotalMemorySize:
*result = process->GetTotalPhysicalMemoryAvailable();
return ResultSuccess;
- case GetInfoType::TotalPhysicalMemoryUsed:
+ case InfoType::UsedMemorySize:
*result = process->GetTotalPhysicalMemoryUsed();
return ResultSuccess;
- case GetInfoType::SystemResourceSize:
+ case InfoType::SystemResourceSizeTotal:
*result = process->GetSystemResourceSize();
return ResultSuccess;
- case GetInfoType::SystemResourceUsage:
+ case InfoType::SystemResourceSizeUsed:
LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage");
*result = process->GetSystemResourceUsage();
return ResultSuccess;
- case GetInfoType::TitleId:
+ case InfoType::ProgramId:
*result = process->GetProgramID();
return ResultSuccess;
- case GetInfoType::UserExceptionContextAddr:
+ case InfoType::UserExceptionContextAddress:
*result = process->GetProcessLocalRegionAddress();
return ResultSuccess;
- case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource:
+ case InfoType::TotalNonSystemMemorySize:
*result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource();
return ResultSuccess;
- case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource:
+ case InfoType::UsedNonSystemMemorySize:
*result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource();
return ResultSuccess;
+ case InfoType::FreeThreadCount:
+ *result = process->GetFreeThreadCount();
+ return ResultSuccess;
+
default:
break;
}
@@ -937,11 +907,11 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
return ResultInvalidEnumValue;
}
- case GetInfoType::IsCurrentProcessBeingDebugged:
+ case InfoType::DebuggerAttached:
*result = 0;
return ResultSuccess;
- case GetInfoType::RegisterResourceLimit: {
+ case InfoType::ResourceLimit: {
if (handle != 0) {
LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle);
return ResultInvalidHandle;
@@ -969,7 +939,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
return ResultSuccess;
}
- case GetInfoType::RandomEntropy:
+ case InfoType::RandomEntropy:
if (handle != 0) {
LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}",
handle);
@@ -985,13 +955,13 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
*result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id);
return ResultSuccess;
- case GetInfoType::PrivilegedProcessId:
+ case InfoType::InitialProcessIdRange:
LOG_WARNING(Kernel_SVC,
"(STUBBED) Attempted to query privileged process id bounds, returned 0");
*result = 0;
return ResultSuccess;
- case GetInfoType::ThreadTickCount: {
+ case InfoType::ThreadTickCount: {
constexpr u64 num_cpus = 4;
if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) {
LOG_ERROR(Kernel_SVC, "Core count is out of range, expected {} but got {}", num_cpus,
@@ -1026,7 +996,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
*result = out_ticks;
return ResultSuccess;
}
- case GetInfoType::IdleTickCount: {
+ case InfoType::IdleTickCount: {
// Verify the input handle is invalid.
R_UNLESS(handle == InvalidHandle, ResultInvalidHandle);
@@ -1040,7 +1010,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
*result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime();
return ResultSuccess;
}
- case GetInfoType::MesosphereCurrentProcess: {
+ case InfoType::MesosphereCurrentProcess: {
// Verify the input handle is invalid.
R_UNLESS(handle == InvalidHandle, ResultInvalidHandle);
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index 4f1a8d6b7..16c5eaf75 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -191,6 +191,13 @@ void SET::GetKeyCodeMap2(Kernel::HLERequestContext& ctx) {
GetKeyCodeMapImpl(ctx);
}
+void SET::GetDeviceNickName(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_SET, "called");
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ ctx.WriteBuffer(Settings::values.device_name.GetValue());
+}
+
SET::SET(Core::System& system_) : ServiceFramework{system_, "set"} {
// clang-format off
static const FunctionInfo functions[] = {
@@ -205,7 +212,7 @@ SET::SET(Core::System& system_) : ServiceFramework{system_, "set"} {
{8, &SET::GetQuestFlag, "GetQuestFlag"},
{9, &SET::GetKeyCodeMap2, "GetKeyCodeMap2"},
{10, nullptr, "GetFirmwareVersionForDebug"},
- {11, nullptr, "GetDeviceNickName"},
+ {11, &SET::GetDeviceNickName, "GetDeviceNickName"},
};
// clang-format on
diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h
index 60cad3e6f..375975711 100644
--- a/src/core/hle/service/set/set.h
+++ b/src/core/hle/service/set/set.h
@@ -50,6 +50,7 @@ private:
void GetRegionCode(Kernel::HLERequestContext& ctx);
void GetKeyCodeMap(Kernel::HLERequestContext& ctx);
void GetKeyCodeMap2(Kernel::HLERequestContext& ctx);
+ void GetDeviceNickName(Kernel::HLERequestContext& ctx);
};
} // namespace Service::Set
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index d7cea6aac..94c20edda 100644
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -3,6 +3,7 @@
#include "common/assert.h"
#include "common/logging/log.h"
+#include "common/settings.h"
#include "core/file_sys/errors.h"
#include "core/file_sys/system_archive/system_version.h"
#include "core/hle/ipc_helpers.h"
@@ -176,6 +177,13 @@ void SET_SYS::GetSettingsItemValue(Kernel::HLERequestContext& ctx) {
rb.Push(response);
}
+void SET_SYS::GetDeviceNickName(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_SET, "called");
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ ctx.WriteBuffer(::Settings::values.device_name.GetValue());
+}
+
SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
// clang-format off
static const FunctionInfo functions[] = {
@@ -253,7 +261,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
{74, nullptr, "SetWirelessLanEnableFlag"},
{75, nullptr, "GetInitialLaunchSettings"},
{76, nullptr, "SetInitialLaunchSettings"},
- {77, nullptr, "GetDeviceNickName"},
+ {77, &SET_SYS::GetDeviceNickName, "GetDeviceNickName"},
{78, nullptr, "SetDeviceNickName"},
{79, nullptr, "GetProductModel"},
{80, nullptr, "GetLdnChannel"},
diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h
index 258ef8c57..464ac3da1 100644
--- a/src/core/hle/service/set/set_sys.h
+++ b/src/core/hle/service/set/set_sys.h
@@ -29,6 +29,7 @@ private:
void GetFirmwareVersion2(Kernel::HLERequestContext& ctx);
void GetColorSetId(Kernel::HLERequestContext& ctx);
void SetColorSetId(Kernel::HLERequestContext& ctx);
+ void GetDeviceNickName(Kernel::HLERequestContext& ctx);
ColorSet color_set = ColorSet::BasicWhite;
};