Changeset 4872160 in mainline for boot/generic/src/balloc.c
- Timestamp:
- 2010-05-04T10:44:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 568db0f
- Parents:
- bb252ca
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/generic/src/balloc.c
rbb252ca r4872160 28 28 29 29 #include <balloc.h> 30 #include <asm.h> 31 #include <types.h> 30 #include <typedefs.h> 32 31 #include <align.h> 33 32 34 33 static ballocs_t *ballocs; 35 34 static uintptr_t phys_base; 35 static size_t max_size; 36 36 37 void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base) 37 void balloc_init(ballocs_t *ball, void *base, uintptr_t kernel_base, 38 size_t size) 38 39 { 39 40 ballocs = ball; 40 phys_base = base; 41 phys_base = (uintptr_t) base; 42 max_size = size; 41 43 ballocs->base = kernel_base; 42 44 ballocs->size = 0; … … 45 47 void *balloc(size_t size, size_t alignment) 46 48 { 49 if (alignment == 0) 50 return NULL; 51 47 52 /* Enforce minimal alignment. */ 48 53 alignment = ALIGN_UP(alignment, 4); … … 50 55 uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment); 51 56 52 if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)57 if (ALIGN_UP(ballocs->size, alignment) + size >= max_size) 53 58 return NULL; 54 59
Note:
See TracChangeset
for help on using the changeset viewer.