revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-native / kernel / kernel_intern.h
blob9d67df6be3f11a45c647d0bdb6465ef61f023ce3
1 /*
2 Copyright © 2013-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef KERNEL_INTERN_H_
7 #define KERNEL_INTERN_H_
9 #include <aros/libcall.h>
10 #include <inttypes.h>
11 #include <exec/lists.h>
12 #include <exec/execbase.h>
13 #include <exec/memory.h>
14 #include <utility/tagitem.h>
15 #include <stdio.h>
16 #include <stdarg.h>
18 #include "kernel_arm.h"
20 #undef KernelBase
21 struct KernelBase;
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();
53 #ifdef bug
54 #undef bug
55 #endif
56 #ifdef D
57 #undef D
58 #endif
59 #if DEBUG
60 #define D(x) x
61 #define DALLOCMEM(x)
62 #else
63 #define D(x)
64 #define DALLOCMEM(x)
65 #endif
67 #define __STR(x) #x
68 #define STR(x) __STR(x)
70 AROS_LD2(int, KrnBug,
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();
78 va_list args;
79 va_start(args, format);
80 AROS_SLIB_ENTRY(KrnBug, Kernel, 12)(format, args, kbase);
81 va_end(args);
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" \
91 " mov r0, sp \n" \
92 " ldr ip, [r0, #16*4] \n" \
93 " and ip, ip, #0x1f \n" \
94 " cmp ip, #0x10 \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" \
112 " rfefd sp! \n"
114 #define STORE_TASKSTATE(task, regs) \
115 struct ExceptionContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; \
116 int __task_reg_no; \
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; \
131 int __task_reg_no; \
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_*/