diff options
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 20 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 45 | ||||
-rw-r--r-- | src/core/hle/kernel/vm_manager.h | 20 | ||||
-rw-r--r-- | src/core/hle/service/am/am.cpp | 26 | ||||
-rw-r--r-- | src/core/hle/service/am/am.h | 1 | ||||
-rw-r--r-- | src/core/memory.cpp | 2 | ||||
-rw-r--r-- | src/core/memory.h | 4 |
7 files changed, 68 insertions, 50 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index de6363ff2..332573a95 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -98,9 +98,9 @@ ResultCode MapUnmapMemorySanityChecks(const VMManager& vm_manager, VAddr dst_add return ERR_INVALID_ADDRESS_STATE; } - if (!vm_manager.IsWithinNewMapRegion(dst_addr, size)) { + if (!vm_manager.IsWithinStackRegion(dst_addr, size)) { LOG_ERROR(Kernel_SVC, - "Destination is not within the new map region, addr=0x{:016X}, size=0x{:016X}", + "Destination is not within the stack region, addr=0x{:016X}, size=0x{:016X}", dst_addr, size); return ERR_INVALID_MEMORY_RANGE; } @@ -726,8 +726,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha // 2.0.0+ ASLRRegionBaseAddr = 12, ASLRRegionSize = 13, - NewMapRegionBaseAddr = 14, - NewMapRegionSize = 15, + StackRegionBaseAddr = 14, + StackRegionSize = 15, // 3.0.0+ IsVirtualAddressMemoryEnabled = 16, PersonalMmHeapUsage = 17, @@ -752,8 +752,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha case GetInfoType::HeapRegionSize: case GetInfoType::ASLRRegionBaseAddr: case GetInfoType::ASLRRegionSize: - case GetInfoType::NewMapRegionBaseAddr: - case GetInfoType::NewMapRegionSize: + case GetInfoType::StackRegionBaseAddr: + case GetInfoType::StackRegionSize: case GetInfoType::TotalPhysicalMemoryAvailable: case GetInfoType::TotalPhysicalMemoryUsed: case GetInfoType::IsVirtualAddressMemoryEnabled: @@ -806,12 +806,12 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha *result = process->VMManager().GetASLRRegionSize(); return RESULT_SUCCESS; - case GetInfoType::NewMapRegionBaseAddr: - *result = process->VMManager().GetNewMapRegionBaseAddress(); + case GetInfoType::StackRegionBaseAddr: + *result = process->VMManager().GetStackRegionBaseAddress(); return RESULT_SUCCESS; - case GetInfoType::NewMapRegionSize: - *result = process->VMManager().GetNewMapRegionSize(); + case GetInfoType::StackRegionSize: + *result = process->VMManager().GetStackRegionSize(); return RESULT_SUCCESS; case GetInfoType::TotalPhysicalMemoryAvailable: diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 3df5ccb7f..501544090 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -625,9 +625,11 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType type) { u64 map_region_size = 0; u64 heap_region_size = 0; - u64 new_map_region_size = 0; + u64 stack_region_size = 0; u64 tls_io_region_size = 0; + u64 stack_and_tls_io_end = 0; + switch (type) { case FileSys::ProgramAddressSpaceType::Is32Bit: case FileSys::ProgramAddressSpaceType::Is32BitNoMap: @@ -643,6 +645,7 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty map_region_size = 0; heap_region_size = 0x80000000; } + stack_and_tls_io_end = 0x40000000; break; case FileSys::ProgramAddressSpaceType::Is36Bit: address_space_width = 36; @@ -652,6 +655,7 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty aslr_region_end = aslr_region_base + 0xFF8000000; map_region_size = 0x180000000; heap_region_size = 0x180000000; + stack_and_tls_io_end = 0x80000000; break; case FileSys::ProgramAddressSpaceType::Is39Bit: address_space_width = 39; @@ -661,7 +665,7 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty aslr_region_end = aslr_region_base + 0x7FF8000000; map_region_size = 0x1000000000; heap_region_size = 0x180000000; - new_map_region_size = 0x80000000; + stack_region_size = 0x80000000; tls_io_region_size = 0x1000000000; break; default: @@ -669,6 +673,8 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty return; } + const u64 stack_and_tls_io_begin = aslr_region_base; + address_space_base = 0; address_space_end = 1ULL << address_space_width; @@ -679,15 +685,20 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty heap_region_end = heap_region_base + heap_region_size; heap_end = heap_region_base; - new_map_region_base = heap_region_end; - new_map_region_end = new_map_region_base + new_map_region_size; + stack_region_base = heap_region_end; + stack_region_end = stack_region_base + stack_region_size; - tls_io_region_base = new_map_region_end; + tls_io_region_base = stack_region_end; tls_io_region_end = tls_io_region_base + tls_io_region_size; - if (new_map_region_size == 0) { - new_map_region_base = address_space_base; - new_map_region_end = address_space_end; + if (stack_region_size == 0) { + stack_region_base = stack_and_tls_io_begin; + stack_region_end = stack_and_tls_io_end; + } + + if (tls_io_region_size == 0) { + tls_io_region_base = stack_and_tls_io_begin; + tls_io_region_end = stack_and_tls_io_end; } } @@ -879,21 +890,21 @@ bool VMManager::IsWithinMapRegion(VAddr address, u64 size) const { return IsInsideAddressRange(address, size, GetMapRegionBaseAddress(), GetMapRegionEndAddress()); } -VAddr VMManager::GetNewMapRegionBaseAddress() const { - return new_map_region_base; +VAddr VMManager::GetStackRegionBaseAddress() const { + return stack_region_base; } -VAddr VMManager::GetNewMapRegionEndAddress() const { - return new_map_region_end; +VAddr VMManager::GetStackRegionEndAddress() const { + return stack_region_end; } -u64 VMManager::GetNewMapRegionSize() const { - return new_map_region_end - new_map_region_base; +u64 VMManager::GetStackRegionSize() const { + return stack_region_end - stack_region_base; } -bool VMManager::IsWithinNewMapRegion(VAddr address, u64 size) const { - return IsInsideAddressRange(address, size, GetNewMapRegionBaseAddress(), - GetNewMapRegionEndAddress()); +bool VMManager::IsWithinStackRegion(VAddr address, u64 size) const { + return IsInsideAddressRange(address, size, GetStackRegionBaseAddress(), + GetStackRegionEndAddress()); } VAddr VMManager::GetTLSIORegionBaseAddress() const { diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 752ae62f9..9fe6ac3f4 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -596,17 +596,17 @@ public: /// Determines whether or not the specified range is within the map region. bool IsWithinMapRegion(VAddr address, u64 size) const; - /// Gets the base address of the new map region. - VAddr GetNewMapRegionBaseAddress() const; + /// Gets the base address of the stack region. + VAddr GetStackRegionBaseAddress() const; - /// Gets the end address of the new map region. - VAddr GetNewMapRegionEndAddress() const; + /// Gets the end address of the stack region. + VAddr GetStackRegionEndAddress() const; - /// Gets the total size of the new map region in bytes. - u64 GetNewMapRegionSize() const; + /// Gets the total size of the stack region in bytes. + u64 GetStackRegionSize() const; - /// Determines whether or not the given address range is within the new map region - bool IsWithinNewMapRegion(VAddr address, u64 size) const; + /// Determines whether or not the given address range is within the stack region + bool IsWithinStackRegion(VAddr address, u64 size) const; /// Gets the base address of the TLS IO region. VAddr GetTLSIORegionBaseAddress() const; @@ -726,8 +726,8 @@ private: VAddr map_region_base = 0; VAddr map_region_end = 0; - VAddr new_map_region_base = 0; - VAddr new_map_region_end = 0; + VAddr stack_region_base = 0; + VAddr stack_region_end = 0; VAddr tls_io_region_base = 0; VAddr tls_io_region_end = 0; diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 33cebb48b..eced38001 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -270,7 +270,7 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger {70, nullptr, "ReportMultimediaError"}, {71, nullptr, "GetCurrentIlluminanceEx"}, {80, nullptr, "SetWirelessPriorityMode"}, - {90, nullptr, "GetAccumulatedSuspendedTickValue"}, + {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"}, {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"}, {100, nullptr, "SetAlbumImageTakenNotificationEnabled"}, {1000, nullptr, "GetDebugStorageChannel"}, @@ -283,10 +283,14 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, "ISelfController:LaunchableEvent"); - // TODO(ogniK): Figure out where, when and why this event gets signalled + // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is + // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple + // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not + // suspended if the event has previously been created by a call to + // GetAccumulatedSuspendedTickChangedEvent. accumulated_suspended_tick_changed_event = Kernel::WritableEvent::CreateEventPair( kernel, Kernel::ResetType::Manual, "ISelfController:AccumulatedSuspendedTickChangedEvent"); - accumulated_suspended_tick_changed_event.writable->Signal(); // Is signalled on creation + accumulated_suspended_tick_changed_event.writable->Signal(); } ISelfController::~ISelfController() = default; @@ -449,11 +453,19 @@ void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& c rb.Push<u32>(idle_time_detection_extension); } +void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_AM, "called."); + + // This command returns the total number of system ticks since ISelfController creation + // where the game was suspended. Since Yuzu doesn't implement game suspension, this command + // can just always return 0 ticks. + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push<u64>(0); +} + void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx) { - // The implementation of this function is fine as is, the reason we're labelling it as stubbed - // is because we're currently unsure when and where accumulated_suspended_tick_changed_event is - // actually signalled for the time being. - LOG_WARNING(Service_AM, "(STUBBED) called"); + LOG_DEBUG(Service_AM, "called."); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 4ea609d23..49ff20959 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -133,6 +133,7 @@ private: void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx); void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); + void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx); std::shared_ptr<NVFlinger::NVFlinger> nvflinger; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index f18f6226b..8555691c0 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -16,11 +16,9 @@ #include "core/core.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/vm_manager.h" -#include "core/hle/lock.h" #include "core/memory.h" #include "core/memory_setup.h" #include "video_core/gpu.h" -#include "video_core/renderer_base.h" namespace Memory { diff --git a/src/core/memory.h b/src/core/memory.h index 04e2c5f1d..09008e1dd 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -8,10 +8,6 @@ #include <string> #include "common/common_types.h" -namespace Common { -struct PageTable; -} - namespace Kernel { class Process; } |