change printed output
This commit is contained in:
@ -7,12 +7,12 @@ void BufferedCGA::init(unsigned int pages) {
|
||||
this->screen_buffer = new CGA::cga_page_t;
|
||||
|
||||
if (this->scrollback_buffer == NULL || this->screen_buffer == NULL) {
|
||||
this->print("\nError initializing scrollback buffer\n\n", 39);
|
||||
this->print("Error initializing scrollback buffer\n", 39);
|
||||
return;
|
||||
}
|
||||
|
||||
this->initialized = true;
|
||||
this->print("\nInitialized scrollback buffer\n\n", 32);
|
||||
this->print("Initialized scrollback buffer\n", 32);
|
||||
}
|
||||
|
||||
void BufferedCGA::display_scrollback() {
|
||||
@ -25,7 +25,7 @@ void BufferedCGA::display_scrollback() {
|
||||
this->scrollback_buffer->get((cga_line_t*)CGA_START, this->scrollback - 1);
|
||||
}
|
||||
} else {
|
||||
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||
this->print("ScrollbackBuffer not initialized\n", 34);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ void BufferedCGA::scrollup() {
|
||||
if (this->initialized) {
|
||||
this->scrollback_buffer->put((cga_line_t*)CGA_START);
|
||||
} else {
|
||||
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||
this->print("ScrollbackBuffer not initialized\n", 34);
|
||||
}
|
||||
|
||||
CGA::scrollup();
|
||||
@ -58,7 +58,7 @@ void BufferedCGA::clear() {
|
||||
this->scrollback_buffer->clear();
|
||||
mmem::zero<CGA::cga_page_t>(this->screen_buffer);
|
||||
} else {
|
||||
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||
this->print("ScrollbackBuffer not initialized\n", 34);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void BufferedCGA::scroll_page_backward() {
|
||||
}
|
||||
this->display_scrollback();
|
||||
} else {
|
||||
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||
this->print("ScrollbackBuffer not initialized\n", 34);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +89,6 @@ void BufferedCGA::scroll_page_forward() {
|
||||
}
|
||||
this->display_scrollback();
|
||||
} else {
|
||||
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||
this->print("ScrollbackBuffer not initialized\n", 34);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
// NOTE: I added this file
|
||||
// TODO: Make output toggleable
|
||||
|
||||
void TreeAllocator::init() {
|
||||
this->free_start = (tree_block_t*)this->heap_start;
|
||||
@ -13,11 +14,7 @@ void TreeAllocator::init() {
|
||||
this->free_start->next = (list_block_t*)this->free_start;
|
||||
this->free_start->previous = (list_block_t*)this->free_start;
|
||||
|
||||
kout << "Initialized Tree Allocator" << endl
|
||||
<< " - Heap Start: " << hex << (unsigned int)this->heap_start
|
||||
<< ", Heap End: " << hex << (unsigned int)this->heap_end
|
||||
<< ", Heap Size: " << hex << this->heap_size << endl;
|
||||
kout << endl;
|
||||
kout << "Initialized Tree Allocator" << endl;
|
||||
}
|
||||
|
||||
void TreeAllocator::dump_free_memory() {
|
||||
@ -44,12 +41,12 @@ void* TreeAllocator::alloc(unsigned int req_size) {
|
||||
// the list_block_t is part of every block, but when freeing
|
||||
// memory we need enough space to store the rbt metadata
|
||||
rreq_size = sizeof(tree_block_t) - sizeof(list_block_t);
|
||||
kout << " - Increased block size for rbt metadata" << endl;
|
||||
// kout << " - Increased block size for rbt metadata" << endl;
|
||||
}
|
||||
unsigned int req_size_diff = (BASIC_ALIGN - rreq_size % BASIC_ALIGN) % BASIC_ALIGN;
|
||||
rreq_size = rreq_size + req_size_diff;
|
||||
if (req_size_diff > 0) {
|
||||
kout << " - Rounded to word border (+" << dec << req_size_diff << " bytes)" << endl;
|
||||
// kout << " - Rounded to word border (+" << dec << req_size_diff << " bytes)" << endl;
|
||||
}
|
||||
|
||||
// Finds smallest block that is large enough
|
||||
@ -60,19 +57,19 @@ void* TreeAllocator::alloc(unsigned int req_size) {
|
||||
}
|
||||
if (best_fit->allocated) {
|
||||
// Something went really wrong
|
||||
kout << " - Block already allocated :(" << endl;
|
||||
// kout << " - Block already allocated :(" << endl;
|
||||
return NULL;
|
||||
}
|
||||
best_fit->allocated = true;
|
||||
unsigned int size = this->get_size(best_fit);
|
||||
kout << " - Found best-fit: " << hex << (unsigned int)best_fit << endl;
|
||||
// kout << " - Found best-fit: " << hex << (unsigned int)best_fit << endl;
|
||||
|
||||
// Remove the block first so we can insert correctly when cutting
|
||||
kout << " - Removing block from freelist" << endl;
|
||||
// kout << " - Removing block from freelist" << endl;
|
||||
this->rbt_remove(best_fit);
|
||||
if (size > HEAP_MIN_FREE_BLOCK_SIZE + rreq_size + sizeof(list_block_t)) {
|
||||
// Block can be cut
|
||||
kout << " - Allocating " << dec << rreq_size << " Bytes with cutting" << endl;
|
||||
// kout << " - Allocating " << dec << rreq_size << " Bytes with cutting" << endl;
|
||||
|
||||
// [best_fit_start | sizeof(list_block_t) | rreq_size | new_block_start]
|
||||
tree_block_t* new_block = (tree_block_t*)((char*)best_fit + sizeof(list_block_t) + rreq_size);
|
||||
@ -83,10 +80,10 @@ void* TreeAllocator::alloc(unsigned int req_size) {
|
||||
// Don't cut block
|
||||
// The block is already correctly positioned in the linked list so we only
|
||||
// need to remove it from the freelist, which is done for both cases
|
||||
kout << " - Allocating " << dec << rreq_size << " Bytes without cutting" << endl;
|
||||
// kout << " - Allocating " << dec << rreq_size << " Bytes without cutting" << endl;
|
||||
}
|
||||
|
||||
kout << " - Returned address " << hex << (unsigned int)((char*)best_fit + sizeof(list_block_t)) << endl;
|
||||
// kout << " - Returned address " << hex << (unsigned int)((char*)best_fit + sizeof(list_block_t)) << endl;
|
||||
return (void*)((char*)best_fit + sizeof(list_block_t));
|
||||
}
|
||||
|
||||
@ -110,7 +107,7 @@ void TreeAllocator::free(void* ptr) {
|
||||
|
||||
if (!next->allocated) {
|
||||
// Merge forward
|
||||
kout << " - Merging forward" << endl;
|
||||
// kout << " - Merging forward" << endl;
|
||||
|
||||
// Remove the next block from all lists as it is now part of our freed block
|
||||
this->dll_remove(next);
|
||||
@ -123,7 +120,7 @@ void TreeAllocator::free(void* ptr) {
|
||||
|
||||
if (!previous->allocated) {
|
||||
// Merge backward
|
||||
kout << " - Merging backward" << endl;
|
||||
// kout << " - Merging backward" << endl;
|
||||
|
||||
// Remove the current block from all lists as it is now part of the previous block
|
||||
// It doesn't have to be removed from rbt as it wasn't in there as it was allocated before
|
||||
|
||||
Reference in New Issue
Block a user