mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-21 02:15:07 -04:00
kern: refactor to use m_ for member variables
This commit is contained in:
parent
0bf2ade76f
commit
968f50bc07
135 changed files with 3727 additions and 3734 deletions
|
@ -25,16 +25,16 @@ namespace ams::kern {
|
|||
const KVirtualAddress management_end = management_address + management_size;
|
||||
|
||||
/* Set our members. */
|
||||
this->heap_address = address;
|
||||
this->heap_size = size;
|
||||
this->num_blocks = num_block_shifts;
|
||||
m_heap_address = address;
|
||||
m_heap_size = size;
|
||||
m_num_blocks = num_block_shifts;
|
||||
|
||||
/* Setup bitmaps. */
|
||||
u64 *cur_bitmap_storage = GetPointer<u64>(management_address);
|
||||
for (size_t i = 0; i < num_block_shifts; i++) {
|
||||
const size_t cur_block_shift = block_shifts[i];
|
||||
const size_t next_block_shift = (i != num_block_shifts - 1) ? block_shifts[i + 1] : 0;
|
||||
cur_bitmap_storage = this->blocks[i].Initialize(this->heap_address, this->heap_size, cur_block_shift, next_block_shift, cur_bitmap_storage);
|
||||
cur_bitmap_storage = m_blocks[i].Initialize(m_heap_address, m_heap_size, cur_block_shift, next_block_shift, cur_bitmap_storage);
|
||||
}
|
||||
|
||||
/* Ensure we didn't overextend our bounds. */
|
||||
|
@ -44,19 +44,19 @@ namespace ams::kern {
|
|||
size_t KPageHeap::GetNumFreePages() const {
|
||||
size_t num_free = 0;
|
||||
|
||||
for (size_t i = 0; i < this->num_blocks; i++) {
|
||||
num_free += this->blocks[i].GetNumFreePages();
|
||||
for (size_t i = 0; i < m_num_blocks; i++) {
|
||||
num_free += m_blocks[i].GetNumFreePages();
|
||||
}
|
||||
|
||||
return num_free;
|
||||
}
|
||||
|
||||
KVirtualAddress KPageHeap::AllocateBlock(s32 index, bool random) {
|
||||
const size_t needed_size = this->blocks[index].GetSize();
|
||||
const size_t needed_size = m_blocks[index].GetSize();
|
||||
|
||||
for (s32 i = index; i < static_cast<s32>(this->num_blocks); i++) {
|
||||
if (const KVirtualAddress addr = this->blocks[i].PopBlock(random); addr != Null<KVirtualAddress>) {
|
||||
if (const size_t allocated_size = this->blocks[i].GetSize(); allocated_size > needed_size) {
|
||||
for (s32 i = index; i < static_cast<s32>(m_num_blocks); i++) {
|
||||
if (const KVirtualAddress addr = m_blocks[i].PopBlock(random); addr != Null<KVirtualAddress>) {
|
||||
if (const size_t allocated_size = m_blocks[i].GetSize(); allocated_size > needed_size) {
|
||||
this->Free(addr + needed_size, (allocated_size - needed_size) / PageSize);
|
||||
}
|
||||
return addr;
|
||||
|
@ -68,7 +68,7 @@ namespace ams::kern {
|
|||
|
||||
void KPageHeap::FreeBlock(KVirtualAddress block, s32 index) {
|
||||
do {
|
||||
block = this->blocks[index++].PushBlock(block);
|
||||
block = m_blocks[index++].PushBlock(block);
|
||||
} while (block != Null<KVirtualAddress>);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ namespace ams::kern {
|
|||
}
|
||||
|
||||
/* Find the largest block size that we can free, and free as many as possible. */
|
||||
s32 big_index = static_cast<s32>(this->num_blocks) - 1;
|
||||
s32 big_index = static_cast<s32>(m_num_blocks) - 1;
|
||||
const KVirtualAddress start = addr;
|
||||
const KVirtualAddress end = addr + num_pages * PageSize;
|
||||
KVirtualAddress before_start = start;
|
||||
|
@ -87,7 +87,7 @@ namespace ams::kern {
|
|||
KVirtualAddress after_start = end;
|
||||
KVirtualAddress after_end = end;
|
||||
while (big_index >= 0) {
|
||||
const size_t block_size = this->blocks[big_index].GetSize();
|
||||
const size_t block_size = m_blocks[big_index].GetSize();
|
||||
const KVirtualAddress big_start = util::AlignUp(GetInteger(start), block_size);
|
||||
const KVirtualAddress big_end = util::AlignDown(GetInteger(end), block_size);
|
||||
if (big_start < big_end) {
|
||||
|
@ -105,7 +105,7 @@ namespace ams::kern {
|
|||
|
||||
/* Free space before the big blocks. */
|
||||
for (s32 i = big_index - 1; i >= 0; i--) {
|
||||
const size_t block_size = this->blocks[i].GetSize();
|
||||
const size_t block_size = m_blocks[i].GetSize();
|
||||
while (before_start + block_size <= before_end) {
|
||||
before_end -= block_size;
|
||||
this->FreeBlock(before_end, i);
|
||||
|
@ -114,7 +114,7 @@ namespace ams::kern {
|
|||
|
||||
/* Free space after the big blocks. */
|
||||
for (s32 i = big_index - 1; i >= 0; i--) {
|
||||
const size_t block_size = this->blocks[i].GetSize();
|
||||
const size_t block_size = m_blocks[i].GetSize();
|
||||
while (after_start + block_size <= after_end) {
|
||||
this->FreeBlock(after_start, i);
|
||||
after_start += block_size;
|
||||
|
@ -135,8 +135,8 @@ namespace ams::kern {
|
|||
void KPageHeap::DumpFreeList() const {
|
||||
MESOSPHERE_RELEASE_LOG("KPageHeap::DumpFreeList %p\n", this);
|
||||
|
||||
for (size_t i = 0; i < this->num_blocks; ++i) {
|
||||
const size_t block_size = this->blocks[i].GetSize();
|
||||
for (size_t i = 0; i < m_num_blocks; ++i) {
|
||||
const size_t block_size = m_blocks[i].GetSize();
|
||||
const char *suffix;
|
||||
size_t size;
|
||||
if (block_size >= 1_GB) {
|
||||
|
@ -153,7 +153,7 @@ namespace ams::kern {
|
|||
size = block_size;
|
||||
}
|
||||
|
||||
MESOSPHERE_RELEASE_LOG(" %4zu %s block x %zu\n", size, suffix, this->blocks[i].GetNumFreeBlocks());
|
||||
MESOSPHERE_RELEASE_LOG(" %4zu %s block x %zu\n", size, suffix, m_blocks[i].GetNumFreeBlocks());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue