From c90337211167a22cd431f2d5b8e31a64794eb334 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Tue, 16 Jan 2018 13:53:43 -0800 Subject: [PATCH 1/5] Increased heap size and changed tls area vaddr --- src/core/memory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/memory.h b/src/core/memory.h index 91bd4d889..336d46f75 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -136,7 +136,7 @@ enum : VAddr { /// Application heap (includes stack). HEAP_VADDR = 0x108000000, - HEAP_SIZE = 0x18000000, + HEAP_SIZE = 0xF0000000, // 0x18000000, HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, /// Area where shared memory buffers are mapped onto. @@ -177,7 +177,7 @@ enum : VAddr { SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, /// Area where TLS (Thread-Local Storage) buffers are allocated. - TLS_AREA_VADDR = 0x1FF82000, + TLS_AREA_VADDR = 0x228000000, // 0x1FF82000, TLS_ENTRY_SIZE = 0x200, /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS. From 68143af6369c1f3349a455fbf94d1bc77ad55957 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Tue, 16 Jan 2018 14:06:45 -0800 Subject: [PATCH 2/5] Added more svcGetInfo pairs --- src/core/hle/kernel/process.h | 2 ++ src/core/hle/kernel/svc.cpp | 12 ++++++++++++ src/core/hle/kernel/svc.h | 13 +++++++++++++ src/core/hle/kernel/vm_manager.cpp | 4 ++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 20b4e401c..add98472f 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -131,6 +131,8 @@ public: /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse /// this value from the process header. u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; + u32 allowed_thread_priority_mask = 0xFFFFFFFF; + u32 is_virtual_address_memory_enabled = 0; /// Current status of the process ProcessStatus status; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9c60576c1..2f1b79f32 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -313,6 +313,15 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) case GetInfoType::AllowedCpuIdBitmask: *result = g_current_process->allowed_processor_mask; break; + case GetInfoType::AllowedThreadPrioBitmask: + *result = g_current_process->allowed_thread_priority_mask; + break; + case GetInfoType::MapRegionBaseAddr: + *result = vm_manager.GetAddressSpaceBaseAddr(); + break; + case GetInfoType::MapRegionSize: + *result = vm_manager.GetAddressSpaceSize(); + break; case GetInfoType::TotalMemoryUsage: *result = vm_manager.GetTotalMemoryUsage(); break; @@ -334,6 +343,9 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) case GetInfoType::NewMapRegionSize: *result = vm_manager.GetNewMapRegionSize(); break; + case GetInfoType::IsVirtualAddressMemoryEnabled: + *result = g_current_process->is_virtual_address_memory_enabled; + break; default: UNIMPLEMENTED(); } diff --git a/src/core/hle/kernel/svc.h b/src/core/hle/kernel/svc.h index 610cd1d7d..a56fd3602 100644 --- a/src/core/hle/kernel/svc.h +++ b/src/core/hle/kernel/svc.h @@ -24,14 +24,27 @@ struct PageInfo { enum class GetInfoType : u64 { // 1.0.0+ AllowedCpuIdBitmask = 0, + AllowedThreadPrioBitmask = 1, + MapRegionBaseAddr = 2, + MapRegionSize = 3, + HeapRegionBaseAddr = 4, + HeapRegionSize = 5, TotalMemoryUsage = 6, TotalHeapUsage = 7, + IsCurrentProcessBeingDebugged = 8, + ResourceHandleLimit = 9, + IdleTickCount = 10, RandomEntropy = 11, + PerformanceCounter = 0xF0000002, // 2.0.0+ AddressSpaceBaseAddr = 12, AddressSpaceSize = 13, NewMapRegionBaseAddr = 14, NewMapRegionSize = 15, + // 3.0.0+ + IsVirtualAddressMemoryEnabled = 16, + TitleId = 18, + PrivilegedProcessId = 19, }; void CallSVC(u32 immediate); diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index dca637dde..d6d0ad996 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -356,12 +356,12 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { u64 VMManager::GetTotalMemoryUsage() { LOG_WARNING(Kernel, "(STUBBED) called"); - return 0x400000; + return 0xBE000000; } u64 VMManager::GetTotalHeapUsage() { LOG_WARNING(Kernel, "(STUBBED) called"); - return 0x10000; + return 0x0; } VAddr VMManager::GetAddressSpaceBaseAddr() { From 104dd867c413b78d09e14bc453a7c37c5f6665c9 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Tue, 16 Jan 2018 14:18:18 -0800 Subject: [PATCH 3/5] implemented more of ISelfController and IApplicationFunctions --- src/core/hle/service/am/applet_oe.cpp | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index f65d6b9f5..b629ac509 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp @@ -54,7 +54,14 @@ class ISelfController final : public ServiceFramework { public: ISelfController() : ServiceFramework("ISelfController") { static const FunctionInfo functions[] = { + {11, &ISelfController::SetOperationModeChangedNotification, + "SetOperationModeChangedNotification"}, + {12, &ISelfController::SetPerformanceModeChangedNotification, + "SetPerformanceModeChangedNotification"}, {13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"}, + {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"}, + {16, &ISelfController::SetOutOfFocusSuspendingEnabled, + "SetOutOfFocusSuspendingEnabled"}, }; RegisterHandlers(functions); } @@ -69,6 +76,37 @@ private: LOG_WARNING(Service, "(STUBBED) called"); } + + void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) { + // Takes 3 input u8s with each field located immediately after the previous u8, these are + // bool flags. No output. + + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service, "(STUBBED) called"); + } }; class ICommonStateGetter final : public ServiceFramework { @@ -119,6 +157,9 @@ public: IApplicationFunctions() : ServiceFramework("IApplicationFunctions") { static const FunctionInfo functions[] = { {22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"}, + {66, &IApplicationFunctions::InitializeGamePlayRecording, + "InitializeGamePlayRecording"}, + {67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"}, }; RegisterHandlers(functions); } @@ -136,6 +177,18 @@ private: LOG_WARNING(Service, "(STUBBED) called, result=0x%08X", result); } + + void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + LOG_WARNING(Service, "(STUBBED) called"); + } + + void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) { + IPC::RequestBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + LOG_WARNING(Service, "(STUBBED) called"); + } }; class ILibraryAppletCreator final : public ServiceFramework { From bb7221c5d55bc42e63e72d7779709d2193c37b53 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Tue, 16 Jan 2018 14:23:53 -0800 Subject: [PATCH 4/5] SetThreadCoreMask stub, time to implement fsp --- src/core/hle/kernel/svc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 2f1b79f32..eb42123dc 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -721,6 +721,11 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 return RESULT_SUCCESS; } +static ResultCode SetThreadCoreMask(u64, u64, u64) { + LOG_WARNING(Kernel_SVC, "(STUBBED) called"); + return RESULT_SUCCESS; +} + namespace { struct FunctionDef { using Func = void(); @@ -747,7 +752,7 @@ static const FunctionDef SVC_Table[] = { {0x0C, SvcWrap, "GetThreadPriority"}, {0x0D, SvcWrap, "SetThreadPriority"}, {0x0E, nullptr, "GetThreadCoreMask"}, - {0x0F, nullptr, "SetThreadCoreMask"}, + {0x0F, SvcWrap, "SetThreadCoreMask"}, {0x10, SvcWrap, "GetCurrentProcessorNumber"}, {0x11, nullptr, "SignalEvent"}, {0x12, nullptr, "ClearEvent"}, From cb8d5328d537658ce714e4f3ea9dcac5e03a8cf7 Mon Sep 17 00:00:00 2001 From: David <25727384+ogniK5377@users.noreply.github.com> Date: Tue, 16 Jan 2018 15:27:13 -0800 Subject: [PATCH 5/5] Update memory.h --- src/core/memory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/memory.h b/src/core/memory.h index 336d46f75..7e554f394 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -136,7 +136,7 @@ enum : VAddr { /// Application heap (includes stack). HEAP_VADDR = 0x108000000, - HEAP_SIZE = 0xF0000000, // 0x18000000, + HEAP_SIZE = 0xF0000000, HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, /// Area where shared memory buffers are mapped onto. @@ -177,7 +177,7 @@ enum : VAddr { SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, /// Area where TLS (Thread-Local Storage) buffers are allocated. - TLS_AREA_VADDR = 0x228000000, // 0x1FF82000, + TLS_AREA_VADDR = 0x228000000, TLS_ENTRY_SIZE = 0x200, /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS.