kern: implement SvcUnmapMemory, more of SvcGetInfo

This commit is contained in:
Michael Scire
2020-05-29 00:57:25 -07:00
parent faad5609b9
commit 1a0696f8a3
14 changed files with 231 additions and 37 deletions

View File

@@ -52,7 +52,6 @@ namespace ams::kern {
OperationType_Unmap = 2,
OperationType_ChangePermissions = 3,
OperationType_ChangePermissionsAndRefresh = 4,
/* TODO: perm/attr operations */
};
static constexpr size_t MaxPhysicalMapAlignment = 1_GB;
@@ -134,7 +133,7 @@ namespace ams::kern {
KProcessAddress code_region_start;
KProcessAddress code_region_end;
size_t max_heap_size;
size_t max_physical_memory_size;
size_t mapped_physical_memory_size;
size_t mapped_unsafe_physical_memory;
mutable KLightLock general_lock;
mutable KLightLock map_physical_memory_lock;
@@ -157,7 +156,7 @@ namespace ams::kern {
address_space_start(), address_space_end(), heap_region_start(), heap_region_end(), current_heap_end(),
alias_region_start(), alias_region_end(), stack_region_start(), stack_region_end(), kernel_map_region_start(),
kernel_map_region_end(), alias_code_region_start(), alias_code_region_end(), code_region_start(), code_region_end(),
max_heap_size(), max_physical_memory_size(),mapped_unsafe_physical_memory(), general_lock(), map_physical_memory_lock(),
max_heap_size(), mapped_physical_memory_size(), mapped_unsafe_physical_memory(), general_lock(), map_physical_memory_lock(),
impl(), memory_block_manager(), allocate_option(), address_space_width(), is_kernel(), enable_aslr(), memory_block_slab_manager(),
block_info_manager(), cached_physical_linear_region(), cached_physical_heap_region(), cached_virtual_heap_region(),
heap_fill_value(), ipc_fill_value(), stack_fill_value()
@@ -251,6 +250,7 @@ namespace ams::kern {
Result SetHeapSize(KProcessAddress *out, size_t size);
Result SetMaxHeapSize(size_t size);
Result QueryInfo(KMemoryInfo *out_info, ams::svc::PageInfo *out_page_info, KProcessAddress addr) const;
Result UnmapMemory(uintptr_t dst_address, uintptr_t src_address, size_t size);
Result MapIo(KPhysicalAddress phys_addr, size_t size, KMemoryPermission perm);
Result MapStatic(KPhysicalAddress phys_addr, size_t size, KMemoryPermission perm);
Result MapRegion(KMemoryRegionType region_type, KMemoryPermission perm);
@@ -287,6 +287,13 @@ namespace ams::kern {
size_t GetStackRegionSize() const { return this->stack_region_end - this->stack_region_start; }
size_t GetKernelMapRegionSize() const { return this->kernel_map_region_end - this->kernel_map_region_start; }
size_t GetAliasCodeRegionSize() const { return this->alias_code_region_end - this->alias_code_region_start; }
size_t GetNormalMemorySize() const {
/* Lock the table. */
KScopedLightLock lk(this->general_lock);
return this->GetHeapRegionSize() + this->mapped_physical_memory_size;
}
public:
static ALWAYS_INLINE KVirtualAddress GetLinearVirtualAddress(KPhysicalAddress addr) {
return KMemoryLayout::GetLinearVirtualAddress(addr);