55#include "exceptions/exception_handler.h"
66#include "std/memory.h"
77#include "math/math.h"
8+ #include "console/kio.h"
89
910#define PD_TABLE 0b11
1011#define PD_BLOCK 0b01
@@ -55,8 +56,6 @@ void pfree(void* ptr, uint64_t size) {
5556uint64_t start ;
5657uint64_t end ;
5758
58- #include "console/kio.h"
59-
6059void * palloc (uint64_t size , uint8_t level , uint8_t attributes , bool full ) {
6160 if (!start ) start = count_pages (get_user_ram_start (),PAGE_SIZE );
6261 if (!end ) end = count_pages (get_user_ram_end (),PAGE_SIZE );
@@ -169,7 +168,7 @@ bool page_used(uintptr_t ptr){
169168void mark_used (uintptr_t address , size_t pages )
170169{
171170 if ((address & (PAGE_SIZE - 1 )) != 0 ) {
172- // kprintf("[mark_used error] address %x not aligned", address);
171+ kprintf ("[mark_used error] address %x not aligned" , address );
173172 return ;
174173 }
175174 if (pages == 0 ) return ;
@@ -193,7 +192,7 @@ void* kalloc(void *page, uint64_t size, uint16_t alignment, uint8_t level){
193192
194193 size = (size + alignment - 1 ) & ~(alignment - 1 );
195194
196- // kprintfv("[in_page_alloc] Requested size: %x", size);
195+ kprintfv ("[in_page_alloc] Requested size: %x" , size );
197196
198197 mem_page * info = (mem_page * )page ;
199198
@@ -206,43 +205,43 @@ void* kalloc(void *page, uint64_t size, uint16_t alignment, uint8_t level){
206205 FreeBlock * * curr = & info -> free_list ;
207206 while (* curr ) {
208207 if ((* curr )-> size >= size ) {
209- // kprintfv("[in_page_alloc] Reusing free block at %x",(uintptr_t)*curr);
208+ kprintfv ("[in_page_alloc] Reusing free block at %x" ,(uintptr_t )* curr );
210209
211210 uint64_t result = (uint64_t )* curr ;
212211 * curr = (* curr )-> next ;
213212 memset ((void * )result , 0 , size );
214213 info -> size += size ;
215214 return (void * )result ;
216215 }
217- // kprintfv("-> %x",(uintptr_t)&(*curr)->next);
216+ kprintfv ("-> %x" ,(uintptr_t )& (* curr )-> next );
218217 curr = & (* curr )-> next ;
219218 }
220219
221- // kprintfv("[in_page_alloc] Current next pointer %x",info->next_free_mem_ptr);
220+ kprintfv ("[in_page_alloc] Current next pointer %x" ,info -> next_free_mem_ptr );
222221
223222 info -> next_free_mem_ptr = (info -> next_free_mem_ptr + alignment - 1 ) & ~(alignment - 1 );
224223
225- // kprintfv("[in_page_alloc] Aligned next pointer %x",info->next_free_mem_ptr);
224+ kprintfv ("[in_page_alloc] Aligned next pointer %x" ,info -> next_free_mem_ptr );
226225
227226 if (info -> next_free_mem_ptr + size > (((uintptr_t )page ) + PAGE_SIZE )) {
228227 if (!info -> next )
229228 info -> next = palloc (PAGE_SIZE , level , info -> attributes , false);
230- // kprintfv("[in_page_alloc] Page full. Moving to %x",(uintptr_t)info->next);
229+ kprintfv ("[in_page_alloc] Page full. Moving to %x" ,(uintptr_t )info -> next );
231230 return kalloc (info -> next , size , alignment , level );
232231 }
233232
234233 uint64_t result = info -> next_free_mem_ptr ;
235234 info -> next_free_mem_ptr += size ;
236235
237- // kprintfv("[in_page_alloc] Allocated address %x",result);
236+ kprintfv ("[in_page_alloc] Allocated address %x" ,result );
238237
239238 memset ((void * )result , 0 , size );
240239 info -> size += size ;
241240 return (void * )result ;
242241}
243242
244243void kfree (void * ptr , uint64_t size ) {
245- // kprintfv("[page_alloc_free] Freeing block at %x size %x",(uintptr_t)ptr, size);
244+ kprintfv ("[page_alloc_free] Freeing block at %x size %x" ,(uintptr_t )ptr , size );
246245
247246 memset ((void * )ptr ,0 ,size );
248247
0 commit comments