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 #define KERNEL_PHYS_BASE 0x07800000
24 #define KERNEL_VIRT_BASE 0xff800000
26 #define VFPEnable (1 << 30)
27 #define VFPSingle (3 << 20)
28 #define VFPDouble (3 << 22)
30 void cpu_Probe(struct ARM_Implementation
*);
31 void cpu_Init(struct ARM_Implementation
*, struct TagItem
*);
33 void platform_Init(struct ARM_Implementation
*, struct TagItem
*);
35 void core_SetupMMU(struct TagItem
*msg
);
36 void core_SetupIntr(void);
38 void *KrnAddSysTimerHandler(struct KernelBase
*);
40 intptr_t krnGetTagData(Tag tagValue
, intptr_t defaultVal
, const struct TagItem
*tagList
);
41 struct TagItem
*krnFindTagItem(Tag tagValue
, const struct TagItem
*tagList
);
42 struct TagItem
*krnNextTagItem(const struct TagItem
**tagListPtr
);
44 struct KernelBase
*getKernelBase();
61 #define STR(x) __STR(x)
64 AROS_LDA(const char *, format
, A0
),
65 AROS_LDA(va_list, args
, A1
),
66 struct KernelBase
*, KernelBase
, 12, Kernel
);
68 static inline void bug(const char *format
, ...)
70 struct KernelBase
*kbase
= getKernelBase();
72 va_start(args
, format
);
73 AROS_SLIB_ENTRY(KrnBug
, Kernel
, 12)(format
, args
, kbase
);
77 #define VECTCOMMON_START \
78 " srsfd sp!, #0x13 \n" \
79 " cpsid i, #0x13 \n" \
80 " sub sp, sp, #2*4 \n" \
81 " stmfd sp!, {r0-r12} \n" \
82 " sub r0, sp, #4 \n" \
83 " strex r1, r2, [r0] \n" \
85 " ldr ip, [r0, #16*4] \n" \
86 " and ip, ip, #0x1f \n" \
88 " cmpne ip, #0x1f \n" \
89 " addeq r1, r0, #13*4 \n" \
90 " stmeq r1, {sp, lr}^ \n" \
91 " strne lr, [r0, #14*4] \n"
93 #define VECTCOMMON_END \
94 " sub r0, sp, #4 \n" \
95 " strex r1, r2, [r0] \n" \
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]; \
119 if (__arm_arosintern.ARMI_Save_VFP_State) __arm_arosintern.ARMI_Save_VFP_State(ctx->fpuContext);
121 #define RESTORE_TASKSTATE(task, regs) \
122 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
124 for (__task_reg_no = 0; __task_reg_no < 12; __task_reg_no++) \
126 ((uint32_t *)regs)[__task_reg_no] = ctx->r[__task_reg_no]; \
128 ((uint32_t *)regs)[12] = ctx->ip; \
129 ((uint32_t *)regs)[13] = ctx->sp = task->tc_SPReg; \
130 ((uint32_t *)regs)[14] = ctx->lr; \
131 ((uint32_t *)regs)[15] = ctx->pc; \
132 ((uint32_t *)regs)[16] = ctx->cpsr; \
133 if (__arm_arosintern.ARMI_Restore_VFP_State) __arm_arosintern.ARMI_Restore_VFP_State(ctx->fpuContext);
135 #endif /*KERNEL_INTERN_H_*/