diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-13 18:29:53 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-13 18:29:53 -0400 |
commit | 54101cf327b7def90636babbadbb66ce697298ee (patch) | |
tree | 4723c6803e855b3a82c4020bb6f287b43a080cb4 /src/user/knob/heap.c | |
parent | 5481848e27fdd4fc859def9841a0283665531a46 (diff) | |
download | portland-os-54101cf327b7def90636babbadbb66ce697298ee.tar.gz |
making elf loader zero bss sections
Diffstat (limited to 'src/user/knob/heap.c')
-rw-r--r-- | src/user/knob/heap.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/user/knob/heap.c b/src/user/knob/heap.c index ec21129..49f9339 100644 --- a/src/user/knob/heap.c +++ b/src/user/knob/heap.c @@ -24,9 +24,23 @@ 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) { @@ -49,7 +63,14 @@ 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; @@ -57,7 +78,14 @@ 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; |