2 * Copyright 2006 Peter Grehan <grehan@freebsd.org>
3 * Copyright 2005 Orlando Bassotto <orlando@break.net>
4 * Copyright 1998 Sean Eric Fagan
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 /* FreeBSD/powerpc64-specific system call handling. */
33 #include <sys/ptrace.h>
34 #include <sys/syscall.h>
36 #include <machine/reg.h>
37 #include <machine/frame.h>
40 #include <sysdecode.h>
45 powerpc64_fetch_args(struct trussinfo
*trussinfo
, u_int narg
)
47 struct ptrace_io_desc iorequest
;
49 struct current_syscall
*cs
;
53 tid
= trussinfo
->curthread
->tid
;
54 cs
= &trussinfo
->curthread
->cs
;
55 if (ptrace(PT_GETREGS
, tid
, (caddr_t
)®s
, 0) < 0) {
56 fprintf(trussinfo
->outfile
, "-- CANNOT READ REGISTERS --\n");
61 * FreeBSD has two special kinds of system call redirections --
62 * SYS_syscall, and SYS___syscall. The former is the old syscall()
63 * routine, basically; the latter is for quad-aligned arguments.
65 * The system call argument count and code from ptrace() already
66 * account for these, but we need to skip over the first argument.
69 switch (regs
.fixreg
[0]) {
76 for (i
= 0; i
< narg
&& reg
< NARGREG
; i
++, reg
++)
77 cs
->args
[i
] = regs
.fixreg
[FIRSTARG
+ reg
];
79 iorequest
.piod_op
= PIOD_READ_D
;
80 iorequest
.piod_offs
= (void *)(regs
.fixreg
[1] + 48);
81 iorequest
.piod_addr
= &cs
->args
[i
];
82 iorequest
.piod_len
= (narg
- i
) * sizeof(cs
->args
[0]);
83 ptrace(PT_IO
, tid
, (caddr_t
)&iorequest
, 0);
84 if (iorequest
.piod_len
== 0)
92 powerpc64_fetch_retval(struct trussinfo
*trussinfo
, long *retval
, int *errorp
)
97 tid
= trussinfo
->curthread
->tid
;
98 if (ptrace(PT_GETREGS
, tid
, (caddr_t
)®s
, 0) < 0) {
99 fprintf(trussinfo
->outfile
, "-- CANNOT READ REGISTERS --\n");
103 retval
[0] = regs
.fixreg
[3];
104 retval
[1] = regs
.fixreg
[4];
105 *errorp
= !!(regs
.cr
& 0x10000000);
109 static struct procabi powerpc64_freebsd
= {
111 SYSDECODE_ABI_FREEBSD
,
112 powerpc64_fetch_args
,
113 powerpc64_fetch_retval
116 PROCABI(powerpc64_freebsd
);