[f0defd2] | 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. */
|
---|
[37e8c4a] | 40 | extern sysipc_ops_t ipc_m_connect_to_me_ops;
|
---|
| 41 | extern sysipc_ops_t ipc_m_connect_me_to_ops;
|
---|
| 42 | extern sysipc_ops_t ipc_m_page_in_ops;
|
---|
| 43 | extern sysipc_ops_t ipc_m_share_out_ops;
|
---|
| 44 | extern sysipc_ops_t ipc_m_share_in_ops;
|
---|
| 45 | extern sysipc_ops_t ipc_m_data_write_ops;
|
---|
| 46 | extern sysipc_ops_t ipc_m_data_read_ops;
|
---|
| 47 | extern sysipc_ops_t ipc_m_state_change_authorize_ops;
|
---|
| 48 | extern sysipc_ops_t ipc_m_debug_ops;
|
---|
[f0defd2] | 49 |
|
---|
| 50 | static sysipc_ops_t *sysipc_ops[] = {
|
---|
| 51 | [IPC_M_CONNECT_TO_ME] = &ipc_m_connect_to_me_ops,
|
---|
| 52 | [IPC_M_CONNECT_ME_TO] = &ipc_m_connect_me_to_ops,
|
---|
[072607b] | 53 | [IPC_M_PAGE_IN] = &ipc_m_page_in_ops,
|
---|
[f0defd2] | 54 | [IPC_M_SHARE_OUT] = &ipc_m_share_out_ops,
|
---|
| 55 | [IPC_M_SHARE_IN] = &ipc_m_share_in_ops,
|
---|
| 56 | [IPC_M_DATA_WRITE] = &ipc_m_data_write_ops,
|
---|
| 57 | [IPC_M_DATA_READ] = &ipc_m_data_read_ops,
|
---|
| 58 | [IPC_M_STATE_CHANGE_AUTHORIZE] = &ipc_m_state_change_authorize_ops,
|
---|
| 59 | [IPC_M_DEBUG] = &ipc_m_debug_ops
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | static sysipc_ops_t null_ops = {
|
---|
| 63 | .request_preprocess = null_request_preprocess,
|
---|
[b1e6269] | 64 | .request_forget = null_request_forget,
|
---|
[f0defd2] | 65 | .request_process = null_request_process,
|
---|
[b1e6269] | 66 | .answer_cleanup = null_answer_cleanup,
|
---|
[f0defd2] | 67 | .answer_preprocess = null_answer_preprocess,
|
---|
| 68 | .answer_process = null_answer_process,
|
---|
| 69 | };
|
---|
| 70 |
|
---|
[b7fd2a0] | 71 | errno_t null_request_preprocess(call_t *call, phone_t *phone)
|
---|
[f0defd2] | 72 | {
|
---|
| 73 | return EOK;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[b7fd2a0] | 76 | errno_t null_request_forget(call_t *call)
|
---|
[b1e6269] | 77 | {
|
---|
[466e95f7] | 78 | return EOK;
|
---|
[b1e6269] | 79 | }
|
---|
| 80 |
|
---|
[f0defd2] | 81 | int null_request_process(call_t *call, answerbox_t *box)
|
---|
| 82 | {
|
---|
[7f11dc6] | 83 | return 0;
|
---|
[f0defd2] | 84 | }
|
---|
| 85 |
|
---|
[b7fd2a0] | 86 | errno_t null_answer_cleanup(call_t *call, ipc_data_t *data)
|
---|
[b1e6269] | 87 | {
|
---|
[466e95f7] | 88 | return EOK;
|
---|
[b1e6269] | 89 | }
|
---|
| 90 |
|
---|
[b7fd2a0] | 91 | errno_t null_answer_preprocess(call_t *call, ipc_data_t *data)
|
---|
[f0defd2] | 92 | {
|
---|
| 93 | return EOK;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[b7fd2a0] | 96 | errno_t null_answer_process(call_t *call)
|
---|
[f0defd2] | 97 | {
|
---|
| 98 | return EOK;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | sysipc_ops_t *sysipc_ops_get(sysarg_t imethod)
|
---|
| 102 | {
|
---|
[e8039a86] | 103 | if (imethod < sizeof(sysipc_ops) / (sizeof(sysipc_ops_t *)))
|
---|
[642dc72] | 104 | return sysipc_ops[imethod] ? sysipc_ops[imethod] : &null_ops;
|
---|
| 105 |
|
---|
[f0defd2] | 106 | return &null_ops;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /** @}
|
---|
| 110 | */
|
---|