expose peripheral iobase via getsystemattr for drivers to use. clean-up iobase code...
[AROS.git] / arch / arm-raspi / kernel / kernel_cpu.c
blobf070e26adb77ff38735250eca6ba3dbb84388f66
1 /*
2 Copyright © 2013-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
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>
19 #include "etask.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"
28 #define D(x)
29 #define DREGS(x)
31 extern struct Task *sysIdleTask;
33 void cpu_Switch(regs_t *regs)
35 struct Task *task;
37 D(bug("[Kernel] cpu_Switch()\n"));
39 task = SysBase->ThisTask;
41 /* Copy current task's context into the ETask structure */
42 /* Restore the task's state */
43 STORE_TASKSTATE(task, regs)
45 /* Update the taks CPU time .. */
46 GetIntETask(task)->iet_CpuTime += *((volatile unsigned int *)(SYSTIMER_CLO)) - GetIntETask(task)->iet_private1;
48 core_Switch();
51 void cpu_Dispatch(regs_t *regs)
53 struct Task *task;
55 D(bug("[Kernel] cpu_Dispatch()\n"));
57 /* Break Disable() if needed */
58 if (SysBase->IDNestCnt >= 0) {
59 SysBase->IDNestCnt = -1;
60 ((uint32_t *)regs)[13] &= ~0x80;
63 if (!(task = core_Dispatch()))
64 task = sysIdleTask;
66 D(bug("[Kernel] cpu_Dispatch: Letting '%s' run for a bit..\n", task->tc_Node.ln_Name));
68 /* Restore the task's state */
69 RESTORE_TASKSTATE(task, regs)
71 DREGS(cpu_DumpRegs(regs));
73 /* Handle tasks's flags */
74 if (task->tc_Flags & TF_EXCEPT)
75 Exception();
77 /* Store the launch time */
78 GetIntETask(task)->iet_private1 = *((volatile unsigned int *)(SYSTIMER_CLO));
80 if (task->tc_Flags & TF_LAUNCH)
82 AROS_UFC1(void, task->tc_Launch,
83 AROS_UFCA(struct ExecBase *, SysBase, A6));
87 void cpu_DumpRegs(regs_t *regs)
89 int i;
91 bug("[KRN] Register Dump:\n");
92 for (i = 0; i < 12; i++)
94 bug("[KRN] r%02d: 0x%08x\n", i, ((uint32_t *)regs)[i]);
96 bug("[KRN] (ip) r12: 0x%08x\n", ((uint32_t *)regs)[12]);
97 bug("[KRN] (sp) r13: 0x%08x\n", ((uint32_t *)regs)[13]);
98 bug("[KRN] (lr) r14: 0x%08x\n", ((uint32_t *)regs)[14]);
99 bug("[KRN] (pc) r15: 0x%08x\n", ((uint32_t *)regs)[15]);
100 bug("[KRN] cpsr: 0x%08x\n", ((uint32_t *)regs)[16]);