2 Copyright � 1995-2014, The AROS Development Team. All rights reserved.
7 * This file is intended to make generic kernel.resource compiling.
8 * This code should NEVER be executed. This file MUST be overriden in
9 * architecture-specific code for the scheduler to work!
12 #include <aros/kernel.h>
13 #include <aros/libcall.h>
14 #include <exec/execbase.h>
15 #include <hardware/intbits.h>
17 #include <proto/kernel.h>
21 #include "kernel_intern.h"
22 #include "kernel_debug.h"
23 #include "kernel_cpu.h"
24 #include "kernel_syscall.h"
25 #include "kernel_scheduler.h"
26 #include "kernel_intr.h"
32 extern uint32_t __arm_periiobase
;
33 #define ARM_PERIIOBASE (__arm_periiobase)
35 extern struct Task
*sysIdleTask
;
37 void cpu_Switch(regs_t
*regs
)
41 D(bug("[Kernel] cpu_Switch()\n"));
43 task
= SysBase
->ThisTask
;
45 /* Copy current task's context into the ETask structure */
46 /* Restore the task's state */
47 STORE_TASKSTATE(task
, regs
)
49 /* Update the taks CPU time .. */
50 GetIntETask(task
)->iet_CpuTime
+= *((volatile unsigned int *)(SYSTIMER_CLO
)) - GetIntETask(task
)->iet_private1
;
55 void cpu_Dispatch(regs_t
*regs
)
59 D(bug("[Kernel] cpu_Dispatch()\n"));
61 /* Break Disable() if needed */
62 if (SysBase
->IDNestCnt
>= 0) {
63 SysBase
->IDNestCnt
= -1;
64 ((uint32_t *)regs
)[13] &= ~0x80;
67 if (!(task
= core_Dispatch()))
70 D(bug("[Kernel] cpu_Dispatch: Letting '%s' run for a bit..\n", task
->tc_Node
.ln_Name
));
72 /* Restore the task's state */
73 RESTORE_TASKSTATE(task
, regs
)
75 DREGS(cpu_DumpRegs(regs
));
77 /* Handle tasks's flags */
78 if (task
->tc_Flags
& TF_EXCEPT
)
81 /* Store the launch time */
82 GetIntETask(task
)->iet_private1
= *((volatile unsigned int *)(SYSTIMER_CLO
));
84 if (task
->tc_Flags
& TF_LAUNCH
)
86 AROS_UFC1(void, task
->tc_Launch
,
87 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));
91 void cpu_DumpRegs(regs_t
*regs
)
95 bug("[KRN] Register Dump:\n");
96 for (i
= 0; i
< 12; i
++)
98 bug("[KRN] r%02d: 0x%08x\n", i
, ((uint32_t *)regs
)[i
]);
100 bug("[KRN] (ip) r12: 0x%08x\n", ((uint32_t *)regs
)[12]);
101 bug("[KRN] (sp) r13: 0x%08x\n", ((uint32_t *)regs
)[13]);
102 bug("[KRN] (lr) r14: 0x%08x\n", ((uint32_t *)regs
)[14]);
103 bug("[KRN] (pc) r15: 0x%08x\n", ((uint32_t *)regs
)[15]);
104 bug("[KRN] cpsr: 0x%08x\n", ((uint32_t *)regs
)[16]);