2
* Copyright (c) 2006 Ondrej Palkovsky
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
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.
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.
35
* @brief Naming service for HelenOS IPC.
39
#include <ipc/services.h>
54
static void *clockaddr = NULL;
55
static void *klogaddr = NULL;
57
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, void *ph_addr,
58
size_t pages, void **addr)
60
if (ph_addr == NULL) {
61
ipc_answer_0(callid, ENOENT);
66
*addr = as_get_mappable_page(pages * PAGE_SIZE);
69
ipc_answer_0(callid, ENOENT);
73
if (physmem_map(ph_addr, *addr, pages,
74
AS_AREA_READ | AS_AREA_CACHEABLE) != 0) {
75
ipc_answer_0(callid, ENOENT);
80
ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ);
83
int main(int argc, char **argv)
85
printf(NAME ": HelenOS IPC Naming Service\n");
87
int rc = service_init();
99
printf(NAME ": Accepting connections\n");
102
process_pending_conn();
103
process_pending_wait();
106
ipc_callid_t callid = ipc_wait_for_call(&call);
111
switch (IPC_GET_METHOD(call)) {
113
switch (IPC_GET_ARG3(call)) {
114
case SERVICE_MEM_REALTIME:
115
get_as_area(callid, &call,
116
(void *) sysinfo_value("clock.faddr"),
119
case SERVICE_MEM_KLOG:
120
get_as_area(callid, &call,
121
(void *) sysinfo_value("klog.faddr"),
122
sysinfo_value("klog.pages"), &klogaddr);
125
ipc_answer_0(callid, ENOENT);
128
case IPC_M_PHONE_HUNGUP:
129
retval = ns_task_disconnect(&call);
131
case IPC_M_CONNECT_TO_ME:
133
* Server requests service registration.
135
if (service_clonable(IPC_GET_ARG1(call))) {
136
register_clonable(IPC_GET_ARG1(call),
137
IPC_GET_ARG5(call), &call, callid);
140
retval = register_service(IPC_GET_ARG1(call),
141
IPC_GET_ARG5(call), &call);
144
case IPC_M_CONNECT_ME_TO:
146
* Client requests to be connected to a service.
148
if (service_clonable(IPC_GET_ARG1(call))) {
149
connect_to_clonable(IPC_GET_ARG1(call),
153
connect_to_service(IPC_GET_ARG1(call), &call,
163
MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
164
wait_for_task(id, &call, callid);
167
retval = ns_task_id_intro(&call);
170
retval = ns_task_retval(&call);
177
if (!(callid & IPC_CALLID_NOTIFICATION))
178
ipc_answer_0(callid, retval);