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