Changeset 6119f24 in mainline for uspace/srv/ns/ns.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/srv/ns/ns.c

    rd7533c7 r6119f24  
    3737
    3838#include <ipc/ipc.h>
    39 #include <ipc/services.h>
    4039#include <ipc/ns.h>
    41 #include <unistd.h>
    4240#include <stdio.h>
    4341#include <errno.h>
    44 #include <as.h>
    45 #include <ddi.h>
    46 #include <event.h>
    4742#include <macros.h>
    48 #include <sysinfo.h>
    4943#include "ns.h"
    5044#include "service.h"
    5145#include "clonable.h"
    5246#include "task.h"
    53 
    54 static void *clockaddr = NULL;
    55 static void *klogaddr = NULL;
    56 
    57 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, void *faddr,
    58     size_t pages, void **addr)
    59 {
    60         if ((faddr == NULL) || (pages == 0)) {
    61                 ipc_answer_0(callid, ENOENT);
    62                 return;
    63         }
    64        
    65         if (*addr == NULL) {
    66                 *addr = as_get_mappable_page(pages * PAGE_SIZE);
    67                
    68                 if (*addr == NULL) {
    69                         ipc_answer_0(callid, ENOENT);
    70                         return;
    71                 }
    72                
    73                 if (physmem_map(faddr, *addr, pages,
    74                     AS_AREA_READ | AS_AREA_CACHEABLE) != 0) {
    75                         ipc_answer_0(callid, ENOENT);
    76                         return;
    77                 }
    78         }
    79        
    80         ipc_answer_2(callid, EOK, (sysarg_t) *addr, AS_AREA_READ);
    81 }
    82 
    83 static void setup_clock_area(ipc_callid_t callid, ipc_call_t *call, void **addr)
    84 {
    85         uintptr_t faddr;
    86         int err = sysinfo_get_value("clock.faddr", &faddr);
    87        
    88         if (err != EOK)
    89                 ipc_answer_0(callid, err);
    90        
    91         get_as_area(callid, call, (void *) faddr, 1, addr);
    92 }
    93 
    94 static void setup_klog_area(ipc_callid_t callid, ipc_call_t *call, void **addr)
    95 {
    96         uintptr_t faddr;
    97         int err = sysinfo_get_value("klog.faddr", &faddr);
    98        
    99         if (err != EOK)
    100                 ipc_answer_0(callid, err);
    101        
    102         size_t pages;
    103         err = sysinfo_get_value("klog.pages", &pages);
    104        
    105         if (err != EOK)
    106                 ipc_answer_0(callid, err);
    107        
    108         get_as_area(callid, call, (void *) faddr, pages, addr);
    109 }
    11047
    11148int main(int argc, char **argv)
     
    13875               
    13976                switch (IPC_GET_IMETHOD(call)) {
    140                 case IPC_M_SHARE_IN:
    141                         switch (IPC_GET_ARG3(call)) {
    142                         case SERVICE_MEM_REALTIME:
    143                                 setup_clock_area(callid, &call, &clockaddr);
    144                                 break;
    145                         case SERVICE_MEM_KLOG:
    146                                 setup_klog_area(callid, &call, &klogaddr);
    147                                 break;
    148                         default:
    149                                 ipc_answer_0(callid, ENOENT);
    150                         }
    151                         continue;
    15277                case IPC_M_PHONE_HUNGUP:
    15378                        retval = ns_task_disconnect(&call);
Note: See TracChangeset for help on using the changeset viewer.