Changeset 6119f24 in mainline for uspace/lib/c/generic/time.c


Ignore:
Timestamp:
2011-01-29T18:58:24Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
10477601, 6aef742
Parents:
d7533c7
Message:

map klog area and clock page directly in tasks which require them (do not use the memory sharing from naming service via IPC)
this avoids the circular dependency between gettimeofday() and the async framework (as reported by Jakub Jermar)
it also simplifies the code of the naming service (the memory sharing was never strictly necessary, it was only a demonstrator)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/time.c

    rd7533c7 r6119f24  
    3434
    3535#include <sys/time.h>
    36 #include <unistd.h>
     36#include <time.h>
    3737#include <bool.h>
    38 #include <ipc/ns.h>
    3938#include <arch/barrier.h>
    4039#include <macros.h>
     40#include <errno.h>
     41#include <sysinfo.h>
     42#include <as.h>
     43#include <ddi.h>
    4144#include <libc.h>
    42 #include <time.h>
    4345
    4446/** Pointer to kernel shared variables with time */
     
    137139int gettimeofday(struct timeval *tv, struct timezone *tz)
    138140{
    139         if (!ktime) {
    140                 ktime = service_realtime_share_in();
    141                 if (!ktime)
     141        if (ktime == NULL) {
     142                uintptr_t faddr;
     143                int rc = sysinfo_get_value("clock.faddr", &faddr);
     144                if (rc != EOK) {
     145                        errno = rc;
    142146                        return -1;
     147                }
     148               
     149                void *addr = as_get_mappable_page(PAGE_SIZE);
     150                if (addr == NULL) {
     151                        errno = ENOMEM;
     152                        return -1;
     153                }
     154               
     155                rc = physmem_map((void *) faddr, addr, 1,
     156                    AS_AREA_READ | AS_AREA_CACHEABLE);
     157                if (rc != EOK) {
     158                        as_area_destroy(addr);
     159                        errno = rc;
     160                        return -1;
     161                }
     162               
     163                ktime = addr;
    143164        }
    144165       
Note: See TracChangeset for help on using the changeset viewer.