Changeset 6119f24 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-01-29T18:58:24Z (14 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)

Location:
uspace/lib/c
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ipc/ns.c

    rd7533c7 r6119f24  
    3434
    3535#include <async.h>
    36 #include <ipc/services.h>
    3736#include <ipc/ns.h>
    38 #include <sysinfo.h>
    39 #include <errno.h>
    40 #include <as.h>
    41 #include <macros.h>
    4237
    4338int service_register(sysarg_t service)
     
    5651}
    5752
    58 wchar_t *service_klog_share_in(size_t *length)
    59 {
    60         size_t pages;
    61         if (sysinfo_get_value("klog.pages", &pages) != EOK)
    62                 return NULL;
    63        
    64         size_t size = pages * PAGE_SIZE;
    65         *length = size / sizeof(wchar_t);
    66        
    67         wchar_t *klog = (wchar_t *) as_get_mappable_page(size);
    68         if (klog == NULL)
    69                 return NULL;
    70        
    71         int res = async_share_in_start_1_0(PHONE_NS, (void *) klog, size,
    72             SERVICE_MEM_KLOG);
    73         if (res != EOK) {
    74                 as_area_destroy((void *) klog);
    75                 return NULL;
    76         }
    77        
    78         return klog;
    79 }
    80 
    81 void *service_realtime_share_in(void)
    82 {
    83         void *rtime = as_get_mappable_page(PAGE_SIZE);
    84         if (rtime == NULL)
    85                 return NULL;
    86        
    87         int res = async_share_in_start_1_0(PHONE_NS, rtime, PAGE_SIZE,
    88             SERVICE_MEM_REALTIME);
    89         if (res != EOK) {
    90                 as_area_destroy((void *) rtime);
    91                 return NULL;
    92         }
    93        
    94         return rtime;
    95 }
    96 
    9753/** @}
    9854 */
  • 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       
  • uspace/lib/c/include/ipc/ns.h

    rd7533c7 r6119f24  
    5050extern int service_connect_blocking(sysarg_t, sysarg_t, sysarg_t);
    5151
    52 extern wchar_t *service_klog_share_in(size_t *);
    53 extern void *service_realtime_share_in(void);
    54 
    5552#endif
    5653
  • uspace/lib/c/include/ipc/services.h

    rd7533c7 r6119f24  
    6666} services_t;
    6767
    68 /* Memory areas to be received from NS */
    69 typedef enum {
    70         SERVICE_MEM_REALTIME = 1,
    71         SERVICE_MEM_KLOG = 2
    72 } mem_services_t;
    73 
    7468#endif
    7569
Note: See TracChangeset for help on using the changeset viewer.