Added missing properties.
[AROS.git] / arch / all-linux / kernel / cpu_arm.h
blob9be1b5a7a1a25b00ae7fbf10ab91e21f1d5b01be
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Macros to handle unix signals, ARM version
6 Lang: english
7 */
9 #ifndef _SIGCORE_H
10 #define _SIGCORE_H
13 * WARNING! Initial version, highly untested!!!
16 #include <exec/types.h>
17 #include <aros/arm/cpucontext.h>
19 #ifndef __AROS_EXEC_LIBRARY__
22 * This part is included only in host-specific code because it relies
23 * on host includes! __AROS_EXEC_LIBRARY__ definition is used to indicate
24 * host-independent code
27 /* We don't use any hacks any more. With modern kernel and libc it's okay */
28 #define SIGCORE_NEED_SA_SIGINFO 1
30 #include <signal.h>
32 #ifdef HOST_OS_android
35 * Android NDK doesn't have some necessary includes.
36 * Linux kernel is Linux kernel, i hope they won't break binary compatibility,
37 * so it's okay to define this structure here.
39 #include <asm/sigcontext.h>
41 struct ucontext
43 unsigned long uc_flags;
44 struct ucontext *uc_link;
45 stack_t uc_stack;
46 struct sigcontext uc_mcontext;
47 sigset_t uc_sigmask;
48 int reserved[32 - (sizeof (sigset_t) / sizeof (int))];
49 unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
52 #else
53 #include <ucontext.h>
54 #endif
56 /* name and type of the signal handler */
57 #define SIGHANDLER linux_sighandler
58 #define SIGHANDLER_T __sighandler_t
60 #define GLOBAL_SIGNAL_INIT(sighandler) \
61 static void sighandler ## _gate (int sig, siginfo_t *blub, void *u) \
62 { \
63 sighandler(sig, u); \
66 #define SP(uc) (uc->uc_mcontext.arm_sp)
67 #define PC(uc) (uc->uc_mcontext.arm_pc)
69 /* Macros to enable or disable all signals after the signal handler
70 has returned and the normal execution commences. */
71 #define SC_DISABLE(uc) uc->uc_sigmask = KernelBase->kb_PlatformData->sig_int_mask
72 #define SC_ENABLE(uc) SIGEMPTYSET(&uc->uc_sigmask)
75 * Linux kernel does not provide any standarized view of VFP context on signal frame. The ARM linux-hosted
76 * port assumes, that the VFP frame is stored in uc_regspace[] area. This is the case on nearly all linux kernel
77 * compiled with VFP/NEON support. If this is not the case, or of linux misses the VFP frame in sigcontext, AROS
78 * will probably fail.
82 * This macro saves all registers. Use this macro when you want to
83 * leave the current tasks' context. Note that fpuContext area can
84 * be absent, this happens at least in trap handler.
86 #define SAVEREGS(cc, uc) \
87 do { \
88 CopyMemQuick(&uc->uc_mcontext.arm_r0, (cc)->regs.r, sizeof(ULONG) * 17); \
89 if ((cc)->regs.fpuContext) \
90 { \
91 CopyMemQuick(&uc->uc_regspace[0], (cc)->regs.fpuContext, 128*sizeof(ULONG)); \
92 (cc)->regs.Flags |= ECF_FPU; \
93 } \
94 } while(0);
97 * This macro does the opposite to SAVEREGS(). It restores all
98 * registers which are present in the context (depending on its flags).
99 * After that, you can enter the new tasks' context.
101 #define RESTOREREGS(cc, uc) \
102 do { \
103 CopyMemQuick((cc)->regs.r, &uc->uc_mcontext.arm_r0, sizeof(ULONG) * 17); \
104 if ((cc)->regs.Flags & ECF_FPU) \
105 CopyMemQuick((cc)->regs.fpuContext, &uc->uc_regspace[0], 128*sizeof(ULONG)); \
106 } while(0);
108 /* Print signal context. Used in crash handler */
109 #define PRINT_SC(sc) \
110 bug (" R0=%08X R1=%08X R2 =%08X R3 =%08X\n" \
111 " R4=%08X R5=%08X R6 =%08X R7 =%08X\n" \
112 " R8=%08X R9=%08X R10=%08X R11=%08X\n" \
113 " IP=%08X SP=%08X LR =%08X PC =%08X\n" \
114 " CPSR=%08X\n" \
115 , (sc)->uc_mcontext.arm_r0, (sc)->uc_mcontext.arm_r1, (sc)->uc_mcontext.arm_r2, (sc)->uc_mcontext.arm_r3 \
116 , (sc)->uc_mcontext.arm_r4, (sc)->uc_mcontext.arm_r5, (sc)->uc_mcontext.arm_r6, (sc)->uc_mcontext.arm_r7 \
117 , (sc)->uc_mcontext.arm_r8, (sc)->uc_mcontext.arm_r9, (sc)->uc_mcontext.arm_r10, (sc)->uc_mcontext.arm_fp \
118 , (sc)->uc_mcontext.arm_ip, (sc)->uc_mcontext.arm_sp, (sc)->uc_mcontext.arm_lr, (sc)->uc_mcontext.arm_pc \
119 , (sc)->uc_mcontext.arm_cpsr \
122 #endif /* __AROS_EXEC_LIBRARY__ */
124 /* We emulate 6 exceptions of ARM CPU (all but softint) */
125 #define EXCEPTIONS_COUNT 6
127 typedef struct ucontext regs_t;
129 /* This structure is used to save/restore registers */
130 struct AROSCPUContext
132 struct ExceptionContext regs; /* Public portion */
133 int errno_backup; /* Host-specific magic follows */
137 * ARM FPU context under Linux is currently private.
138 * So we set type to FPU_NONE (so that noone tries to mess with it).
140 #define ARM_FPU_TYPE FPU_NONE
141 #define ARM_FPU_SIZE (128*sizeof(ULONG))
143 #endif /* _SIGCORE_H */