source: mainline/uspace/srv/ns/ns.c@ 77ad86c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 77ad86c was 6119f24, checked in by Martin Decky <martin@…>, 14 years ago

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)

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup ns
30 * @{
31 */
32
33/**
34 * @file ns.c
35 * @brief Naming service for HelenOS IPC.
36 */
37
38#include <ipc/ipc.h>
39#include <ipc/ns.h>
40#include <stdio.h>
41#include <errno.h>
42#include <macros.h>
43#include "ns.h"
44#include "service.h"
45#include "clonable.h"
46#include "task.h"
47
48int main(int argc, char **argv)
49{
50 printf(NAME ": HelenOS IPC Naming Service\n");
51
52 int rc = service_init();
53 if (rc != EOK)
54 return rc;
55
56 rc = clonable_init();
57 if (rc != EOK)
58 return rc;
59
60 rc = task_init();
61 if (rc != EOK)
62 return rc;
63
64 printf("%s: Accepting connections\n", NAME);
65
66 while (true) {
67 process_pending_conn();
68 process_pending_wait();
69
70 ipc_call_t call;
71 ipc_callid_t callid = ipc_wait_for_call(&call);
72
73 task_id_t id;
74 sysarg_t retval;
75
76 switch (IPC_GET_IMETHOD(call)) {
77 case IPC_M_PHONE_HUNGUP:
78 retval = ns_task_disconnect(&call);
79 break;
80 case IPC_M_CONNECT_TO_ME:
81 /*
82 * Server requests service registration.
83 */
84 if (service_clonable(IPC_GET_ARG1(call))) {
85 register_clonable(IPC_GET_ARG1(call),
86 IPC_GET_ARG5(call), &call, callid);
87 continue;
88 } else {
89 retval = register_service(IPC_GET_ARG1(call),
90 IPC_GET_ARG5(call), &call);
91 }
92 break;
93 case IPC_M_CONNECT_ME_TO:
94 /*
95 * Client requests to be connected to a service.
96 */
97 if (service_clonable(IPC_GET_ARG1(call))) {
98 connect_to_clonable(IPC_GET_ARG1(call),
99 &call, callid);
100 continue;
101 } else {
102 connect_to_service(IPC_GET_ARG1(call), &call,
103 callid);
104 continue;
105 }
106 break;
107 case NS_PING:
108 retval = EOK;
109 break;
110 case NS_TASK_WAIT:
111 id = (task_id_t)
112 MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
113 wait_for_task(id, &call, callid);
114 continue;
115 case NS_ID_INTRO:
116 retval = ns_task_id_intro(&call);
117 break;
118 case NS_RETVAL:
119 retval = ns_task_retval(&call);
120 break;
121 default:
122 retval = ENOENT;
123 break;
124 }
125
126 if (!(callid & IPC_CALLID_NOTIFICATION))
127 ipc_answer_0(callid, retval);
128 }
129
130 /* Not reached */
131 return 0;
132}
133
134/**
135 * @}
136 */
Note: See TracBrowser for help on using the repository browser.