162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2003 PathScale, Inc.
362306a36Sopenharmony_ci * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Licensed under the GPL
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef __SYSDEP_X86_64_PTRACE_H
962306a36Sopenharmony_ci#define __SYSDEP_X86_64_PTRACE_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#define MAX_FP_NR HOST_FP_SIZE
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define REGS_R8(r) ((r)[HOST_R8])
1462306a36Sopenharmony_ci#define REGS_R9(r) ((r)[HOST_R9])
1562306a36Sopenharmony_ci#define REGS_R10(r) ((r)[HOST_R10])
1662306a36Sopenharmony_ci#define REGS_R11(r) ((r)[HOST_R11])
1762306a36Sopenharmony_ci#define REGS_R12(r) ((r)[HOST_R12])
1862306a36Sopenharmony_ci#define REGS_R13(r) ((r)[HOST_R13])
1962306a36Sopenharmony_ci#define REGS_R14(r) ((r)[HOST_R14])
2062306a36Sopenharmony_ci#define REGS_R15(r) ((r)[HOST_R15])
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define HOST_FS_BASE 21
2362306a36Sopenharmony_ci#define HOST_GS_BASE 22
2462306a36Sopenharmony_ci#define HOST_DS 23
2562306a36Sopenharmony_ci#define HOST_ES 24
2662306a36Sopenharmony_ci#define HOST_FS 25
2762306a36Sopenharmony_ci#define HOST_GS 26
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* Also defined in asm/ptrace-x86_64.h, but not in libc headers.  So, these
3062306a36Sopenharmony_ci * are already defined for kernel code, but not for userspace code.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci#ifndef FS_BASE
3362306a36Sopenharmony_ci/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
3462306a36Sopenharmony_ci * which is what x86_64 ptrace actually uses.
3562306a36Sopenharmony_ci */
3662306a36Sopenharmony_ci#define FS_BASE (HOST_FS_BASE * sizeof(long))
3762306a36Sopenharmony_ci#define GS_BASE (HOST_GS_BASE * sizeof(long))
3862306a36Sopenharmony_ci#define DS (HOST_DS * sizeof(long))
3962306a36Sopenharmony_ci#define ES (HOST_ES * sizeof(long))
4062306a36Sopenharmony_ci#define FS (HOST_FS * sizeof(long))
4162306a36Sopenharmony_ci#define GS (HOST_GS * sizeof(long))
4262306a36Sopenharmony_ci#endif
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define UPT_R8(r) REGS_R8((r)->gp)
4562306a36Sopenharmony_ci#define UPT_R9(r) REGS_R9((r)->gp)
4662306a36Sopenharmony_ci#define UPT_R10(r) REGS_R10((r)->gp)
4762306a36Sopenharmony_ci#define UPT_R11(r) REGS_R11((r)->gp)
4862306a36Sopenharmony_ci#define UPT_R12(r) REGS_R12((r)->gp)
4962306a36Sopenharmony_ci#define UPT_R13(r) REGS_R13((r)->gp)
5062306a36Sopenharmony_ci#define UPT_R14(r) REGS_R14((r)->gp)
5162306a36Sopenharmony_ci#define UPT_R15(r) REGS_R15((r)->gp)
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define UPT_SYSCALL_ARG1(r) UPT_DI(r)
5462306a36Sopenharmony_ci#define UPT_SYSCALL_ARG2(r) UPT_SI(r)
5562306a36Sopenharmony_ci#define UPT_SYSCALL_ARG3(r) UPT_DX(r)
5662306a36Sopenharmony_ci#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
5762306a36Sopenharmony_ci#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
5862306a36Sopenharmony_ci#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciextern void arch_init_registers(int pid);
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#endif
63