kern: finish SvcGetSystemInfo

This commit is contained in:
Michael Scire 2020-07-21 01:59:48 -07:00 committed by SciresM
parent 43ad4eb794
commit 058f223b97
3 changed files with 58 additions and 0 deletions

View file

@ -73,6 +73,8 @@ namespace ams::kern {
constexpr size_t GetSize() const { return this->heap.GetSize(); }
constexpr KVirtualAddress GetEndAddress() const { return this->heap.GetEndAddress(); }
size_t GetFreeSize() const { return this->heap.GetFreeSize(); }
constexpr void SetNext(Impl *n) { this->next = n; }
constexpr void SetPrev(Impl *n) { this->prev = n; }
constexpr Impl *GetNext() const { return this->next; }
@ -204,6 +206,23 @@ namespace ams::kern {
}
return total;
}
size_t GetFreeSize() {
size_t total = 0;
for (size_t i = 0; i < this->num_managers; i++) {
total += this->managers[i].GetFreeSize();
}
return total;
}
size_t GetFreeSize(Pool pool) {
constexpr Direction GetSizeDirection = Direction_FromFront;
size_t total = 0;
for (auto *manager = this->GetFirstManager(pool, GetSizeDirection); manager != nullptr; manager = this->GetNextManager(manager, GetSizeDirection)) {
total += manager->GetFreeSize();
}
return total;
}
public:
static size_t CalculateMetadataOverheadSize(size_t region_size) {
return Impl::CalculateMetadataOverheadSize(region_size);

View file

@ -145,6 +145,8 @@ namespace ams::kern {
return Initialize(heap_address, heap_size, metadata_address, metadata_size, MemoryBlockPageShifts, NumMemoryBlockPageShifts);
}
size_t GetFreeSize() const { return this->GetNumFreePages() * PageSize; }
void UpdateUsedSize() {
this->used_size = this->heap_size - (this->GetNumFreePages() * PageSize);
}