[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 | #ifndef KERN_SYSIPC_OPS_H_
|
---|
| 36 | #define KERN_SYSIPC_OPS_H_
|
---|
| 37 |
|
---|
| 38 | #include <ipc/ipc.h>
|
---|
| 39 |
|
---|
[466e95f7] | 40 | #define SYSIPC_OP(op, call, ...) \
|
---|
| 41 | ({ \
|
---|
| 42 | int rc = EOK; \
|
---|
| 43 | \
|
---|
| 44 | sysipc_ops_t *ops; \
|
---|
| 45 | ops = sysipc_ops_get((call)->request_method); \
|
---|
| 46 | if (ops->op) \
|
---|
| 47 | rc = ops->op((call), ##__VA_ARGS__); \
|
---|
| 48 | rc; \
|
---|
| 49 | })
|
---|
| 50 |
|
---|
[f3b97d1] | 51 | /**
|
---|
| 52 | * This header declares the per-method IPC callbacks. Using these callbacks,
|
---|
| 53 | * each IPC method (but system methods in particular), can define actions that
|
---|
| 54 | * will be called at specific moments in the call life-cycle.
|
---|
| 55 | *
|
---|
| 56 | * Normally, the kernel will attempt to invoke the following callbacks in the
|
---|
| 57 | * following order on each call:
|
---|
| 58 | *
|
---|
| 59 | * request_preprocess()
|
---|
| 60 | * request_process()
|
---|
| 61 | * answer_preprocess()
|
---|
| 62 | * answer_process()
|
---|
| 63 | *
|
---|
| 64 | * This callback invocation sequence is a natural order of processing. Note,
|
---|
| 65 | * however, that due to various special circumstances, callbacks may be called
|
---|
| 66 | * also in a different than natural order of processing. This means that some
|
---|
| 67 | * callbacks may be skipped and some others may be called instead.
|
---|
| 68 | *
|
---|
| 69 | * The additional callbacks that may be called are as follows:
|
---|
| 70 | *
|
---|
| 71 | * request_forget()
|
---|
| 72 | * answer_cleanup()
|
---|
| 73 | *
|
---|
| 74 | * There are several notable scenarios in which some callbacks of the natural
|
---|
| 75 | * order of processing will be skipped.
|
---|
| 76 | *
|
---|
| 77 | * The request_process(), answer_preprocess() and answer_process() callbacks
|
---|
[6b83300] | 78 | * will be skipped if the call cannot be delivered to the callee. This may
|
---|
| 79 | * happen when e.g. the request_preprocess() callback fails or the connection
|
---|
| 80 | * to the callee is not functional. The next callback that will be invoked on
|
---|
| 81 | * the call is request_forget().
|
---|
[f3b97d1] | 82 | *
|
---|
| 83 | * The comments for each callback type describe the specifics of each callback
|
---|
| 84 | * such as the context in which it is invoked and various constraints.
|
---|
| 85 | */
|
---|
| 86 |
|
---|
[f0defd2] | 87 | typedef struct {
|
---|
[eb5560a] | 88 | /**
|
---|
| 89 | * This callback is called from request_preprocess().
|
---|
| 90 | *
|
---|
| 91 | * Context: caller
|
---|
| 92 | * Caller alive: guaranteed
|
---|
| 93 | * Races with: N/A
|
---|
| 94 | * Invoked on: all calls
|
---|
| 95 | */
|
---|
[f0defd2] | 96 | int (* request_preprocess)(call_t *, phone_t *);
|
---|
[eb5560a] | 97 |
|
---|
| 98 | /**
|
---|
| 99 | * This callback is called when the IPC cleanup code wins the race to
|
---|
| 100 | * forget the call.
|
---|
| 101 | *
|
---|
| 102 | * Context: caller
|
---|
| 103 | * Caller alive: guaranteed
|
---|
[cd671c3] | 104 | * Races with: request_process(), answer_cleanup(),
|
---|
| 105 | * _ipc_answer_free_call()
|
---|
[eb5560a] | 106 | * Invoked on: all forgotten calls
|
---|
| 107 | */
|
---|
[466e95f7] | 108 | int (* request_forget)(call_t *);
|
---|
[eb5560a] | 109 |
|
---|
| 110 | /**
|
---|
| 111 | * This callback is called from process_request().
|
---|
| 112 | *
|
---|
| 113 | * Context: callee
|
---|
| 114 | * Caller alive: no guarantee
|
---|
| 115 | * Races with: request_forget()
|
---|
[716185d] | 116 | * Invoked on: all calls delivered to the callee
|
---|
[eb5560a] | 117 | */
|
---|
[f0defd2] | 118 | int (* request_process)(call_t *, answerbox_t *);
|
---|
[eb5560a] | 119 |
|
---|
| 120 | /**
|
---|
| 121 | * This callback is called when answer_preprocess() loses the race to
|
---|
| 122 | * answer the call.
|
---|
| 123 | *
|
---|
| 124 | * Context: callee
|
---|
| 125 | * Caller alive: no guarantee
|
---|
| 126 | * Races with: request_forget()
|
---|
| 127 | * Invoked on: all forgotten calls
|
---|
| 128 | */
|
---|
[466e95f7] | 129 | int (* answer_cleanup)(call_t *, ipc_data_t *);
|
---|
[eb5560a] | 130 |
|
---|
| 131 | /**
|
---|
| 132 | * This callback is called when answer_preprocess() wins the race to
|
---|
| 133 | * answer the call.
|
---|
| 134 | *
|
---|
| 135 | * Context: callee
|
---|
| 136 | * Caller alive: guaranteed
|
---|
| 137 | * Races with: N/A
|
---|
| 138 | * Invoked on: all answered calls
|
---|
| 139 | */
|
---|
[f0defd2] | 140 | int (* answer_preprocess)(call_t *, ipc_data_t *);
|
---|
[eb5560a] | 141 |
|
---|
| 142 | /**
|
---|
| 143 | * This callback is called from process_answer().
|
---|
| 144 | *
|
---|
| 145 | * Context: caller
|
---|
| 146 | * Caller alive: guaranteed
|
---|
| 147 | * Races with: N/A
|
---|
[716185d] | 148 | * Invoked on: all answered calls
|
---|
[eb5560a] | 149 | */
|
---|
[f0defd2] | 150 | int (* answer_process)(call_t *);
|
---|
| 151 | } sysipc_ops_t;
|
---|
| 152 |
|
---|
| 153 | extern sysipc_ops_t *sysipc_ops_get(sysarg_t);
|
---|
| 154 |
|
---|
| 155 | extern int null_request_preprocess(call_t *, phone_t *);
|
---|
[466e95f7] | 156 | extern int null_request_forget(call_t *);
|
---|
[f0defd2] | 157 | extern int null_request_process(call_t *, answerbox_t *);
|
---|
[466e95f7] | 158 | extern int null_answer_cleanup(call_t *, ipc_data_t *);
|
---|
[f0defd2] | 159 | extern int null_answer_preprocess(call_t *, ipc_data_t *);
|
---|
| 160 | extern int null_answer_process(call_t *);
|
---|
| 161 |
|
---|
| 162 | #endif
|
---|
| 163 |
|
---|
| 164 | /** @}
|
---|
| 165 | */
|
---|