summaryrefslogtreecommitdiff
path: root/src/user/knob/heap.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
committerBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
commitbce944d1498eaa3b6940ee234c863b3548a66b37 (patch)
treeea40c087ab4f0f236aee8d158cf68550f5209f72 /src/user/knob/heap.c
parentca731aa747214919df7b3dfe3478dbe787ce5b68 (diff)
downloadportland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz
graphics!
Diffstat (limited to 'src/user/knob/heap.c')
-rw-r--r--src/user/knob/heap.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/user/knob/heap.c b/src/user/knob/heap.c
index 49f9339..b770542 100644
--- a/src/user/knob/heap.c
+++ b/src/user/knob/heap.c
@@ -1,4 +1,7 @@
+#include <knob/format.h>
+
#include <pland/syscall.h>
+
#include <stdbool.h>
#include <stdint.h>
@@ -24,23 +27,8 @@ static void add_header(struct block_header *bh) {
__attribute__ ((malloc))
void *get_block(uint32_t bytes) {
-//char nbuf[11];
-//tell_user_sz("[heap::get_block]\n first_block = 0x");
-//itosz_h32((uint32_t)first_block, nbuf);
-//tell_user_sz(nbuf);
-//tell_user_sz("\n");
struct block_header *header = 0;
-
for (struct block_header *ptr = first_block; ptr; ptr = ptr->next) {
- //tell_user_sz(" ptr = 0x");
- //itosz_h32((uint32_t)ptr, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz("\n &ptr->allocated = 0x");
- //itosz_h32((uint32_t)&ptr->allocated, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz("\n ptr->allocated = ");
- //tell_user_sz(ptr->allocated ? "true\n" : "false\n");
-
if (ptr->allocated)
continue;
if (ptr->length == bytes) {
@@ -63,14 +51,7 @@ void *get_block(uint32_t bytes) {
if (!header) {
uint32_t size_with_header = bytes + sizeof(struct block_header);
if (!(size_with_header % 4096)) {
- //tell_user_sz(" allocate ");
- //itosz(size_with_header / 4096, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz(" pages = 0x");
header = _allocate_ram(size_with_header / 4096);
- //itosz_h32((uint32_t)header, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz("\n");
if (!header)
return 0;
header->length = bytes;
@@ -78,14 +59,7 @@ void *get_block(uint32_t bytes) {
}
else {
uint32_t pages = (bytes + sizeof(struct block_header) * 2) / 4096 + 1;
- //tell_user_sz(" allocate ");
- //itosz(pages, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz(" pages = 0x");
header = _allocate_ram(pages);
- //itosz_h32((uint32_t)header, nbuf);
- //tell_user_sz(nbuf);
- //tell_user_sz("\n");
if (!header)
return 0;
header->length = bytes;