1

Implement Util::System to keep system utility functions like streams

This commit is contained in:
2022-12-08 02:19:52 +01:00
parent 56eb074192
commit 663fabf074
18 changed files with 236 additions and 191 deletions

View File

@ -11,6 +11,7 @@
#include "BumpAllocator.h"
#include "kernel/system/Globals.h"
#include "lib/util/System.h"
namespace Kernel {
@ -38,9 +39,9 @@ void BumpAllocator::dump_free_memory() {
/* Hier muess Code eingefuegt werden */
Kernel::kout << "Freier Speicher:" << endl
<< " - Next: " << hex << reinterpret_cast<uint32_t>(next)
<< ", Allocations: " << dec << allocations << endl;
Util::System::out << "Freier Speicher:" << endl
<< " - Next: " << hex << reinterpret_cast<uint32_t>(next)
<< ", Allocations: " << dec << allocations << endl;
}
/*****************************************************************************

View File

@ -11,6 +11,7 @@
#include "LinkedListAllocator.h"
#include "kernel/system/Globals.h"
#include "lib/util/System.h"
// I don't order the list by size so that the block order corresponds to the location in memory
// Then I can easily merge adjacent free blocks by finding the previous block without looking at
@ -50,17 +51,17 @@ void LinkedListAllocator::dump_free_memory() {
/* Hier muess Code eingefuegt werden */
Kernel::kout << "Freier Speicher:" << endl;
Util::System::out << "Freier Speicher:" << endl;
if (free_start == nullptr) {
Kernel::kout << " - No free Blocks" << endl;
Util::System::out << " - No free Blocks" << endl;
} else {
Kernel::kout << " - Freelist start: " << hex << reinterpret_cast<uint32_t>(free_start) << endl;
Util::System::out << " - Freelist start: " << hex << reinterpret_cast<uint32_t>(free_start) << endl;
free_block_t *current = free_start;
do {
Kernel::kout << " - Free Block (Start: " << hex << reinterpret_cast<uint32_t>(current)
<< " Size: " << hex << current->size << ")" << endl;
Util::System::out << " - Free Block (Start: " << hex << reinterpret_cast<uint32_t>(current)
<< " Size: " << hex << current->size << ")" << endl;
current = current->next;
} while (current != free_start);
}
@ -312,7 +313,7 @@ free_block_t *LinkedListAllocator::find_previous_block(free_block_t *next_block)
}
// if (current == next_block) {
// Kernel::kout << "LinkedListAllocator::find_previous_block returned the input block" << endl;
// Util::System::out << "LinkedListAllocator::find_previous_block returned the input block" << endl;
// }
return current;

View File

@ -17,13 +17,13 @@ void TreeAllocator::init() {
}
void TreeAllocator::dump_free_memory() {
Kernel::kout << "Free Memory:" << endl;
Util::System::out << "Free Memory:" << endl;
list_block_t *current = reinterpret_cast<list_block_t *>(heap_start);
do {
if (!current->allocated) {
Kernel::kout << " - Free Block at " << reinterpret_cast<uint32_t>(current) << ", Size: "
<< reinterpret_cast<uint32_t>(current->next) - reinterpret_cast<uint32_t>(current)
<< endl;
Util::System::out << " - Free Block at " << reinterpret_cast<uint32_t>(current) << ", Size: "
<< reinterpret_cast<uint32_t>(current->next) - reinterpret_cast<uint32_t>(current)
<< endl;
}
current = current->next;
} while (reinterpret_cast<uint32_t>(current) != heap_start);