- Timestamp:
- 2006-06-02T11:35:05Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2d22049
- Parents:
- 49d072e
- Location:
- libc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/as.c
r49d072e rbf9afa07 27 27 */ 28 28 29 #include <stdlib.h> 30 #include <unistd.h> 31 #include <string.h> 32 #include <ddi.h> 33 #include <sysinfo.h> 34 #include <align.h> 35 #include <as.h> 36 #include <ipc/fb.h> 37 #include <ipc/ipc.h> 38 #include <ipc/ns.h> 39 #include <ipc/services.h> 40 #include <kernel/errno.h> 41 42 29 43 #include <as.h> 30 44 #include <libc.h> 31 45 #include <unistd.h> 32 #include < task.h>46 #include <align.h> 33 47 34 48 /** Create address space area. … … 71 85 static size_t heapsize = 0; 72 86 static size_t maxheapsize = (size_t)(-1); 87 88 static void * last_allocated = 0; 89 73 90 /* Start of heap linker symbol */ 74 91 extern char _heap; … … 108 125 } 109 126 127 /** Set maximum heap size and return pointer just after the heap */ 110 128 void *set_maxheapsize(size_t mhs) 111 129 { … … 115 133 116 134 } 135 136 /** Return pointer to some unmapped area, where fits new as_area 137 * 138 * TODO: make some first_fit/... algorithm, we are now just incrementing 139 * the pointer to last area 140 */ 141 void * as_get_mappable_page(size_t sz) 142 { 143 void *res; 144 145 /* Set heapsize to some meaningful value */ 146 if (maxheapsize == -1) 147 set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE)); 148 if (!last_allocated) 149 last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE); 150 151 sz = ALIGN_UP(sz, PAGE_SIZE); 152 res = last_allocated; 153 last_allocated += sz; 154 155 return res; 156 } -
libc/generic/time.c
r49d072e rbf9afa07 57 57 * sequence of subsequent gettimeofday calls is ordered. 58 58 */ 59 #define TMAREA (100*1024*1024)60 59 int gettimeofday(struct timeval *tv, struct timezone *tz) 61 60 { … … 66 65 67 66 if (!ktime) { 68 /* TODO: specify better, where to map the area */67 mapping = as_get_mappable_page(PAGE_SIZE); 69 68 /* Get the mapping of kernel clock */ 70 69 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, 71 TMAREA, 72 PAGE_SIZE, 73 0, 70 mapping, PAGE_SIZE, 0, 74 71 NULL,&rights,NULL); 75 72 if (res) { … … 80 77 printf("Received bad rights on time area: %X\n", 81 78 rights); 82 as_area_destroy( TMAREA);79 as_area_destroy(mapping); 83 80 _exit(1); 84 81 } 85 ktime = (void *) (TMAREA);82 ktime = mapping; 86 83 } 87 84 if (tz) { -
libc/include/align.h
r49d072e rbf9afa07 43 43 * @param a Size of alignment, must be power of 2. 44 44 */ 45 #define ALIGN_UP(s, a) (( (s) + ((a) - 1)) & ~((a) - 1))45 #define ALIGN_UP(s, a) ((long)((s) + ((a) - 1)) & ~((long) (a) - 1)) 46 46 47 47 #endif -
libc/include/as.h
r49d072e rbf9afa07 41 41 extern int as_area_destroy(void *address); 42 42 extern void *set_maxheapsize(size_t mhs); 43 extern void * as_get_mappable_page(size_t sz); 43 44 44 45 #endif
Note:
See TracChangeset
for help on using the changeset viewer.