1/*
2 * Copyright 2016, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(D61_GPL)
11 */
12#ifndef __OBJECT_REPLY_H
13#define __OBJECT_REPLY_H
14
15#include <types.h>
16#include <api/failures.h>
17#include <object/structures.h>
18
19/* Unlink a reply from its tcb */
20static inline void reply_unlink(reply_t *reply)
21{
22    /* check the tcb and reply are linked correctly */
23    assert(thread_state_get_replyObject(reply->replyTCB->tcbState) == REPLY_REF(reply));
24
25    tcb_t *tcb = reply->replyTCB;
26    thread_state_ptr_set_replyObject(&tcb->tcbState, REPLY_REF(0));
27    reply->replyTCB = NULL;
28    setThreadState(tcb, ThreadState_Inactive);
29}
30
31/* Push a reply object onto the call stack */
32void reply_push(tcb_t *tcb_caller, tcb_t *tcb_callee, reply_t *reply, bool_t canDonate);
33/* Pop the head reply from the call stack */
34void reply_pop(reply_t *reply);
35/* Remove a reply from the call stack - replyTCB must be in ThreadState_BlockedOnReply */
36void reply_remove(reply_t *reply);
37/* Remove a specific tcb, and the reply it is blocking on, from the call stack */
38void reply_remove_tcb(tcb_t *tcb);
39
40#endif /* __OBJECT_REPLY_H */
41