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