Minor fixes to comments.
[AROS.git] / rom / kernel / kernel_intr.c
blob3501aa2b6f57ed7974849da56c1b70c926ee9fff
1 /*
2 Copyright © 2011, 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>
19 * Leave the interrupt. This function receives the interrupt register frame
20 * and runs task scheduler if needed.
22 * You should call it only if you're returning to user mode (i.e. not from
23 * within nested interrupt).
25 * It relies on CPU-specific cpu_Switch() and cpu_Dispatch() implementations
26 * which save and restore CPU context. cpu_Dispatch() is allowed just to
27 * jump to the saved context and not return here.
29 void core_ExitInterrupt(regs_t *regs)
31 /* Soft interrupt requested? It's high time to do it */
32 if (SysBase->SysFlags & SFF_SoftInt)
33 core_Cause(INTB_SOFTINT, 1L << INTB_SOFTINT);
35 /* If task switching is disabled, do nothing */
36 if (SysBase->TDNestCnt < 0)
39 * Do not disturb task if it's not necessary.
40 * Reschedule only if switch pending flag is set. Exit otherwise.
42 if (SysBase->AttnResched & ARF_AttnSwitch)
44 /* Run task scheduling sequence */
45 if (core_Schedule())
47 cpu_Switch(regs);
48 cpu_Dispatch(regs);
55 * This routine dispatches scheduler's SysCall, when some task wants to give up
56 * the CPU time explicitly.
57 * Similar to above, it should be called only when you're returning to user mode.
59 void core_SysCall(int sc, regs_t *regs)
61 switch (sc)
63 case SC_CAUSE:
64 core_ExitInterrupt(regs);
65 break;
67 case SC_SCHEDULE:
68 if (!core_Schedule())
69 break;
70 /* Fallthrough */
72 case SC_SWITCH:
73 cpu_Switch(regs);
74 /* Fallthrough */
76 case SC_DISPATCH:
77 cpu_Dispatch(regs);
78 break;