2 * FreeBSD amd64 register structures
4 * Copyright (c) 2015 Stacey Son
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef TARGET_ARCH_REG_H
22 #define TARGET_ARCH_REG_H
24 /* See sys/amd64/include/reg.h */
25 typedef struct target_reg
{
54 typedef struct target_fpreg
{
56 uint8_t fpr_acc
[8][16];
57 uint8_t fpr_xacc
[16][16];
58 uint64_t fpr_spare
[12];
61 static inline void target_copy_regs(target_reg_t
*regs
, const CPUX86State
*env
)
64 regs
->r_r15
= env
->regs
[15];
65 regs
->r_r14
= env
->regs
[14];
66 regs
->r_r13
= env
->regs
[13];
67 regs
->r_r12
= env
->regs
[12];
68 regs
->r_r11
= env
->regs
[11];
69 regs
->r_r10
= env
->regs
[10];
70 regs
->r_r9
= env
->regs
[9];
71 regs
->r_r8
= env
->regs
[8];
72 regs
->r_rdi
= env
->regs
[R_EDI
];
73 regs
->r_rsi
= env
->regs
[R_ESI
];
74 regs
->r_rbp
= env
->regs
[R_EBP
];
75 regs
->r_rbx
= env
->regs
[R_EBX
];
76 regs
->r_rdx
= env
->regs
[R_EDX
];
77 regs
->r_rcx
= env
->regs
[R_ECX
];
78 regs
->r_rax
= env
->regs
[R_EAX
];
79 /* regs->r_trapno = env->regs[R_TRAPNO]; XXX */
80 regs
->r_fs
= env
->segs
[R_FS
].selector
& 0xffff;
81 regs
->r_gs
= env
->segs
[R_GS
].selector
& 0xffff;
82 regs
->r_err
= env
->error_code
; /* XXX ? */
83 regs
->r_es
= env
->segs
[R_ES
].selector
& 0xffff;
84 regs
->r_ds
= env
->segs
[R_DS
].selector
& 0xffff;
85 regs
->r_rip
= env
->eip
;
86 regs
->r_cs
= env
->segs
[R_CS
].selector
& 0xffff;
87 regs
->r_rflags
= env
->eflags
;
88 regs
->r_rsp
= env
->regs
[R_ESP
];
89 regs
->r_ss
= env
->segs
[R_SS
].selector
& 0xffff;
92 #endif /* TARGET_ARCH_REG_H */