//uspace/trunk/libc/include/as.h |
---|
40,6 → 40,5 |
extern int as_area_resize(void *address, size_t size, int flags); |
extern int as_area_destroy(void *address); |
extern void *set_maxheapsize(size_t mhs); |
extern void * as_get_mappable_page(size_t sz); |
#endif |
//uspace/trunk/libc/include/align.h |
---|
42,6 → 42,6 |
* @param s Address or size to be aligned. |
* @param a Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(s, a) ((long)((s) + ((a) - 1)) & ~((long) (a) - 1)) |
#define ALIGN_UP(s, a) (((s) + ((a) - 1)) & ~((a) - 1)) |
#endif |
//uspace/trunk/libc/generic/time.c |
---|
56,6 → 56,7 |
* useconds again. This provides assurance, that at least the |
* sequence of subsequent gettimeofday calls is ordered. |
*/ |
#define TMAREA (100*1024*1024) |
int gettimeofday(struct timeval *tv, struct timezone *tz) |
{ |
void *mapping; |
64,10 → 65,12 |
int res; |
if (!ktime) { |
mapping = as_get_mappable_page(PAGE_SIZE); |
/* TODO: specify better, where to map the area */ |
/* Get the mapping of kernel clock */ |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
mapping, PAGE_SIZE, 0, |
TMAREA, |
PAGE_SIZE, |
0, |
NULL,&rights,NULL); |
if (res) { |
printf("Failed to initialize timeofday memarea\n"); |
76,10 → 79,10 |
if (rights != (AS_AREA_READ | AS_AREA_CACHEABLE)) { |
printf("Received bad rights on time area: %X\n", |
rights); |
as_area_destroy(mapping); |
as_area_destroy(TMAREA); |
_exit(1); |
} |
ktime = mapping; |
ktime = (void *) (TMAREA); |
} |
if (tz) { |
tz->tz_minuteswest = 0; |
//uspace/trunk/libc/generic/as.c |
---|
26,24 → 26,10 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <stdlib.h> |
#include <unistd.h> |
#include <string.h> |
#include <ddi.h> |
#include <sysinfo.h> |
#include <align.h> |
#include <as.h> |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include <kernel/errno.h> |
#include <as.h> |
#include <libc.h> |
#include <unistd.h> |
#include <align.h> |
#include <task.h> |
/** Create address space area. |
* |
84,9 → 70,6 |
static size_t heapsize = 0; |
static size_t maxheapsize = (size_t)(-1); |
static void * last_allocated = 0; |
/* Start of heap linker symbol */ |
extern char _heap; |
124,7 → 107,6 |
return res; |
} |
/** Set maximum heap size and return pointer just after the heap */ |
void *set_maxheapsize(size_t mhs) |
{ |
maxheapsize=mhs; |
132,25 → 114,3 |
return (void *)&_heap + maxheapsize; |
} |
/** Return pointer to some unmapped area, where fits new as_area |
* |
* TODO: make some first_fit/... algorithm, we are now just incrementing |
* the pointer to last area |
*/ |
void * as_get_mappable_page(size_t sz) |
{ |
void *res; |
/* Set heapsize to some meaningful value */ |
if (maxheapsize == -1) |
set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE)); |
if (!last_allocated) |
last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE); |
sz = ALIGN_UP(sz, PAGE_SIZE); |
res = last_allocated; |
last_allocated += sz; |
return res; |
} |