source: mainline/uspace/srv/devmap/devmap.c@ 90e6025

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 90e6025 was 90e6025, checked in by Josef Cejka <malyzelenyhnus@…>, 18 years ago

Fixed naming convention in IPC.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2007 Josef Cejka
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/**
30 * @defgroup devmap Device mapper.
31 * @brief HelenOS device mapper.
32 * @{
33 */
34
35/** @file
36 */
37
38#include <ipc/services.h>
39#include <ipc/ns.h>
40#include <async.h>
41#include <stdio.h>
42#include <errno.h>
43
44#include "devmap.h"
45
46/** Initialize device mapper.
47 *
48 *
49 */
50static int devmap_init()
51{
52 /* */
53
54 return 0;
55}
56
57
58/** Function for handling connections to devmap
59 *
60 */
61static void
62devmap_client_connection(ipc_callid_t iid, ipc_call_t *icall)
63{
64 ipc_callid_t callid;
65 ipc_call_t call;
66 int retval;
67
68 ipc_answer_fast(iid, EOK, 0, 0); /* Accept connection */
69
70 while (1) {
71 callid = async_get_call(&call);
72
73 switch (IPC_GET_METHOD(call)) {
74 case IPC_M_PHONE_HUNGUP:
75 /* TODO: if its a device connection, remove it from table */
76 return; /* Exit thread */
77
78 case DEVMAP_REGISTER:
79 /* TODO: */
80 case DEVMAP_UNREGISTER:
81 /* TODO: */
82 case DEVMAP_CONNECT_TO_DEVICE:
83 /* TODO: */
84 retval = 0;
85 break;
86 default:
87 retval = ENOENT;
88 }
89 ipc_answer_fast(callid, retval, 0, 0);
90 }
91
92}
93
94
95int main(int argc, char *argv[])
96{
97
98 ipcarg_t phonead;
99
100 printf("DevMap: HelenOS device mapper.\n");
101
102 if (devmap_init() != 0) {
103 printf("Error while initializing DevMap service.");
104 return -1;
105 }
106
107 /* Set a handler of incomming connections */
108 async_set_client_connection(devmap_client_connection);
109
110 /* Register device mapper at naming service */
111 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, &phonead) != 0)
112 return -1;
113
114 async_manager();
115 /* Never reached */
116 return 0;
117}
118
119/**
120 * @}
121 */
122
Note: See TracBrowser for help on using the repository browser.