comparison src/os/heap.c @ 150:e72f984619c7

Consolidated a lot of the defines which relate to the memory layout There is a new file (include/os/memLayout.h) which now includes just about all the #defines
author Jonathan Pevarnek <pevarnj@gmail.com>
date Wed, 02 Nov 2011 09:55:09 -0400
parents eb69d1caa83b
children 54ccc4f06e6b
comparison
equal deleted inserted replaced
149:eb69d1caa83b 150:e72f984619c7
1 #include <os/heap.h> 1 #include <os/heap.h>
2 #include <memHead.h> 2 #include <memHead.h>
3 #include <os/storageKeys.h> 3 #include <os/storageKeys.h>
4 #include <os/memLayout.h>
4 5
5 static Header base; 6 static Header base;
6 static Header *allocp = NULL; 7 static Header *allocp = NULL;
7 8
8 void heap_init(size_t memSize) 9 void heap_init(size_t memSize)
32 cur->size = nUnits; 33 cur->size = nUnits;
33 *ammt = cur->size*PageSize - sizeof(Header); 34 *ammt = cur->size*PageSize - sizeof(Header);
34 } 35 }
35 allocp = prev; 36 allocp = prev;
36 intptr_t ptr; 37 intptr_t ptr;
37 for(ptr = (intptr_t)cur; (ptr - (intptr_t)cur)/PageSize < nUnits; ptr += PageSize) { 38 for(ptr = (intptr_t)cur; (ptr - (intptr_t)cur)/BLOCKSIZE < nUnits; ptr += PageSize) {
38 setStorageKey(ptr, PROGSK, 1); 39 setStorageKey(ptr, PROGSK, 1); //TODO only do this if being called by the program (how?)
39 } 40 }
40 return (void*)(cur + 1); 41 return (void*)(cur + 1);
41 } else if(cur == allocp) { //We went back to the start... 42 } else if(cur == allocp) { //We went back to the start...
42 return NULL; 43 return NULL;
43 } 44 }