summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/memory
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-10-21 04:07:39 +0200
committerGitHub <noreply@github.com>2020-10-21 04:07:39 +0200
commit3d592972dc3fd61cc88771b889eff237e4e03e0f (patch)
tree0dbc65ac86e609ae22087c7be9d4759ac6b73004 /src/core/hle/kernel/memory
parentkernel: Fix build with recent compiler flag changes (diff)
downloadyuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.gz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.bz2
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.lz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.xz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.zst
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/memory/address_space_info.cpp2
-rw-r--r--src/core/hle/kernel/memory/memory_manager.cpp4
-rw-r--r--src/core/hle/kernel/memory/page_heap.cpp17
-rw-r--r--src/core/hle/kernel/memory/page_heap.h18
-rw-r--r--src/core/hle/kernel/memory/page_table.cpp6
5 files changed, 20 insertions, 27 deletions
diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/memory/address_space_info.cpp
index 6cf43ba24..e4288cab4 100644
--- a/src/core/hle/kernel/memory/address_space_info.cpp
+++ b/src/core/hle/kernel/memory/address_space_info.cpp
@@ -96,7 +96,6 @@ u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) {
return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].address;
}
UNREACHABLE();
- return 0;
}
std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) {
@@ -113,7 +112,6 @@ std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type)
return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].size;
}
UNREACHABLE();
- return 0;
}
} // namespace Kernel::Memory
diff --git a/src/core/hle/kernel/memory/memory_manager.cpp b/src/core/hle/kernel/memory/memory_manager.cpp
index a96157c37..acf13585c 100644
--- a/src/core/hle/kernel/memory/memory_manager.cpp
+++ b/src/core/hle/kernel/memory/memory_manager.cpp
@@ -71,7 +71,7 @@ VAddr MemoryManager::AllocateContinuous(std::size_t num_pages, std::size_t align
}
// If we allocated more than we need, free some
- const auto allocated_pages{PageHeap::GetBlockNumPages(static_cast<u32>(heap_index))};
+ const auto allocated_pages{PageHeap::GetBlockNumPages(heap_index)};
if (allocated_pages > num_pages) {
chosen_manager.Free(allocated_block + num_pages * PageSize, allocated_pages - num_pages);
}
@@ -112,7 +112,7 @@ ResultCode MemoryManager::Allocate(PageLinkedList& page_list, std::size_t num_pa
// Keep allocating until we've allocated all our pages
for (s32 index{heap_index}; index >= 0 && num_pages > 0; index--) {
- const auto pages_per_alloc{PageHeap::GetBlockNumPages(static_cast<u32>(index))};
+ const auto pages_per_alloc{PageHeap::GetBlockNumPages(index)};
while (num_pages >= pages_per_alloc) {
// Allocate a block
diff --git a/src/core/hle/kernel/memory/page_heap.cpp b/src/core/hle/kernel/memory/page_heap.cpp
index 7890b8c1a..0ab1f7205 100644
--- a/src/core/hle/kernel/memory/page_heap.cpp
+++ b/src/core/hle/kernel/memory/page_heap.cpp
@@ -33,12 +33,11 @@ void PageHeap::Initialize(VAddr address, std::size_t size, std::size_t metadata_
}
VAddr PageHeap::AllocateBlock(s32 index) {
- const auto u_index = static_cast<std::size_t>(index);
- const auto needed_size{blocks[u_index].GetSize()};
+ const std::size_t needed_size{blocks[index].GetSize()};
- for (auto i = u_index; i < MemoryBlockPageShifts.size(); i++) {
- if (const VAddr addr = blocks[i].PopBlock(); addr != 0) {
- if (const std::size_t allocated_size = blocks[i].GetSize();
+ for (s32 i{index}; i < static_cast<s32>(MemoryBlockPageShifts.size()); i++) {
+ if (const VAddr addr{blocks[i].PopBlock()}; addr) {
+ if (const std::size_t allocated_size{blocks[i].GetSize()};
allocated_size > needed_size) {
Free(addr + needed_size, (allocated_size - needed_size) / PageSize);
}
@@ -51,7 +50,7 @@ VAddr PageHeap::AllocateBlock(s32 index) {
void PageHeap::FreeBlock(VAddr block, s32 index) {
do {
- block = blocks[static_cast<std::size_t>(index++)].PushBlock(block);
+ block = blocks[index++].PushBlock(block);
} while (block != 0);
}
@@ -70,7 +69,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) {
VAddr after_start{end};
VAddr after_end{end};
while (big_index >= 0) {
- const std::size_t block_size{blocks[static_cast<std::size_t>(big_index)].GetSize()};
+ const std::size_t block_size{blocks[big_index].GetSize()};
const VAddr big_start{Common::AlignUp((start), block_size)};
const VAddr big_end{Common::AlignDown((end), block_size)};
if (big_start < big_end) {
@@ -88,7 +87,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) {
// Free space before the big blocks
for (s32 i{big_index - 1}; i >= 0; i--) {
- const std::size_t block_size{blocks[static_cast<size_t>(i)].GetSize()};
+ const std::size_t block_size{blocks[i].GetSize()};
while (before_start + block_size <= before_end) {
before_end -= block_size;
FreeBlock(before_end, i);
@@ -97,7 +96,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) {
// Free space after the big blocks
for (s32 i{big_index - 1}; i >= 0; i--) {
- const std::size_t block_size{blocks[static_cast<size_t>(i)].GetSize()};
+ const std::size_t block_size{blocks[i].GetSize()};
while (after_start + block_size <= after_end) {
FreeBlock(after_start, i);
after_start += block_size;
diff --git a/src/core/hle/kernel/memory/page_heap.h b/src/core/hle/kernel/memory/page_heap.h
index 92a2bce04..22b0de860 100644
--- a/src/core/hle/kernel/memory/page_heap.h
+++ b/src/core/hle/kernel/memory/page_heap.h
@@ -34,9 +34,7 @@ public:
static constexpr s32 GetBlockIndex(std::size_t num_pages) {
for (s32 i{static_cast<s32>(NumMemoryBlockPageShifts) - 1}; i >= 0; i--) {
- const auto shift_index = static_cast<std::size_t>(i);
- if (num_pages >=
- (static_cast<std::size_t>(1) << MemoryBlockPageShifts[shift_index]) / PageSize) {
+ if (num_pages >= (static_cast<std::size_t>(1) << MemoryBlockPageShifts[i]) / PageSize) {
return i;
}
}
@@ -88,7 +86,7 @@ private:
// Set the bitmap pointers
for (s32 depth{GetHighestDepthIndex()}; depth >= 0; depth--) {
- bit_storages[static_cast<std::size_t>(depth)] = storage;
+ bit_storages[depth] = storage;
size = Common::AlignUp(size, 64) / 64;
storage += size;
}
@@ -101,7 +99,7 @@ private:
s32 depth{};
do {
- const u64 v{bit_storages[static_cast<std::size_t>(depth)][offset]};
+ const u64 v{bit_storages[depth][offset]};
if (v == 0) {
// Non-zero depth indicates that a previous level had a free block
ASSERT(depth == 0);
@@ -127,7 +125,7 @@ private:
constexpr bool ClearRange(std::size_t offset, std::size_t count) {
const s32 depth{GetHighestDepthIndex()};
const auto bit_ind{offset / 64};
- u64* bits{bit_storages[static_cast<std::size_t>(depth)]};
+ u64* bits{bit_storages[depth]};
if (count < 64) {
const auto shift{offset % 64};
ASSERT(shift + count <= 64);
@@ -179,11 +177,11 @@ private:
const auto which{offset % 64};
const u64 mask{1ULL << which};
- u64* bit{std::addressof(bit_storages[static_cast<std::size_t>(depth)][ind])};
+ u64* bit{std::addressof(bit_storages[depth][ind])};
const u64 v{*bit};
ASSERT((v & mask) == 0);
*bit = v | mask;
- if (v != 0) {
+ if (v) {
break;
}
offset = ind;
@@ -197,12 +195,12 @@ private:
const auto which{offset % 64};
const u64 mask{1ULL << which};
- u64* bit{std::addressof(bit_storages[static_cast<std::size_t>(depth)][ind])};
+ u64* bit{std::addressof(bit_storages[depth][ind])};
u64 v{*bit};
ASSERT((v & mask) != 0);
v &= ~mask;
*bit = v;
- if (v != 0) {
+ if (v) {
break;
}
offset = ind;
diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp
index 4f759d078..a3fadb533 100644
--- a/src/core/hle/kernel/memory/page_table.cpp
+++ b/src/core/hle/kernel/memory/page_table.cpp
@@ -414,8 +414,7 @@ ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) {
const std::size_t remaining_pages{remaining_size / PageSize};
if (process->GetResourceLimit() &&
- !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory,
- static_cast<s64>(remaining_size))) {
+ !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, remaining_size)) {
return ERR_RESOURCE_LIMIT_EXCEEDED;
}
@@ -779,8 +778,7 @@ ResultVal<VAddr> PageTable::SetHeapSize(std::size_t size) {
auto process{system.Kernel().CurrentProcess()};
if (process->GetResourceLimit() && delta != 0 &&
- !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory,
- static_cast<s64>(delta))) {
+ !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, delta)) {
return ERR_RESOURCE_LIMIT_EXCEEDED;
}