1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 // Disable preemption, if it is not already disabled.
6 //
7 // This prevents the current thread being switched. It may also disable
8 // interrupts, but the caller should not rely on this.
9 //
10 // Calls to this function may be nested. Each call must be matched by a
11 // call to preempt_enable().
12 void
13 preempt_disable(void) ACQUIRE_PREEMPT_DISABLED;
14 
15 // Undo the effect of an earlier preempt_disable() call.
16 //
17 // If the matching preempt_disable() call disabled interrupts, then this call
18 // will re-enable them.
19 void
20 preempt_enable(void) RELEASE_PREEMPT_DISABLED;
21 
22 // Handle an interrupt in hypervisor mode.
23 //
24 // This function must be called by the architecture's interrupt handling routine
25 // when an interrupt preempts execution of the hypervisor. It will arrange for
26 // the handling of the interrupt, but note that such handling may not complete
27 // before this function returns.
28 //
29 // If this function returns true, the caller must arrange for interrupts to be
30 // disabled upon return from the current interrupt. This is intended to allow
31 // preempt module implementations to defer handling of an interrupt; e.g. to
32 // allow preempt_disable() to avoid disabling interrupts if the CPU makes that
33 // too slow to do frequently.
34 bool
35 preempt_interrupt_dispatch(void);
36 
37 // Assert that the caller is executing in an interrupt handler, and mark
38 // preemption as disabled for the purpose of static analysis.
39 void
40 preempt_disable_in_irq(void) ACQUIRE_PREEMPT_DISABLED;
41 
42 // Assert that the caller is executing in an interrupt handler, and mark
43 // preemption as enabled for the purpose of static analysis.
44 void
45 preempt_enable_in_irq(void) RELEASE_PREEMPT_DISABLED;
46 
47 // Handle an asynchronous abort in hypervisor mode.
48 //
49 // This function must be called by the architecture's exception or interrupt
50 // handling routine when an asynchronous abort preempts execution of the
51 // hypervisor. It will arrange for handling of the abort.
52 //
53 // The meaning of "asynchronous abort" is architecture-specific and includes,
54 // for example, an AArch64 SError interrupt or an x86 NMI.
55 bool
56 preempt_abort_dispatch(void);
57 
58 // Assert that preemption is currently disabled.
59 //
60 // This calls assert(), so it is effective only if !defined(NDEBUG).
61 void
62 assert_preempt_disabled(void) REQUIRE_PREEMPT_DISABLED;
63 
64 // Assert that preemption is currently enabled.
65 //
66 // This calls assert(), so it is effective only if !defined(NDEBUG).
67 void
68 assert_preempt_enabled(void) EXCLUDE_PREEMPT_DISABLED;
69