grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / kernel / kernel_intr.c
blobf142e6b44c288448e41ab7d7bfcf05c3eb72232a
1 /*
2 Copyright © 2011-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: High-level scheduler calling code
6 Lang: English
7 */
9 #include <exec/execbase.h>
10 #include <hardware/intbits.h>
11 #include <proto/exec.h>
13 #include <kernel_base.h>
14 #include <kernel_intr.h>
15 #include <kernel_scheduler.h>
16 #include <kernel_syscall.h>
18 #include "exec_platform.h"
21 * Leave the interrupt. This function receives the interrupt register frame
22 * and runs task scheduler if needed.
24 * You should call it only if you're returning to user mode (i.e. not from
25 * within nested interrupt).
27 * It relies on CPU-specific cpu_Switch() and cpu_Dispatch() implementations
28 * which save and restore CPU context. cpu_Dispatch() is allowed just to
29 * jump to the saved context and not return here.
31 void core_ExitInterrupt(regs_t *regs)
33 /* Soft interrupt requested? It's high time to do it */
34 if (SysBase->SysFlags & SFF_SoftInt)
35 core_Cause(INTB_SOFTINT, 1L << INTB_SOFTINT);
37 /* If task switching is disabled, do nothing */
38 if (TDNESTCOUNT_GET < 0)
41 * Do not disturb task if it's not necessary.
42 * Reschedule only if switch pending flag is set. Exit otherwise.
44 if (FLAG_SCHEDSWITCH_ISSET)
46 /* Run task scheduling sequence */
47 if (core_Schedule())
49 cpu_Switch(regs);
50 cpu_Dispatch(regs);
57 * This routine dispatches scheduler's SysCall, when some task wants to give up
58 * the CPU time explicitly.
59 * Similar to above, it should be called only when you're returning to user mode.
61 void core_SysCall(int sc, regs_t *regs)
63 switch (sc)
65 case SC_CAUSE:
66 core_ExitInterrupt(regs);
67 break;
69 case SC_SCHEDULE:
70 if (!core_Schedule())
71 break;
72 /* Fallthrough */
74 case SC_SWITCH:
75 cpu_Switch(regs);
76 /* Fallthrough */
78 case SC_DISPATCH:
79 cpu_Dispatch(regs);
80 break;