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 dt_set_root(void * r
);
31 void *dt_find_node_by_phandle(uint32_t phandle
);
32 void *dt_find_node(char *key
);
33 void *dt_find_property(void *key
, char *propname
);
34 int dt_get_prop_len(void *prop
);
35 void *dt_get_prop_value(void *prop
);
37 void cpu_Probe(struct ARM_Implementation
*);
38 void cpu_Init(struct ARM_Implementation
*, struct TagItem
*);
40 void platform_Init(struct ARM_Implementation
*, struct TagItem
*);
42 void core_SetupMMU(struct TagItem
*msg
);
43 void core_SetupIntr(void);
45 void *KrnAddSysTimerHandler(struct KernelBase
*);
47 intptr_t krnGetTagData(Tag tagValue
, intptr_t defaultVal
, const struct TagItem
*tagList
);
48 struct TagItem
*krnFindTagItem(Tag tagValue
, const struct TagItem
*tagList
);
49 struct TagItem
*krnNextTagItem(const struct TagItem
**tagListPtr
);
51 struct KernelBase
*getKernelBase();
68 #define STR(x) __STR(x)
71 AROS_LDA(const char *, format
, A0
),
72 AROS_LDA(va_list, args
, A1
),
73 struct KernelBase
*, KernelBase
, 12, Kernel
);
75 static inline void bug(const char *format
, ...)
77 struct KernelBase
*kbase
= getKernelBase();
79 va_start(args
, format
);
80 AROS_SLIB_ENTRY(KrnBug
, Kernel
, 12)(format
, args
, kbase
);
84 #define VECTCOMMON_START \
85 " srsfd sp!, #0x13 \n" \
86 " cpsid i, #0x13 \n" \
87 " sub sp, sp, #2*4 \n" \
88 " stmfd sp!, {r0-r12} \n" \
89 " sub r0, sp, #4 \n" \
90 " strex r1, r2, [r0] \n" \
92 " ldr ip, [r0, #16*4] \n" \
93 " and ip, ip, #0x1f \n" \
95 " cmpne ip, #0x1f \n" \
96 " addeq r1, r0, #13*4 \n" \
97 " stmeq r1, {sp, lr}^ \n" \
98 " strne lr, [r0, #14*4] \n"
100 #define VECTCOMMON_END \
101 " sub r0, sp, #4 \n" \
102 " strex r1, r2, [r0] \n" \
103 " ldr ip, [sp, #16*4] \n" \
104 " and ip, ip, #0x1f \n" \
105 " cmp ip, #0x10 \n" \
106 " cmpne ip, #0x1f \n" \
107 " addeq r1, sp, #13*4 \n" \
108 " ldmeq r1, {sp, lr}^ \n" \
109 " ldrne lr, [sp, #14*4] \n" \
110 " ldmfd sp!, {r0-r12} \n" \
111 " add sp, sp, #2*4 \n" \
114 #define STORE_TASKSTATE(task, regs) \
115 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
117 for (__task_reg_no = 0; __task_reg_no < 12; __task_reg_no++) \
119 ctx->r[__task_reg_no] = ((uint32_t *)regs)[__task_reg_no]; \
121 ctx->ip = ((uint32_t *)regs)[12]; \
122 ctx->sp = ((uint32_t *)regs)[13]; \
123 task->tc_SPReg = (void *)ctx->sp; \
124 ctx->lr = ((uint32_t *)regs)[14]; \
125 ctx->pc = ((uint32_t *)regs)[15]; \
126 ctx->cpsr = ((uint32_t *)regs)[16]; \
127 if (__arm_arosintern.ARMI_Save_VFP_State) __arm_arosintern.ARMI_Save_VFP_State(ctx->fpuContext);
129 #define RESTORE_TASKSTATE(task, regs) \
130 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
132 for (__task_reg_no = 0; __task_reg_no < 12; __task_reg_no++) \
134 ((uint32_t *)regs)[__task_reg_no] = ctx->r[__task_reg_no]; \
136 ((uint32_t *)regs)[12] = ctx->ip; \
137 ctx->sp = (intptr_t)task->tc_SPReg; \
138 ((uint32_t *)regs)[13] = ctx->sp; \
139 ((uint32_t *)regs)[14] = ctx->lr; \
140 ((uint32_t *)regs)[15] = ctx->pc; \
141 ((uint32_t *)regs)[16] = ctx->cpsr; \
142 if (__arm_arosintern.ARMI_Restore_VFP_State) __arm_arosintern.ARMI_Restore_VFP_State(ctx->fpuContext);
144 #endif /*KERNEL_INTERN_H_*/