Removed autodocs of arch specific variants of ROM modules.
[AROS.git] / arch / all-linux / kernel / cpu_ppc.h
blob85a2123d77b4666e93fef296754c966c53a19625
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Macros to handle unix signals, PPC version
6 Lang: english
7 */
9 #ifndef _SIGCORE_H
10 #define _SIGCORE_H
12 #include <exec/types.h>
13 #include <aros/ppc/cpucontext.h>
15 #ifdef __AROS_EXEC_LIBRARY__
17 struct ucontext;
19 #else
21 /* We don't use any hacks any more. With modern kernel and libc it's okay */
22 #define SIGCORE_NEED_SA_SIGINFO 1
24 #include <ucontext.h>
25 #include <signal.h>
27 #ifndef _SIGNAL_H
28 #define _SIGNAL_H
29 #endif
30 #ifndef __KERNEL_STRICT_NAMES
31 #define __KERNEL_STRICT_NAMES
32 #endif
33 #include <bits/sigcontext.h>
35 /* name and type of the signal handler */
36 #define SIGHANDLER linux_sighandler
37 #define SIGHANDLER_T __sighandler_t
39 #define GLOBAL_SIGNAL_INIT(sighandler) \
40 static void sighandler ## _gate (int sig, siginfo_t *blub, void *u) \
41 { \
42 sighandler(sig, u); \
45 /* Macros to access the stack pointer and program counter,
46 PC is the current address in the program code. */
48 #define SP(uc) (uc->uc_mcontext.regs->gpr[1])
49 #define PC(uc) (uc->uc_mcontext.regs->nip)
51 /* Macros to enable or disable all signals after the signal handler
52 has returned and the normal execution commences.
53 On PowerPC this is the same as on x86-64. */
54 #define SC_DISABLE(uc) uc->uc_sigmask = KernelBase->kb_PlatformData->sig_int_mask
55 #define SC_ENABLE(uc) pd->iface->SigEmptySet(&uc->uc_sigmask)
58 * This macro saves all registers. Use this macro when you want
59 * to leave the current tasks' context.
60 * It saves as much is possible and sets appropriate flags in
61 * context structure.
62 * TODO: check if Traptype usage is correct.
64 #define SAVEREGS(cc, uc) \
65 do \
66 { \
67 long i; \
68 (cc)->regs.Flags = ECF_FULL_GPRS|ECF_FPU; \
69 for (i = 0; i < 32; i++) \
70 (cc)->regs.gpr[i] = uc->uc_mcontext.regs->gpr[i]; \
71 (cc)->regs.ip = uc->uc_mcontext.regs->nip; \
72 (cc)->regs.msr = uc->uc_mcontext.regs->msr; \
73 (cc)->regs.ctr = uc->uc_mcontext.regs->ctr; \
74 (cc)->regs.lr = uc->uc_mcontext.regs->link; \
75 (cc)->regs.xer = uc->uc_mcontext.regs->xer; \
76 (cc)->regs.cr = uc->uc_mcontext.regs->ccr; \
77 (cc)->regs.Traptype = uc->uc_mcontext.regs->trap; \
78 (cc)->regs.dar = uc->uc_mcontext.regs->dar; \
79 (cc)->regs.dsisr = uc->uc_mcontext.regs->dsisr; \
80 (cc)->orig_gpr3 = uc->uc_mcontext.regs->orig_gpr3; \
81 (cc)->result = uc->uc_mcontext.regs->result; \
82 for (i = 0; i < 32; i++) \
83 (cc)->regs.fpr[i] = *(double*)&(uc->uc_mcontext.regs->gpr[PT_FPR0 + 2 * i]); \
84 } while(0)
87 * This macro does the opposite to SAVEREGS(). It restores all
88 * registers which are present in context (indicated by its flags).
89 * After that, you can enter the new task's context.
91 #define RESTOREREGS(cc, uc) \
92 do \
93 { \
94 long i; \
95 long n = ((cc)->regs.Flags & ECF_FULL_GPRS) ? 32 : 14; \
96 for (i = 0; i < n; i++) \
97 uc->uc_mcontext.regs->gpr[i] = (cc)->regs.gpr[i]; \
98 uc->uc_mcontext.regs->nip = (cc)->regs.ip; \
99 uc->uc_mcontext.regs->msr = (cc)->regs.msr; \
100 uc->uc_mcontext.regs->ctr = (cc)->regs.ctr; \
101 uc->uc_mcontext.regs->link = (cc)->regs.lr; \
102 uc->uc_mcontext.regs->xer = (cc)->regs.xer; \
103 uc->uc_mcontext.regs->ccr = (cc)->regs.cr; \
104 uc->uc_mcontext.regs->trap = (cc)->regs.Traptype; \
105 uc->uc_mcontext.regs->dar = (cc)->regs.dar; \
106 uc->uc_mcontext.regs->dsisr = (cc)->regs.dsisr; \
107 uc->uc_mcontext.regs->orig_gpr3 = (cc)->orig_gpr3; \
108 uc->uc_mcontext.regs->result = (cc)->result; \
109 if ((cc)->regs.Flags & ECF_FPU) \
111 for (i = 0; i < 32; i++) \
112 *(double*)&(uc->uc_mcontext.regs->gpr[PT_FPR0 + 2 * i]) = (cc)->regs.fpr[i]; \
114 } while(0)
116 /* This macro prints the current signals' context */
118 #define PRINT_SC(sc) \
119 bug ("SC: SP=%08lx PC=%08lx\n" \
120 , SP(sc), PC(sc) \
123 #endif /* __AROS_EXEC_LIBRARY__ */
126 * We support 14 exceptions for PPC (see arch/all-unix/kernel/cpu_ppc.c).
127 * Note that krnRunExceptionHandlers() does not check exception number,
128 * so increase this if you use higher numbers.
130 #define EXCEPTIONS_COUNT 14
132 typedef struct ucontext regs_t;
134 /* This structure is used to save/restore registers */
135 struct AROSCPUContext
137 struct ExceptionContext regs; /* Public portion */
138 unsigned long orig_gpr3; /* Host-specific magic */
139 unsigned long result;
140 int errno_backup;
143 #endif /* _SIGCORE_H */