mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-29 08:34:20 +01:00
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.
This commit is contained in:
parent
7fd598636e
commit
6c6f95d071
@ -325,26 +325,27 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
|
|||||||
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
|
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
|
||||||
info_sub_id, handle);
|
info_sub_id, handle);
|
||||||
|
|
||||||
const auto& vm_manager = Core::CurrentProcess()->vm_manager;
|
const auto& current_process = Core::CurrentProcess();
|
||||||
|
const auto& vm_manager = current_process->vm_manager;
|
||||||
|
|
||||||
switch (static_cast<GetInfoType>(info_id)) {
|
switch (static_cast<GetInfoType>(info_id)) {
|
||||||
case GetInfoType::AllowedCpuIdBitmask:
|
case GetInfoType::AllowedCpuIdBitmask:
|
||||||
*result = Core::CurrentProcess()->allowed_processor_mask;
|
*result = current_process->allowed_processor_mask;
|
||||||
break;
|
break;
|
||||||
case GetInfoType::AllowedThreadPrioBitmask:
|
case GetInfoType::AllowedThreadPrioBitmask:
|
||||||
*result = Core::CurrentProcess()->allowed_thread_priority_mask;
|
*result = current_process->allowed_thread_priority_mask;
|
||||||
break;
|
break;
|
||||||
case GetInfoType::MapRegionBaseAddr:
|
case GetInfoType::MapRegionBaseAddr:
|
||||||
*result = Memory::MAP_REGION_VADDR;
|
*result = vm_manager.GetMapRegionBaseAddress();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::MapRegionSize:
|
case GetInfoType::MapRegionSize:
|
||||||
*result = Memory::MAP_REGION_SIZE;
|
*result = vm_manager.GetMapRegionSize();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::HeapRegionBaseAddr:
|
case GetInfoType::HeapRegionBaseAddr:
|
||||||
*result = Memory::HEAP_VADDR;
|
*result = vm_manager.GetHeapRegionBaseAddress();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::HeapRegionSize:
|
case GetInfoType::HeapRegionSize:
|
||||||
*result = Memory::HEAP_SIZE;
|
*result = vm_manager.GetHeapRegionSize();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::TotalMemoryUsage:
|
case GetInfoType::TotalMemoryUsage:
|
||||||
*result = vm_manager.GetTotalMemoryUsage();
|
*result = vm_manager.GetTotalMemoryUsage();
|
||||||
@ -359,22 +360,35 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
|
|||||||
*result = 0;
|
*result = 0;
|
||||||
break;
|
break;
|
||||||
case GetInfoType::AddressSpaceBaseAddr:
|
case GetInfoType::AddressSpaceBaseAddr:
|
||||||
*result = vm_manager.GetAddressSpaceBaseAddr();
|
*result = vm_manager.GetCodeRegionBaseAddress();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::AddressSpaceSize:
|
case GetInfoType::AddressSpaceSize: {
|
||||||
*result = vm_manager.GetAddressSpaceSize();
|
const u64 width = vm_manager.GetAddressSpaceWidth();
|
||||||
|
|
||||||
|
switch (width) {
|
||||||
|
case 32:
|
||||||
|
*result = 0xFFE00000;
|
||||||
|
break;
|
||||||
|
case 36:
|
||||||
|
*result = 0xFF8000000;
|
||||||
|
break;
|
||||||
|
case 39:
|
||||||
|
*result = 0x7FF8000000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GetInfoType::NewMapRegionBaseAddr:
|
case GetInfoType::NewMapRegionBaseAddr:
|
||||||
*result = Memory::NEW_MAP_REGION_VADDR;
|
*result = vm_manager.GetNewMapRegionBaseAddress();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::NewMapRegionSize:
|
case GetInfoType::NewMapRegionSize:
|
||||||
*result = Memory::NEW_MAP_REGION_SIZE;
|
*result = vm_manager.GetNewMapRegionSize();
|
||||||
break;
|
break;
|
||||||
case GetInfoType::IsVirtualAddressMemoryEnabled:
|
case GetInfoType::IsVirtualAddressMemoryEnabled:
|
||||||
*result = Core::CurrentProcess()->is_virtual_address_memory_enabled;
|
*result = current_process->is_virtual_address_memory_enabled;
|
||||||
break;
|
break;
|
||||||
case GetInfoType::TitleId:
|
case GetInfoType::TitleId:
|
||||||
*result = Core::CurrentProcess()->program_id;
|
*result = current_process->program_id;
|
||||||
break;
|
break;
|
||||||
case GetInfoType::PrivilegedProcessId:
|
case GetInfoType::PrivilegedProcessId:
|
||||||
LOG_WARNING(Kernel_SVC,
|
LOG_WARNING(Kernel_SVC,
|
||||||
|
@ -474,14 +474,16 @@ u64 VMManager::GetTotalHeapUsage() const {
|
|||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAddr VMManager::GetAddressSpaceBaseAddr() const {
|
VAddr VMManager::GetAddressSpaceBaseAddress() const {
|
||||||
LOG_WARNING(Kernel, "(STUBBED) called");
|
return address_space_base;
|
||||||
return 0x8000000;
|
}
|
||||||
|
|
||||||
|
VAddr VMManager::GetAddressSpaceEndAddress() const {
|
||||||
|
return address_space_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 VMManager::GetAddressSpaceSize() const {
|
u64 VMManager::GetAddressSpaceSize() const {
|
||||||
LOG_WARNING(Kernel, "(STUBBED) called");
|
return address_space_end - address_space_base;
|
||||||
return MAX_ADDRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 VMManager::GetAddressSpaceWidth() const {
|
u64 VMManager::GetAddressSpaceWidth() const {
|
||||||
|
@ -114,12 +114,6 @@ struct VirtualMemoryArea {
|
|||||||
*/
|
*/
|
||||||
class VMManager final {
|
class VMManager final {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* The maximum amount of address space managed by the kernel.
|
|
||||||
* @todo This was selected arbitrarily, and should be verified for Switch OS.
|
|
||||||
*/
|
|
||||||
static constexpr VAddr MAX_ADDRESS{0x1000000000ULL};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map covering the entirety of the managed address space, keyed by the `base` field of each
|
* A map covering the entirety of the managed address space, keyed by the `base` field of each
|
||||||
* VMA. It must always be modified by splitting or merging VMAs, so that the invariant
|
* VMA. It must always be modified by splitting or merging VMAs, so that the invariant
|
||||||
@ -199,10 +193,13 @@ public:
|
|||||||
/// Gets the total heap usage, used by svcGetInfo
|
/// Gets the total heap usage, used by svcGetInfo
|
||||||
u64 GetTotalHeapUsage() const;
|
u64 GetTotalHeapUsage() const;
|
||||||
|
|
||||||
/// Gets the address space base address, used by svcGetInfo
|
/// Gets the address space base address
|
||||||
VAddr GetAddressSpaceBaseAddr() const;
|
VAddr GetAddressSpaceBaseAddress() const;
|
||||||
|
|
||||||
/// Gets the total address space address size, used by svcGetInfo
|
/// Gets the address space end address
|
||||||
|
VAddr GetAddressSpaceEndAddress() const;
|
||||||
|
|
||||||
|
/// Gets the total address space address size in bytes
|
||||||
u64 GetAddressSpaceSize() const;
|
u64 GetAddressSpaceSize() const;
|
||||||
|
|
||||||
/// Gets the address space width in bits.
|
/// Gets the address space width in bits.
|
||||||
|
Loading…
Reference in New Issue
Block a user