1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
7 * Asm Implementation File *
9 * Copyright (C) 2011-2015, Free Software Foundation, Inc. *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
22 * In particular, you can freely distribute your programs built with the *
23 * GNAT Pro compiler, including any required library run-time units, using *
24 * any licensing terms of your choosing. See the AdaCore Software License *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 ****************************************************************************/
32 /********************************************************
33 * VxWorks VXSIM version of the __gnat_sigtramp service *
34 ********************************************************/
37 #define CPU __VXSIM_CPU__
40 /* See sigtramp.h for a general explanation of functionality. */
43 #include <arch/../regs.h>
50 typedef struct mcontext
55 typedef struct ucontext
57 mcontext_t uc_mcontext
; /* register set */
58 struct ucontext
* uc_link
; /* not used */
59 sigset_t uc_sigmask
; /* set of signals blocked */
60 stack_t uc_stack
; /* stack of context signaled */
64 /* ----------------------
65 -- General comments --
66 ----------------------
68 Stubs are generated from toplevel asms and .cfi directives, much simpler
69 to use and check for correctness than manual encodings of CFI byte
70 sequences. The general idea is to establish CFA as sigcontext->sc_pregs
71 (for DKM) and mcontext (for RTP) and state where to find the registers as
74 As of today, we support a stub providing CFI info for common
75 registers (GPRs, LR, ...). We might need variants with support for floating
76 point or altivec registers as well at some point.
78 Checking which variant should apply and getting at sc_pregs / mcontext
79 is simpler to express in C (we can't use offsetof in toplevel asms and
80 hardcoding constants is not workable with the flurry of VxWorks variants),
81 so this is the choice for our toplevel interface.
83 Note that the registers we "restore" here are those to which we have
84 direct access through the system sigcontext structure, which includes
85 only a partial set of the non-volatiles ABI-wise. */
87 /* -------------------------------------------
88 -- Prototypes for our internal asm stubs --
89 -------------------------------------------
91 Eventhough our symbols will remain local, the prototype claims "extern"
92 and not "static" to prevent compiler complaints about a symbol used but
95 /* sigtramp stub providing CFI info for common registers. */
97 extern void __gnat_sigtramp_vxsim_common
98 (int signo
, void *siginfo
, void *sigcontext
,
99 __sigtramphandler_t
* handler
, void * sc_pregs
);
102 /* -------------------------------------
103 -- Common interface implementation --
104 -------------------------------------
106 We enforce optimization to minimize the overhead of the extra layer. */
108 void __gnat_sigtramp_vxsim (int signo
, void *si
, void *sc
,
109 __sigtramphandler_t
* handler
)
110 __attribute__((optimize(2)));
112 void __gnat_sigtramp_vxsim (int signo
, void *si
, void *sc
,
113 __sigtramphandler_t
* handler
)
116 mcontext_t
*mcontext
= &((ucontext_t
*) sc
)->uc_mcontext
;
118 /* Pass MCONTEXT in the fifth position so that the assembly code can find
119 it at the same stack location or in the same register as SC_PREGS. */
120 __gnat_sigtramp_vxsim_common (signo
, si
, mcontext
, handler
, mcontext
);
122 struct sigcontext
* sctx
= (struct sigcontext
*) sc
;
124 __gnat_sigtramp_vxsim_common (signo
, si
, sctx
, handler
, sctx
->sc_pregs
);
128 /* Include the target specific bits. */
129 #include "sigtramp-vxworks-target.inc"
131 /* sigtramp stub for common registers. */
133 #define TRAMP_COMMON __gnat_sigtramp_vxsim_common
135 asm (SIGTRAMP_START(TRAMP_COMMON
));
137 asm (CFI_COMMON_REGS
);
139 asm (SIGTRAMP_END(TRAMP_COMMON
));