2 Copyright © 2013-2015, The AROS Development Team. All rights reserved.
6 #ifndef KERNEL_INTERN_H_
7 #define KERNEL_INTERN_H_
9 #include <aros/libcall.h>
11 #include <exec/lists.h>
12 #include <exec/execbase.h>
13 #include <exec/memory.h>
14 #include <utility/tagitem.h>
18 #include "kernel_arm.h"
23 /* Use system timer 3 for our scheduling heartbeat */
24 #define VBLANK_TIMER 3
25 #define VBLANK_INTERVAL (1000000 / 50)
27 #define KERNEL_PHYS_BASE 0x07800000
28 #define KERNEL_VIRT_BASE 0xff800000
30 #define VFPEnable (1 << 30)
31 #define VFPSingle (3 << 20)
32 #define VFPDouble (3 << 22)
34 void cpu_Probe(struct ARM_Implementation
*);
35 void cpu_Init(struct ARM_Implementation
*, struct TagItem
*);
37 void platform_Init(struct ARM_Implementation
*, struct TagItem
*);
39 void core_SetupMMU(struct TagItem
*msg
);
40 void core_SetupIntr(void);
42 void *KrnAddSysTimerHandler(struct KernelBase
*);
44 intptr_t krnGetTagData(Tag tagValue
, intptr_t defaultVal
, const struct TagItem
*tagList
);
45 struct TagItem
*krnFindTagItem(Tag tagValue
, const struct TagItem
*tagList
);
46 struct TagItem
*krnNextTagItem(const struct TagItem
**tagListPtr
);
48 struct KernelBase
*getKernelBase();
65 #define STR(x) __STR(x)
68 AROS_LDA(const char *, format
, A0
),
69 AROS_LDA(va_list, args
, A1
),
70 struct KernelBase
*, KernelBase
, 12, Kernel
);
72 static inline void bug(const char *format
, ...)
74 struct KernelBase
*kbase
= getKernelBase();
76 va_start(args
, format
);
77 AROS_SLIB_ENTRY(KrnBug
, Kernel
, 12)(format
, args
, kbase
);
81 #define VECTCOMMON_START \
82 " srsfd sp!, #0x13 \n" \
83 " cpsid i, #0x13 \n" \
84 " sub sp, sp, #2*4 \n" \
85 " stmfd sp!, {r0-r12} \n" \
87 " ldr ip, [r0, #16*4] \n" \
88 " and ip, ip, #0x1f \n" \
90 " cmpne ip, #0x1f \n" \
91 " addeq r1, r0, #13*4 \n" \
92 " stmeq r1, {sp, lr}^ \n" \
93 " strne lr, [r0, #14*4] \n"
95 #define VECTCOMMON_END \
96 " ldr ip, [sp, #16*4] \n" \
97 " and ip, ip, #0x1f \n" \
99 " cmpne ip, #0x1f \n" \
100 " addeq r1, sp, #13*4 \n" \
101 " ldmeq r1, {sp, lr}^ \n" \
102 " ldrne lr, [sp, #14*4] \n" \
103 " ldmfd sp!, {r0-r12} \n" \
104 " add sp, sp, #2*4 \n" \
107 #define STORE_TASKSTATE(task, regs) \
108 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
110 for (__task_reg_no = 0; __task_reg_no < 12; __task_reg_no++) \
112 ctx->r[__task_reg_no] = ((uint32_t *)regs)[__task_reg_no]; \
114 ctx->ip = ((uint32_t *)regs)[12]; \
115 ctx->sp = task->tc_SPReg = ((uint32_t *)regs)[13]; \
116 ctx->lr = ((uint32_t *)regs)[14]; \
117 ctx->pc = ((uint32_t *)regs)[15]; \
118 ctx->cpsr = ((uint32_t *)regs)[16];
120 #define RESTORE_TASKSTATE(task, regs) \
121 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
123 for (__task_reg_no = 0; __task_reg_no < 12; __task_reg_no++) \
125 ((uint32_t *)regs)[__task_reg_no] = ctx->r[__task_reg_no]; \
127 ((uint32_t *)regs)[12] = ctx->ip; \
128 ((uint32_t *)regs)[13] = ctx->sp = task->tc_SPReg; \
129 ((uint32_t *)regs)[14] = ctx->lr; \
130 ((uint32_t *)regs)[15] = ctx->pc; \
131 ((uint32_t *)regs)[16] = ctx->cpsr;
133 #endif /*KERNEL_INTERN_H_*/