Rev 1462 | Rev 1547 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1462 | Rev 1501 | ||
---|---|---|---|
Line 54... | Line 54... | ||
54 | * use a trick: First read a seconds, then read microseconds, then |
54 | * use a trick: First read a seconds, then read microseconds, then |
55 | * read seconds again. If a second elapsed in the meantime, read |
55 | * read seconds again. If a second elapsed in the meantime, read |
56 | * useconds again. This provides assurance, that at least the |
56 | * useconds again. This provides assurance, that at least the |
57 | * sequence of subsequent gettimeofday calls is ordered. |
57 | * sequence of subsequent gettimeofday calls is ordered. |
58 | */ |
58 | */ |
59 | #define TMAREA (100*1024*1024) |
- | |
60 | int gettimeofday(struct timeval *tv, struct timezone *tz) |
59 | int gettimeofday(struct timeval *tv, struct timezone *tz) |
61 | { |
60 | { |
62 | void *mapping; |
61 | void *mapping; |
63 | sysarg_t s1, s2; |
62 | sysarg_t s1, s2; |
64 | sysarg_t rights; |
63 | sysarg_t rights; |
65 | int res; |
64 | int res; |
66 | 65 | ||
67 | if (!ktime) { |
66 | if (!ktime) { |
68 | /* TODO: specify better, where to map the area */ |
67 | mapping = as_get_mappable_page(PAGE_SIZE); |
69 | /* Get the mapping of kernel clock */ |
68 | /* Get the mapping of kernel clock */ |
70 | res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
69 | res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
71 | TMAREA, |
- | |
72 | PAGE_SIZE, |
70 | mapping, PAGE_SIZE, 0, |
73 | 0, |
- | |
74 | NULL,&rights,NULL); |
71 | NULL,&rights,NULL); |
75 | if (res) { |
72 | if (res) { |
76 | printf("Failed to initialize timeofday memarea\n"); |
73 | printf("Failed to initialize timeofday memarea\n"); |
77 | _exit(1); |
74 | _exit(1); |
78 | } |
75 | } |
79 | if (rights != (AS_AREA_READ | AS_AREA_CACHEABLE)) { |
76 | if (rights != (AS_AREA_READ | AS_AREA_CACHEABLE)) { |
80 | printf("Received bad rights on time area: %X\n", |
77 | printf("Received bad rights on time area: %X\n", |
81 | rights); |
78 | rights); |
82 | as_area_destroy(TMAREA); |
79 | as_area_destroy(mapping); |
83 | _exit(1); |
80 | _exit(1); |
84 | } |
81 | } |
85 | ktime = (void *) (TMAREA); |
82 | ktime = mapping; |
86 | } |
83 | } |
87 | if (tz) { |
84 | if (tz) { |
88 | tz->tz_minuteswest = 0; |
85 | tz->tz_minuteswest = 0; |
89 | tz->tz_dsttime = DST_NONE; |
86 | tz->tz_dsttime = DST_NONE; |
90 | } |
87 | } |