2 * Sparc register context support
4 * Copyright (C) 2000 Ulrich Weigand
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include <sys/types.h>
33 #ifdef HAVE_SYS_PTRACE_H
34 # include <sys/ptrace.h>
43 #if 0 /* no longer used */
45 #if defined(__sun) || defined(__sun__)
47 /* retrieve a thread context */
48 static void get_thread_context_ptrace( struct thread
*thread
, unsigned int flags
, CONTEXT
*context
)
50 int pid
= get_ptrace_pid(thread
);
51 if (flags
& CONTEXT_FULL
)
54 if (ptrace( PTRACE_GETREGS
, pid
, 0, (int) ®s
) == -1) goto error
;
55 if (flags
& CONTEXT_INTEGER
)
58 context
->g1
= regs
.r_g1
;
59 context
->g2
= regs
.r_g2
;
60 context
->g3
= regs
.r_g3
;
61 context
->g4
= regs
.r_g4
;
62 context
->g5
= regs
.r_g5
;
63 context
->g6
= regs
.r_g6
;
64 context
->g7
= regs
.r_g7
;
66 context
->o0
= regs
.r_o0
;
67 context
->o1
= regs
.r_o1
;
68 context
->o2
= regs
.r_o2
;
69 context
->o3
= regs
.r_o3
;
70 context
->o4
= regs
.r_o4
;
71 context
->o5
= regs
.r_o5
;
72 context
->o6
= regs
.r_o6
;
73 context
->o7
= regs
.r_o7
;
75 /* FIXME: local and in registers */
77 if (flags
& CONTEXT_CONTROL
)
79 context
->psr
= regs
.r_psr
;
80 context
->pc
= regs
.r_pc
;
81 context
->npc
= regs
.r_npc
;
82 context
->y
= regs
.r_y
;
83 context
->wim
= 0; /* FIXME */
84 context
->tbr
= 0; /* FIXME */
86 context
|= flags
& (CONTEXT_CONTROL
|CONTEXT_INTEGER
);
88 if (flags
& CONTEXT_FLOATING_POINT
)
98 /* set a thread context */
99 static void set_thread_context_ptrace( struct thread
*thread
, unsigned int flags
, const CONTEXT
*context
)
105 #error You must implement get/set_thread_context_ptrace for your platform
110 /* copy a context structure according to the flags */
111 void copy_context( CONTEXT
*to
, const CONTEXT
*from
, unsigned int flags
)
113 flags
&= ~CONTEXT_SPARC
; /* get rid of CPU id */
114 if (flags
& CONTEXT_CONTROL
)
123 if (flags
& CONTEXT_INTEGER
)
158 if (flags
& CONTEXT_FLOATING_POINT
)
162 context
|= flags
& (CONTEXT_CONTROL
|CONTEXT_INTEGER
);
165 /* retrieve the current instruction pointer of a context */
166 client_ptr_t
get_context_ip( const CONTEXT
*context
)
171 /* return the context flag that contains the CPU id */
172 unsigned int get_context_cpu_flag(void)
174 return CONTEXT_SPARC
;
177 /* return only the context flags that correspond to system regs */
178 /* (system regs are the ones we can't access on the client side) */
179 unsigned int get_context_system_regs( unsigned int flags
)
181 return 0; /* FIXME: implement client-side handling */
184 #endif /* __sparc__ */