Changes in boot/genarch/balloc.c [e731b0d:95b47c82] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/balloc.c
re731b0d r95b47c82 28 28 29 29 #include <balloc.h> 30 #include <asm.h>31 30 #include <types.h> 32 31 #include <align.h> 33 32 34 33 static ballocs_t *ballocs; 35 static uintptr_t phys_base;36 34 37 void balloc_init(ballocs_t *b all, uintptr_t base, uintptr_t kernel_base)35 void balloc_init(ballocs_t *b, uintptr_t base) 38 36 { 39 ballocs = ball; 40 phys_base = base; 41 ballocs->base = kernel_base; 37 ballocs = b; 38 ballocs->base = base; 42 39 ballocs->size = 0; 43 40 } … … 45 42 void *balloc(size_t size, size_t alignment) 46 43 { 44 uintptr_t addr; 45 47 46 /* Enforce minimal alignment. */ 48 47 alignment = ALIGN_UP(alignment, 4); 49 48 50 uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment);51 49 addr = ballocs->base + ALIGN_UP(ballocs->size, alignment); 50 52 51 if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE) 53 52 return NULL; 54 53 55 54 ballocs->size = ALIGN_UP(ballocs->size, alignment) + size; 56 55 57 56 return (void *) addr; 58 57 } 59 60 void *balloc_rebase(void *ptr)61 {62 return (void *) ((uintptr_t) ptr - phys_base + ballocs->base);63 }
Note:
See TracChangeset
for help on using the changeset viewer.