diff options
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/process.cpp | 18 | ||||
-rw-r--r-- | src/core/hle/kernel/process.h | 14 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 34 | ||||
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.h | 2 |
6 files changed, 60 insertions, 18 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 0775a89fb..2b81a8d4f 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -48,7 +48,7 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) { } } // Anonymous namespace -SharedPtr<Process> Process::Create(Core::System& system, std::string&& name) { +SharedPtr<Process> Process::Create(Core::System& system, std::string name) { auto& kernel = system.Kernel(); SharedPtr<Process> process(new Process(system)); @@ -72,10 +72,26 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const { return resource_limit; } +u64 Process::GetTotalPhysicalMemoryAvailable() const { + return vm_manager.GetTotalPhysicalMemoryAvailable(); +} + +u64 Process::GetTotalPhysicalMemoryAvailableWithoutMmHeap() const { + // TODO: Subtract the personal heap size from this when the + // personal heap is implemented. + return GetTotalPhysicalMemoryAvailable(); +} + u64 Process::GetTotalPhysicalMemoryUsed() const { return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size; } +u64 Process::GetTotalPhysicalMemoryUsedWithoutMmHeap() const { + // TODO: Subtract the personal heap size from this when the + // personal heap is implemented. + return GetTotalPhysicalMemoryUsed(); +} + void Process::RegisterThread(const Thread* thread) { thread_list.push_back(thread); } diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index bf3b7eef3..29e016983 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -10,7 +10,6 @@ #include <list> #include <string> #include <vector> -#include <boost/container/static_vector.hpp> #include "common/common_types.h" #include "core/hle/kernel/address_arbiter.h" #include "core/hle/kernel/handle_table.h" @@ -76,7 +75,7 @@ public: static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; - static SharedPtr<Process> Create(Core::System& system, std::string&& name); + static SharedPtr<Process> Create(Core::System& system, std::string name); std::string GetTypeName() const override { return "Process"; @@ -187,9 +186,20 @@ public: return random_entropy.at(index); } + /// Retrieves the total physical memory available to this process in bytes. + u64 GetTotalPhysicalMemoryAvailable() const; + + /// Retrieves the total physical memory available to this process in bytes, + /// without the size of the personal heap added to it. + u64 GetTotalPhysicalMemoryAvailableWithoutMmHeap() const; + /// Retrieves the total physical memory used by this process in bytes. u64 GetTotalPhysicalMemoryUsed() const; + /// Retrieves the total physical memory used by this process in bytes, + /// without the size of the personal heap added to it. + u64 GetTotalPhysicalMemoryUsedWithoutMmHeap() const; + /// Gets the list of all threads created with this process as their owner. const std::list<const Thread*>& GetThreadList() const { return thread_list; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 5a5851f66..de6363ff2 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -38,6 +38,7 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" #include "core/memory.h" +#include "core/reporter.h" namespace Kernel { namespace { @@ -594,6 +595,7 @@ struct BreakReason { static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { BreakReason break_reason{reason}; bool has_dumped_buffer{}; + std::vector<u8> debug_buffer; const auto handle_debug_buffer = [&](VAddr addr, u64 sz) { if (sz == 0 || addr == 0 || has_dumped_buffer) { @@ -605,7 +607,7 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { LOG_CRITICAL(Debug_Emulated, "debug_buffer_err_code={:X}", Memory::Read32(addr)); } else { // We don't know what's in here so we'll hexdump it - std::vector<u8> debug_buffer(sz); + debug_buffer.resize(sz); Memory::ReadBlock(addr, debug_buffer.data(), sz); std::string hexdump; for (std::size_t i = 0; i < debug_buffer.size(); i++) { @@ -664,6 +666,10 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { break; } + system.GetReporter().SaveSvcBreakReport( + static_cast<u32>(break_reason.break_type.Value()), break_reason.signal_debugger, info1, + info2, has_dumped_buffer ? std::make_optional(debug_buffer) : std::nullopt); + if (!break_reason.signal_debugger) { LOG_CRITICAL( Debug_Emulated, @@ -710,13 +716,13 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha MapRegionSize = 3, HeapRegionBaseAddr = 4, HeapRegionSize = 5, - TotalMemoryUsage = 6, + TotalPhysicalMemoryAvailable = 6, TotalPhysicalMemoryUsed = 7, IsCurrentProcessBeingDebugged = 8, RegisterResourceLimit = 9, IdleTickCount = 10, RandomEntropy = 11, - PerformanceCounter = 0xF0000002, + ThreadTickCount = 0xF0000002, // 2.0.0+ ASLRRegionBaseAddr = 12, ASLRRegionSize = 13, @@ -730,7 +736,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha PrivilegedProcessId = 19, // 5.0.0+ UserExceptionContextAddr = 20, - ThreadTickCount = 0xF0000002, + // 6.0.0+ + TotalPhysicalMemoryAvailableWithoutMmHeap = 21, + TotalPhysicalMemoryUsedWithoutMmHeap = 22, }; const auto info_id_type = static_cast<GetInfoType>(info_id); @@ -746,12 +754,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha case GetInfoType::ASLRRegionSize: case GetInfoType::NewMapRegionBaseAddr: case GetInfoType::NewMapRegionSize: - case GetInfoType::TotalMemoryUsage: + case GetInfoType::TotalPhysicalMemoryAvailable: case GetInfoType::TotalPhysicalMemoryUsed: case GetInfoType::IsVirtualAddressMemoryEnabled: case GetInfoType::PersonalMmHeapUsage: case GetInfoType::TitleId: - case GetInfoType::UserExceptionContextAddr: { + case GetInfoType::UserExceptionContextAddr: + case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap: + case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap: { if (info_sub_id != 0) { return ERR_INVALID_ENUM_VALUE; } @@ -804,8 +814,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha *result = process->VMManager().GetNewMapRegionSize(); return RESULT_SUCCESS; - case GetInfoType::TotalMemoryUsage: - *result = process->VMManager().GetTotalMemoryUsage(); + case GetInfoType::TotalPhysicalMemoryAvailable: + *result = process->GetTotalPhysicalMemoryAvailable(); return RESULT_SUCCESS; case GetInfoType::TotalPhysicalMemoryUsed: @@ -826,6 +836,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha *result = 0; return RESULT_SUCCESS; + case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap: + *result = process->GetTotalPhysicalMemoryAvailable(); + return RESULT_SUCCESS; + + case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap: + *result = process->GetTotalPhysicalMemoryUsedWithoutMmHeap(); + return RESULT_SUCCESS; + default: break; } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 2abf9efca..c73a40977 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -75,9 +75,9 @@ void Thread::WakeAfterDelay(s64 nanoseconds) { // This function might be called from any thread so we have to be cautious and use the // thread-safe version of ScheduleEvent. + const s64 cycles = Core::Timing::nsToCycles(std::chrono::nanoseconds{nanoseconds}); Core::System::GetInstance().CoreTiming().ScheduleEventThreadsafe( - Core::Timing::nsToCycles(nanoseconds), kernel.ThreadWakeupCallbackEventType(), - callback_handle); + cycles, kernel.ThreadWakeupCallbackEventType(), callback_handle); } void Thread::CancelWakeupTimer() { diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 48b13cfdd..c929c2a52 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -68,9 +68,7 @@ VMManager::VMManager(Core::System& system) : system{system} { Reset(FileSys::ProgramAddressSpaceType::Is39Bit); } -VMManager::~VMManager() { - Reset(FileSys::ProgramAddressSpaceType::Is39Bit); -} +VMManager::~VMManager() = default; void VMManager::Reset(FileSys::ProgramAddressSpaceType type) { Clear(); @@ -758,7 +756,7 @@ VMManager::CheckResults VMManager::CheckRangeState(VAddr address, u64 size, Memo std::make_tuple(initial_state, initial_permissions, initial_attributes & ~ignore_mask)); } -u64 VMManager::GetTotalMemoryUsage() const { +u64 VMManager::GetTotalPhysicalMemoryAvailable() const { LOG_WARNING(Kernel, "(STUBBED) called"); return 0xF8000000; } diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index ec84d9a70..dfbf7a894 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -499,7 +499,7 @@ public: void LogLayout() const; /// Gets the total memory usage, used by svcGetInfo - u64 GetTotalMemoryUsage() const; + u64 GetTotalPhysicalMemoryAvailable() const; /// Gets the address space base address VAddr GetAddressSpaceBaseAddress() const; |