source: trunk/source/lisp-kernel/arm-exceptions.h

Last change on this file was 16760, checked in by gb, 3 years ago

kinder, gentler pc_luser_xp(): always back out of allocation if the
interrupted thread is at or before the alloc trap, else finish it.
when installing the handler for thread_suspend_signal, explicitly
unblock SIGILL to avoid race conditions.

File size: 5.7 KB
Line 
1/*
2 * Copyright 2010 Clozure Associates
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#define UUO_MASK 0x0ff000f0
17
18#define IS_UUO(i) (((i) & UUO_MASK) == 0x07f000f0)
19/* If an instruction is a UUO its format is determined by the low 4 bits */
20#define UUO_FORMAT(i) ((i)&0xf)
21
22#define UUO_UNARY_field(uuo) (((uuo)>>12)&0xff)
23#define UUOA_field(uuo)      (((uuo)>>8) &0x0f)
24
25#define uuo_format_nullary          0 /* 12 bits of code */
26#define uuo_format_unary            1 /* 8 bits of info - NOT type info - 4-bit reg */
27#define uuo_format_error_lisptag    2 /* 2 bits of lisptag info, 4-bit reg */
28#define uuo_format_error_fulltag    3 /* 3 bits of fulltag info, 4 bit reg */
29
30#define uuo_format_error_xtype      4 /* 8 bits of extended type/subtag info, 4 bit reg */
31#define uuo_format_ternary2         5 /* r0,r1,r2 */
32#define uuo_format_binary           7 /* 4 bits of code, r1, r0 */
33#define uuo_format_nullary_error    8 /* nullary, call out to lisp */
34#define uuo_format_unary_error      9 /* like unary, but call out to lisp */
35#define uuo_format_cerror_lisptag  10 /* continuable, lisptag, reg */
36#define uuo_format_cerror_fulltag  11 /* continuable, fulltag, reg */
37#define uuo_format_cerror_xtype    12 /* continuable, xtype, reg */ 
38#define uuo_format_kernel_service  13 /* 8 bits of info */     
39#define uuo_format_ternary         14 /* slot-unbound only */
40#define uuo_format_binary_error    15 /* binary format, call out to lisp */
41
42
43
44
45typedef u_int32_t opcode, *pc;
46/*
47bad idea
48#define TCR_FLAG_BIT_PC_LUSERED (fixnumshift+9)
49*/
50
51Boolean
52handle_uuo(ExceptionInformation *, siginfo_t *, opcode);
53
54
55
56int
57callback_for_trap (LispObj, ExceptionInformation *, natural, natural, int*);
58
59natural
60register_codevector_contains_pc (natural, pc);
61
62int
63callback_to_lisp (LispObj, ExceptionInformation *, natural, natural, int*);
64
65OSStatus
66handle_trap(ExceptionInformation *, opcode, pc, siginfo_t *);
67
68
69/* */
70
71#define RN_field(i) (((i)>>16)&0xf)
72#define RD_field(i) (((i)>>12)&0xf)
73#define RM_field(i) ((i)&0xf)
74
75#define IS_SUB_RM_FROM_ALLOCPTR(i)   (((i)&0x0ffff000) == 0x004cc000)
76#define IS_SUB_FROM_ALLOCPTR(i)      (((i)&0x0ffff000) == 0x024cc000)
77#define IS_SUB_LO_FROM_ALLOCPTR(i)   (((i)&0x0fffff00) == 0x024cc000)
78#define IS_SUB_HI_FROM_ALLOCPTR(i)   (IS_SUB_FROM_ALLOCPTR(i) && \
79                                     !(IS_SUB_LO_FROM_ALLOCPTR(i)))
80#define IS_LOAD_RD_FROM_ALLOCBASE(i) (((i)&0x0fff0fff) == \
81                                      ( 0x05930000 | offsetof(TCR,save_allocbase)))
82#define IS_COMPARE_ALLOCPTR_TO_RM(i) (((i)&0x0fff0ff0) == 0x015c0000)
83#define IS_ALLOC_TRAP(i) (((i)&0x0fffffff) == 0x07f000f0)
84#define IS_SET_ALLOCPTR_HEADER_RD(i) (((i)&0x0fff0fff) == \
85                                      (0x050c0000 | (- misc_header_offset)))
86/* The 5 here - and the 1 in the following definition - are based on
87   the tagged offsets of cars and cdrs.  Fix these definitions if that ever
88   changes ... */
89#define IS_SET_ALLOCPTR_CDR_RD(i)    (((i)&0x0fff0fff) == 0x050c0005)
90#define IS_SET_ALLOCPTR_CAR_RD(i)    (((i)&0x0fff0fff) == 0x050c0001)
91#define IS_SET_ALLOCPTR_RESULT_RD(i) (((i)&0x0fff0fff) == 0x01a0000c)
92#define IS_CLR_ALLOCPTR_TAG(i)       (((i)&0x0fffffff) == 0x03ccc007)
93#define IS_BRANCH_AROUND_ALLOC_TRAP(i) (((i)&0x0fffffff) == 0x0a000000)
94
95typedef enum {
96  ID_unrecognized_alloc_instruction,
97  ID_adjust_allocptr_instruction,
98  ID_load_allocbase_instruction,
99  ID_compare_allocptr_to_allocbase_instruction,
100  ID_branch_around_alloc_trap_instruction,
101  ID_alloc_trap_instruction,
102  ID_finish_allocation
103} alloc_instruction_id;
104
105
106#define IS_GC_TRAP(i)                (((i)&0x0fffffff) == 0x07f002f0)
107#define IS_DEBUG_TRAP(i)             (((i)&0x0fffffff) == 0x07f003f0)
108#define IS_DEFERRED_INTERRUPT(i)     (((i)&0x0fffffff) == 0x07f004f0)
109#define IS_DEFERRED_SUSPEND(i)       (((i)&0x0fffffff) == 0x07f005f0)
110
111#define PSEUDO_SIGRETURN_UUO         (0xe7fffef1)
112
113OSStatus
114handle_error(ExceptionInformation *, unsigned, unsigned, int*);
115
116typedef char* vector_buf;
117
118void put_altivec_registers(vector_buf);
119void get_altivec_registers(vector_buf);
120
121
122int altivec_available;
123
124
125
126
127#ifdef DARWIN
128#define SIGNAL_FOR_PROCESS_INTERRUPT SIGUSR1
129#endif
130#ifdef LINUX
131#define SIGNAL_FOR_PROCESS_INTERRUPT SIGPWR
132#endif
133
134
135
136Boolean
137extend_tcr_tlb(TCR *, ExceptionInformation *,  unsigned);
138
139void 
140pc_luser_xp(ExceptionInformation *, TCR *, signed_natural *);
141
142#define codevec_hdr_p(value) ((value) == 0)
143
144#ifdef __GNUC__
145static __inline__ natural
146ror(natural val, natural count) __attribute__((always_inline));
147
148static __inline__ natural
149ror(natural val,natural count)
150{
151  natural result;
152  __asm__ __volatile__("ror %[result],%[val],%[count]"
153                       :[result] "=r" (result)
154                       :[val] "r" (val),
155                        [count] "r" (count));
156  return result;
157}
158#else
159extern natural ror(natural, natural);
160#endif
161
162#ifdef DARWIN
163#undef USE_SIGALTSTACK
164#else
165#define USE_SIGALTSTACK 1
166#endif
167
168#ifdef USE_SIGALTSTACK
169void
170invoke_handler_on_main_stack(int, siginfo_t*, ExceptionInformation *, void *, void*);
171#endif
172
173#ifdef USE_SIGALTSTACK
174#define ALTSTACK(handler) altstack_ ## handler
175#else
176#define ALTSTACK(handler) handler
177#endif
178
179void
180normalize_tcr(ExceptionInformation *,TCR *, Boolean);
181
182void
183install_signal_handler(int, void*, unsigned);
Note: See TracBrowser for help on using the repository browser.