source: mainline/uspace/srv/devmap/devmap.c@ 12a56fa

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

Added basic support for device mapper.

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