source: release/1.7/source/lisp-kernel/arm-exceptions.h @ 15267

Last change on this file since 15267 was 14807, checked in by gb, 8 years ago

Define and export the functions ALLOW-HEAP-ALLOCATION and
HEAP-ALLOCATION-ALLOWED-P and the condition type ALLOCATION-DISABLED.

(ALLOW-HEAP-ALLOCATION arg) : when ARG is NIL, causes any subsequent
attempts to heap-allocate lisp memory to signal (as if by CERROR)
an ALLOCATION-DISABLED condition. (Allocaton is enabled globally at
the point where the error is signaled.) Continuing from the CERROR
restarts the allocation attempt.

This is intended to help verify that code that's not expected to
cons doesn't do so.

(This is only implemented on the ARM at the moment, but the intent
is that it be supported on all platforms.)

Note that calling (ALLOW-HEAP-ALLOCATION NIL) in the REPL CERRORs
immediately, since the REPL will cons to create the new value of CL:/.

File size: 5.4 KB
Line 
1/*
2   Copyright (C) 2010 Clozure Associates
3   This file is part of Clozure CL. 
4
5   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with Clozure CL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with Clozure CL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   Clozure CL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
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_binary           7 /* 4 bits of code, r1, r0 */
32#define uuo_format_nullary_error    8 /* nullary, call out to lisp */
33#define uuo_format_unary_error      9 /* like unary, but call out to lisp */
34#define uuo_format_cerror_lisptag  10 /* continuable, lisptag, reg */
35#define uuo_format_cerror_fulltag  11 /* continuable, fulltag, reg */
36#define uuo_format_cerror_xtype    12 /* continuable, xtype, reg */ 
37#define uuo_format_kernel_service  13 /* 8 bits of info */     
38#define uuo_format_ternary         14 /* slot-unbound only */
39#define uuo_format_binary_error    15 /* binary format, call out to lisp */
40
41
42
43
44typedef u_int32_t opcode, *pc;
45
46Boolean
47handle_uuo(ExceptionInformation *, siginfo_t *, opcode);
48
49
50
51int
52callback_for_trap (LispObj, ExceptionInformation *, natural, natural, int*);
53
54natural
55register_codevector_contains_pc (natural, pc);
56
57int
58callback_to_lisp (LispObj, ExceptionInformation *, natural, natural, int*);
59
60OSStatus
61handle_trap(ExceptionInformation *, opcode, pc, siginfo_t *);
62
63
64/* */
65
66#define RN_field(i) (((i)>>16)&0xf)
67#define RD_field(i) (((i)>>12)&0xf)
68#define RM_field(i) ((i)&0xf)
69
70#define IS_SUB_RM_FROM_ALLOCPTR(i)   (((i)&0x0ffff000) == 0x004cc000)
71#define IS_SUB_FROM_ALLOCPTR(i)      (((i)&0x0ffff000) == 0x024cc000)
72#define IS_SUB_LO_FROM_ALLOCPTR(i)   (((i)&0x0fffff00) == 0x024cc000)
73#define IS_SUB_HI_FROM_ALLOCPTR(i)   (IS_SUB_FROM_ALLOCPTR(i) && \
74                                     !(IS_SUB_LO_FROM_ALLOCPTR(i)))
75#define IS_LOAD_RD_FROM_ALLOCBASE(i) (((i)&0x0fff0fff) == \
76                                      ( 0x05930000 | offsetof(TCR,save_allocbase)))
77#define IS_COMPARE_ALLOCPTR_TO_RM(i) (((i)&0x0fff0ff0) == 0x015c0000)
78#define IS_ALLOC_TRAP(i) (((i)&0x0fffffff) == 0x07f000f0)
79#define IS_SET_ALLOCPTR_HEADER_RD(i) (((i)&0x0fff0fff) == \
80                                      (0x050c0000 | (- misc_header_offset)))
81/* The 5 here - and the 1 in the following definition - are based on
82   the tagged offsets of cars and cdrs.  Fix these definitions if that ever
83   changes ... */
84#define IS_SET_ALLOCPTR_CDR_RD(i)    (((i)&0x0fff0fff) == 0x050c0005)
85#define IS_SET_ALLOCPTR_CAR_RD(i)    (((i)&0x0fff0fff) == 0x050c0001)
86#define IS_SET_ALLOCPTR_RESULT_RD(i) (((i)&0x0fff0fff) == 0x01a0000c)
87#define IS_CLR_ALLOCPTR_TAG(i)       (((i)&0x0fffffff) == 0x03ccc007)
88#define IS_BRANCH_AROUND_ALLOC_TRAP(i) (((i)&0x0fffffff) == 0x0a000000)
89
90
91#define IS_GC_TRAP(i)                (((i)&0x0fffffff) == 0x07f002f0)
92#define IS_DEBUG_TRAP(i)             (((i)&0x0fffffff) == 0x07f003f0)
93#define IS_DEFERRED_INTERRUPT(i)     (((i)&0x0fffffff) == 0x07f004f0)
94#define IS_DEFERRED_SUSPEND(i)       (((i)&0x0fffffff) == 0x07f005f0)
95
96#define PSEUDO_SIGRETURN_UUO         (0xe7fffef1)
97
98OSStatus
99handle_error(ExceptionInformation *, unsigned, unsigned, int*);
100
101typedef char* vector_buf;
102
103void put_altivec_registers(vector_buf);
104void get_altivec_registers(vector_buf);
105
106
107int altivec_available;
108
109#ifdef DARWIN
110#include <mach/mach.h>
111#include <mach/mach_error.h>
112#include <mach/machine/thread_state.h>
113#include <mach/machine/thread_status.h>
114
115#endif
116
117
118
119#ifdef DARWIN
120#define SIGNAL_FOR_PROCESS_INTERRUPT SIGUSR1
121#endif
122#ifdef LINUX
123#define SIGNAL_FOR_PROCESS_INTERRUPT SIGPWR
124#endif
125
126
127
128Boolean
129extend_tcr_tlb(TCR *, ExceptionInformation *,  unsigned);
130
131void 
132pc_luser_xp(ExceptionInformation *, TCR *, signed_natural *);
133
134#define codevec_hdr_p(value) ((value) == 0)
135
136#ifdef __GNUC__
137static __inline__ natural
138ror(natural val, natural count) __attribute__((always_inline));
139
140static __inline__ natural
141ror(natural val,natural count)
142{
143  natural result;
144  __asm__ __volatile__("ror %[result],%[val],%[count]"
145                       :[result] "=r" (result)
146                       :[val] "r" (val),
147                        [count] "r" (count));
148  return result;
149}
150#else
151extern natural ror(natural, natural);
152#endif
153
154#ifdef DARWIN
155#undef USE_SIGALTSTACK
156#else
157#define USE_SIGALTSTACK 1
158#endif
159
160#ifdef USE_SIGALTSTACK
161void
162invoke_handler_on_main_stack(int, siginfo_t*, ExceptionInformation *, void *, void*);
163#endif
164
165#ifdef USE_SIGALTSTACK
166#define ALTSTACK(handler) altstack_ ## handler
167#else
168#define ALTSTACK(handler) handler
169#endif
170
171void
172normalize_tcr(ExceptionInformation *,TCR *, Boolean);
Note: See TracBrowser for help on using the repository browser.