source: trunk/ccl/lisp-kernel/x86-exceptions.h @ 5996

Last change on this file since 5996 was 5996, checked in by gb, 13 years ago

Darwin signal return: logior in the el-bizarro syscall mask, pass the
magic number 0x1e as a second arg, just in case.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/*
2   Copyright (C) 2005 Clozure Associates
3   This file is part of OpenMCL. 
4
5   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with OpenMCL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with OpenMCL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   OpenMCL 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
17typedef u8_t opcode, *pc;
18
19#ifdef LINUX
20#ifdef X8664
21#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext.gregs)))
22#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
23#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
24#define xpPC(x) (xpGPR(x,Iip))
25#define xpMMXreg(x,n)  *((natural *)(&((x)->uc_mcontext.fpregs->_st[n])))
26#endif
27#endif
28
29#ifdef DARWIN
30#define DARWIN_USE_PSEUDO_SIGRETURN 1
31#include <sys/syscall.h>
32#define DarwinSigReturn(context) syscall(0x2000000|SYS_sigreturn,context,0x1e)
33#ifdef X8664
34#define xpGPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__ss.__rax)))
35#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
36#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
37#define xpPC(x) (xpGPR(x,Iip))
38#define xpFPRvector(x) ((natural *)(&(UC_MCONTEXT(x)->__fs.__fpu_stmm0)))
39#define xpMMXreg(x,n)  (xpFPRvector(x)[gprno])
40#endif
41#include <mach/mach.h>
42#include <mach/mach_error.h>
43#include <mach/machine/thread_state.h>
44#include <mach/machine/thread_status.h>
45
46pthread_mutex_t *mach_exception_lock;
47
48#endif
49
50#ifdef FREEBSD
51#ifdef X8664
52#include <machine/fpu.h>
53#define xpGPRvector(x) ((natural *)(&((x)->uc_mcontext)))
54#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
55#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
56#define xpPC(x) xpGPR(x,Iip)
57#define xpMMXreg(x,n) *((natural *)(&(((struct savefpu *)(&(x)->uc_mcontext.mc_fpstate))->sv_fp[n])))
58#endif
59#endif
60
61#ifdef SOLARIS
62#ifdef X8664
63#define xpGPRvector(x) ((x)->uc_mcontext.gregs)
64#define xpGPR(x,gprno) (xpGPRvector(x)[gprno])
65#define set_xpGPR(x,gpr,new) xpGPR((x),(gpr)) = (natural)(new)
66#define xpPC(x) xpGPR(x,Iip)
67#define xpMMXreg(x,n)  *((natural *)(&(x)->uc_mcontext.fpregs.fp_reg_set.fpchip_state.st[n]))
68#endif
69#endif
70
71
72#ifdef DARWIN
73#define SIGNAL_FOR_PROCESS_INTERRUPT SIGEMT
74#endif
75#ifdef LINUX
76#define SIGNAL_FOR_PROCESS_INTERRUPT SIGPWR
77#endif
78#ifdef FREEBSD
79#define SIGNAL_FOR_PROCESS_INTERRUPT SIGEMT
80#endif
81#ifdef SOLARIS
82#define SIGNAL_FOR_PROCESS_INTERRUPT SIGEMT
83#endif
84
85#ifdef USE_SIGALTSTACK
86void setup_sigaltstack(area *);
87void switch_to_foreign_stack(void*, ...);
88#endif
89
90#define INTN_OPCODE 0xcd
91
92#define UUO_GC_TRAP    0xc4
93#define UUO_ALLOC_TRAP 0xc5
94#define UUO_DEBUG_TRAP 0xca
95#define UUO_DEBUG_TRAP_WITH_STRING 0xcd
96
97#define XUUO_OPCODE_0 0x0f
98#define XUUO_OPCODE_1 0x0b
99
100#define XUUO_TLB_TOO_SMALL 1
101#define XUUO_INTERRUPT_NOW 2
102
103void
104pc_luser_xp(ExceptionInformation*, TCR*, signed_natural*);
105
106
107typedef enum {
108  ID_unrecognized_alloc_instruction,
109  ID_load_allocptr_reg_from_tcr_save_allocptr_instruction,
110  ID_compare_allocptr_reg_to_tcr_save_allocbase_instruction,
111  ID_branch_around_alloc_trap_instruction,
112  ID_alloc_trap_instruction,
113  ID_set_allocptr_header_instruction,
114  ID_clear_tcr_save_allocptr_tag_instruction
115} alloc_instruction_id;
116
117#ifdef LINUX
118#define SIGNUM_FOR_INTN_TRAP SIGSEGV
119#define IS_MAYBE_INT_TRAP(info,xp) (((info->si_code) &0x7f) == 0)
120#define SIGRETURN(context)
121#endif
122
123#ifdef FREEBSD
124extern void freebsd_sigreturn(ExceptionInformation *);
125#define SIGNUM_FOR_INTN_TRAP SIGBUS
126#define IS_MAYBE_INT_TRAP(info,xp) (xp->uc_mcontext.mc_trapno == T_PROTFLT)
127#define SIGRETURN(context) freebsd_sigreturn(context)
128#endif
129
130#ifdef DARWIN
131#define SIGNUM_FOR_INTN_TRAP SIGSEGV /* Not really, but our Mach handler fakes that */
132#define IS_MAYBE_INT_TRAP(info,xp) (info->si_code == EXC_I386_GPFLT)
133/* The x86 version of sigreturn just needs the context argument; the
134   hidden, magic "flavor" argument that sigtramp uses is ignored. */
135#define SIGRETURN(context) DarwinSigReturn(context)
136#endif
137
138/* Please go away. */
139#ifdef DARWIN_GS_HACK
140extern Boolean ensure_gs_pthread(void);
141extern void set_gs_address(void *);
142#endif
Note: See TracBrowser for help on using the repository browser.