summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-24 11:16:17 -0400
committerGravatar Lioncash2018-09-24 22:16:03 -0400
commit6c6f95d071b25f2743fcb6652f4389c9e25a7506 (patch)
tree330deda9baa95c5177b680ae2aab355d6f9f1105 /src
parentmemory: Dehardcode the use of a 36-bit address space (diff)
downloadyuzu-6c6f95d071b25f2743fcb6652f4389c9e25a7506.tar.gz
yuzu-6c6f95d071b25f2743fcb6652f4389c9e25a7506.tar.xz
yuzu-6c6f95d071b25f2743fcb6652f4389c9e25a7506.zip
svc: Report correct memory-related values within some of the cases in svcGetInfo()
Previously, these were reporting hardcoded values, but given the regions can change depending on the requested address spaces, these need to report the values that the memory manager contains.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/svc.cpp42
-rw-r--r--src/core/hle/kernel/vm_manager.cpp12
-rw-r--r--src/core/hle/kernel/vm_manager.h15
3 files changed, 41 insertions, 28 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 0bc407098..e0f5e3f39 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -325,26 +325,27 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
325 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, 325 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
326 info_sub_id, handle); 326 info_sub_id, handle);
327 327
328 const auto& vm_manager = Core::CurrentProcess()->vm_manager; 328 const auto& current_process = Core::CurrentProcess();
329 const auto& vm_manager = current_process->vm_manager;
329 330
330 switch (static_cast<GetInfoType>(info_id)) { 331 switch (static_cast<GetInfoType>(info_id)) {
331 case GetInfoType::AllowedCpuIdBitmask: 332 case GetInfoType::AllowedCpuIdBitmask:
332 *result = Core::CurrentProcess()->allowed_processor_mask; 333 *result = current_process->allowed_processor_mask;
333 break; 334 break;
334 case GetInfoType::AllowedThreadPrioBitmask: 335 case GetInfoType::AllowedThreadPrioBitmask:
335 *result = Core::CurrentProcess()->allowed_thread_priority_mask; 336 *result = current_process->allowed_thread_priority_mask;
336 break; 337 break;
337 case GetInfoType::MapRegionBaseAddr: 338 case GetInfoType::MapRegionBaseAddr:
338 *result = Memory::MAP_REGION_VADDR; 339 *result = vm_manager.GetMapRegionBaseAddress();
339 break; 340 break;
340 case GetInfoType::MapRegionSize: 341 case GetInfoType::MapRegionSize:
341 *result = Memory::MAP_REGION_SIZE; 342 *result = vm_manager.GetMapRegionSize();
342 break; 343 break;
343 case GetInfoType::HeapRegionBaseAddr: 344 case GetInfoType::HeapRegionBaseAddr:
344 *result = Memory::HEAP_VADDR; 345 *result = vm_manager.GetHeapRegionBaseAddress();
345 break; 346 break;
346 case GetInfoType::HeapRegionSize: 347 case GetInfoType::HeapRegionSize:
347 *result = Memory::HEAP_SIZE; 348 *result = vm_manager.GetHeapRegionSize();
348 break; 349 break;
349 case GetInfoType::TotalMemoryUsage: 350 case GetInfoType::TotalMemoryUsage:
350 *result = vm_manager.GetTotalMemoryUsage(); 351 *result = vm_manager.GetTotalMemoryUsage();
@@ -359,22 +360,35 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
359 *result = 0; 360 *result = 0;
360 break; 361 break;
361 case GetInfoType::AddressSpaceBaseAddr: 362 case GetInfoType::AddressSpaceBaseAddr:
362 *result = vm_manager.GetAddressSpaceBaseAddr(); 363 *result = vm_manager.GetCodeRegionBaseAddress();
363 break; 364 break;
364 case GetInfoType::AddressSpaceSize: 365 case GetInfoType::AddressSpaceSize: {
365 *result = vm_manager.GetAddressSpaceSize(); 366 const u64 width = vm_manager.GetAddressSpaceWidth();
367
368 switch (width) {
369 case 32:
370 *result = 0xFFE00000;
371 break;
372 case 36:
373 *result = 0xFF8000000;
374 break;
375 case 39:
376 *result = 0x7FF8000000;
377 break;
378 }
366 break; 379 break;
380 }
367 case GetInfoType::NewMapRegionBaseAddr: 381 case GetInfoType::NewMapRegionBaseAddr:
368 *result = Memory::NEW_MAP_REGION_VADDR; 382 *result = vm_manager.GetNewMapRegionBaseAddress();
369 break; 383 break;
370 case GetInfoType::NewMapRegionSize: 384 case GetInfoType::NewMapRegionSize:
371 *result = Memory::NEW_MAP_REGION_SIZE; 385 *result = vm_manager.GetNewMapRegionSize();
372 break; 386 break;
373 case GetInfoType::IsVirtualAddressMemoryEnabled: 387 case GetInfoType::IsVirtualAddressMemoryEnabled:
374 *result = Core::CurrentProcess()->is_virtual_address_memory_enabled; 388 *result = current_process->is_virtual_address_memory_enabled;
375 break; 389 break;
376 case GetInfoType::TitleId: 390 case GetInfoType::TitleId:
377 *result = Core::CurrentProcess()->program_id; 391 *result = current_process->program_id;
378 break; 392 break;
379 case GetInfoType::PrivilegedProcessId: 393 case GetInfoType::PrivilegedProcessId:
380 LOG_WARNING(Kernel_SVC, 394 LOG_WARNING(Kernel_SVC,
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 20d06f000..e412309fd 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -474,14 +474,16 @@ u64 VMManager::GetTotalHeapUsage() const {
474 return 0x0; 474 return 0x0;
475} 475}
476 476
477VAddr VMManager::GetAddressSpaceBaseAddr() const { 477VAddr VMManager::GetAddressSpaceBaseAddress() const {
478 LOG_WARNING(Kernel, "(STUBBED) called"); 478 return address_space_base;
479 return 0x8000000; 479}
480
481VAddr VMManager::GetAddressSpaceEndAddress() const {
482 return address_space_end;
480} 483}
481 484
482u64 VMManager::GetAddressSpaceSize() const { 485u64 VMManager::GetAddressSpaceSize() const {
483 LOG_WARNING(Kernel, "(STUBBED) called"); 486 return address_space_end - address_space_base;
484 return MAX_ADDRESS;
485} 487}
486 488
487u64 VMManager::GetAddressSpaceWidth() const { 489u64 VMManager::GetAddressSpaceWidth() const {
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h
index 581bf3d00..015559a64 100644
--- a/src/core/hle/kernel/vm_manager.h
+++ b/src/core/hle/kernel/vm_manager.h
@@ -115,12 +115,6 @@ struct VirtualMemoryArea {
115class VMManager final { 115class VMManager final {
116public: 116public:
117 /** 117 /**
118 * The maximum amount of address space managed by the kernel.
119 * @todo This was selected arbitrarily, and should be verified for Switch OS.
120 */
121 static constexpr VAddr MAX_ADDRESS{0x1000000000ULL};
122
123 /**
124 * A map covering the entirety of the managed address space, keyed by the `base` field of each 118 * A map covering the entirety of the managed address space, keyed by the `base` field of each
125 * VMA. It must always be modified by splitting or merging VMAs, so that the invariant 119 * VMA. It must always be modified by splitting or merging VMAs, so that the invariant
126 * `elem.base + elem.size == next.base` is preserved, and mergeable regions must always be 120 * `elem.base + elem.size == next.base` is preserved, and mergeable regions must always be
@@ -199,10 +193,13 @@ public:
199 /// Gets the total heap usage, used by svcGetInfo 193 /// Gets the total heap usage, used by svcGetInfo
200 u64 GetTotalHeapUsage() const; 194 u64 GetTotalHeapUsage() const;
201 195
202 /// Gets the address space base address, used by svcGetInfo 196 /// Gets the address space base address
203 VAddr GetAddressSpaceBaseAddr() const; 197 VAddr GetAddressSpaceBaseAddress() const;
198
199 /// Gets the address space end address
200 VAddr GetAddressSpaceEndAddress() const;
204 201
205 /// Gets the total address space address size, used by svcGetInfo 202 /// Gets the total address space address size in bytes
206 u64 GetAddressSpaceSize() const; 203 u64 GetAddressSpaceSize() const;
207 204
208 /// Gets the address space width in bits. 205 /// Gets the address space width in bits.