source: mainline/kernel/generic/src/ipc/sysipc_ops.c@ c32b6f0

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c32b6f0 was 466e95f7, checked in by Jakub Jermar <jakub@…>, 13 years ago

Add SYSIPC_OP macro to avoid repeating the same boilerplate code.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2012 Jakub Jermar
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 genericipc
30 * @{
31 */
32/** @file
33 */
34
35#include <ipc/sysipc_ops.h>
36#include <abi/ipc/methods.h>
37#include <abi/errno.h>
38
39/* Forward declarations. */
40sysipc_ops_t ipc_m_connection_clone_ops;
41sysipc_ops_t ipc_m_clone_establish_ops;
42sysipc_ops_t ipc_m_connect_to_me_ops;
43sysipc_ops_t ipc_m_connect_me_to_ops;
44sysipc_ops_t ipc_m_share_out_ops;
45sysipc_ops_t ipc_m_share_in_ops;
46sysipc_ops_t ipc_m_data_write_ops;
47sysipc_ops_t ipc_m_data_read_ops;
48sysipc_ops_t ipc_m_state_change_authorize_ops;
49sysipc_ops_t ipc_m_debug_ops;
50
51static sysipc_ops_t *sysipc_ops[] = {
52 [IPC_M_CONNECTION_CLONE] = &ipc_m_connection_clone_ops,
53 [IPC_M_CLONE_ESTABLISH] = &ipc_m_clone_establish_ops,
54 [IPC_M_CONNECT_TO_ME] = &ipc_m_connect_to_me_ops,
55 [IPC_M_CONNECT_ME_TO] = &ipc_m_connect_me_to_ops,
56 [IPC_M_SHARE_OUT] = &ipc_m_share_out_ops,
57 [IPC_M_SHARE_IN] = &ipc_m_share_in_ops,
58 [IPC_M_DATA_WRITE] = &ipc_m_data_write_ops,
59 [IPC_M_DATA_READ] = &ipc_m_data_read_ops,
60 [IPC_M_STATE_CHANGE_AUTHORIZE] = &ipc_m_state_change_authorize_ops,
61 [IPC_M_DEBUG] = &ipc_m_debug_ops
62};
63
64static sysipc_ops_t null_ops = {
65 .request_preprocess = null_request_preprocess,
66 .request_forget = null_request_forget,
67 .request_process = null_request_process,
68 .answer_cleanup = null_answer_cleanup,
69 .answer_preprocess = null_answer_preprocess,
70 .answer_process = null_answer_process,
71};
72
73int null_request_preprocess(call_t *call, phone_t *phone)
74{
75 return EOK;
76}
77
78int null_request_forget(call_t *call)
79{
80 return EOK;
81}
82
83int null_request_process(call_t *call, answerbox_t *box)
84{
85 return EOK;
86}
87
88int null_answer_cleanup(call_t *call, ipc_data_t *data)
89{
90 return EOK;
91}
92
93int null_answer_preprocess(call_t *call, ipc_data_t *data)
94{
95 return EOK;
96}
97
98int null_answer_process(call_t *call)
99{
100 return EOK;
101}
102
103sysipc_ops_t *sysipc_ops_get(sysarg_t imethod)
104{
105 if (imethod < sizeof(sysipc_ops) / (sizeof(sysipc_ops_t *)))
106 return sysipc_ops[imethod] ? sysipc_ops[imethod] : &null_ops;
107
108 return &null_ops;
109}
110
111/** @}
112 */
Note: See TracBrowser for help on using the repository browser.