1 /* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 #pragma once 7 8 #include <types.h> 9 #include <api/failures.h> 10 #include <object/structures.h> 11 12 exception_t decodeSchedContextInvocation(word_t label, cap_t cap, word_t *buffer); 13 14 /* Bind a tcb and a scheduling context. This allows a tcb to enter the scheduler. 15 * If the tcb is runnable, insert into scheduler 16 * 17 * @param sc the scheduling context to bind 18 * @param tcb the tcb to bind 19 * 20 * @pre the scheduling context must not already be bound to a tcb, 21 * tcb->tcbSchedContext == NULL && sc->scTcb == NULL 22 * @post tcb->tcbSchedContext == sc && sc->scTcb == tcb 23 */ 24 void schedContext_bindTCB(sched_context_t *sc, tcb_t *tcb); 25 26 /* Unbind a specific tcb from a scheduling context. If the tcb is runnable, 27 * remove from the scheduler. 28 * 29 * @param sc scheduling context to unbind 30 * @param tcb the tcb to unbind 31 * 32 * @pre the tcb is bound to the sc, 33 * (sc->scTcb == tcb && tcb->tcbSchedContext == sc); 34 * @post (tcb->tcbSchedContext == NULL && sc->scTcb == NULL) 35 */ 36 void schedContext_unbindTCB(sched_context_t *sc, tcb_t *tcb); 37 38 /* 39 * Unbind any tcb from a scheduling context. If the tcb bound to the scheduling 40 * context is runnable, remove from the scheduler. 41 * 42 * @param sc the scheduling context to unbind 43 * @post (sc->scTcb == NULL) 44 */ 45 void schedContext_unbindAllTCBs(sched_context_t *sc); 46 47 /* 48 * Resume a scheduling context. This will check if a the tcb bound to the scheduling context 49 * is runnable, if so, it will then check if the budget is due to be recharged and do so. 50 * If the scheduling context has insufficient budget the bound tcb is placed in the release queue. 51 * 52 * @pre (sc != NULL) 53 */ 54 void schedContext_resume(sched_context_t *sc); 55 56 /* 57 * Donate sc to tcb. 58 * 59 * @pre (sc != NULL && tcb != NULL) 60 * @post (sc->scTcb == tcb && tcb->tcbSchedContext == sc) 61 */ 62 void schedContext_donate(sched_context_t *sc, tcb_t *to); 63 64 /* Bind scheduling context to a notification */ 65 void schedContext_bindNtfn(sched_context_t *sc, notification_t *ntfn); 66 /* unbind scheduling context from a notification */ 67 void schedContext_unbindNtfn(sched_context_t *sc); 68 69 time_t schedContext_updateConsumed(sched_context_t *sc); 70 void schedContext_completeYieldTo(tcb_t *yielder); 71 void schedContext_cancelYieldTo(tcb_t *yielder); 72 73