Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _ARCH_H |
| 7 | #define _ARCH_H |
| 8 | |
| 9 | #include <stdbool.h> |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 10 | #include <linux/list.h> |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 11 | #include "elf.h" |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 12 | #include "cfi.h" |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 13 | |
Josh Poimboeuf | 9fe7b76 | 2019-07-17 20:36:56 -0500 | [diff] [blame] | 14 | enum insn_type { |
| 15 | INSN_JUMP_CONDITIONAL, |
| 16 | INSN_JUMP_UNCONDITIONAL, |
| 17 | INSN_JUMP_DYNAMIC, |
Josh Poimboeuf | b68b990 | 2019-07-17 20:36:57 -0500 | [diff] [blame] | 18 | INSN_JUMP_DYNAMIC_CONDITIONAL, |
Josh Poimboeuf | 9fe7b76 | 2019-07-17 20:36:56 -0500 | [diff] [blame] | 19 | INSN_CALL, |
| 20 | INSN_CALL_DYNAMIC, |
| 21 | INSN_RETURN, |
| 22 | INSN_CONTEXT_SWITCH, |
| 23 | INSN_STACK, |
| 24 | INSN_BUG, |
| 25 | INSN_NOP, |
| 26 | INSN_STAC, |
| 27 | INSN_CLAC, |
| 28 | INSN_STD, |
| 29 | INSN_CLD, |
| 30 | INSN_OTHER, |
| 31 | }; |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 32 | |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 33 | enum op_dest_type { |
| 34 | OP_DEST_REG, |
| 35 | OP_DEST_REG_INDIRECT, |
| 36 | OP_DEST_MEM, |
| 37 | OP_DEST_PUSH, |
Peter Zijlstra | ea24213 | 2019-02-25 12:50:09 +0100 | [diff] [blame] | 38 | OP_DEST_PUSHF, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 39 | OP_DEST_LEAVE, |
| 40 | }; |
| 41 | |
| 42 | struct op_dest { |
| 43 | enum op_dest_type type; |
| 44 | unsigned char reg; |
| 45 | int offset; |
| 46 | }; |
| 47 | |
| 48 | enum op_src_type { |
| 49 | OP_SRC_REG, |
| 50 | OP_SRC_REG_INDIRECT, |
| 51 | OP_SRC_CONST, |
| 52 | OP_SRC_POP, |
Peter Zijlstra | ea24213 | 2019-02-25 12:50:09 +0100 | [diff] [blame] | 53 | OP_SRC_POPF, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 54 | OP_SRC_ADD, |
| 55 | OP_SRC_AND, |
| 56 | }; |
| 57 | |
| 58 | struct op_src { |
| 59 | enum op_src_type type; |
| 60 | unsigned char reg; |
| 61 | int offset; |
| 62 | }; |
| 63 | |
| 64 | struct stack_op { |
| 65 | struct op_dest dest; |
| 66 | struct op_src src; |
| 67 | }; |
| 68 | |
| 69 | void arch_initial_func_cfi_state(struct cfi_state *state); |
| 70 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 71 | int arch_decode_instruction(struct elf *elf, struct section *sec, |
| 72 | unsigned long offset, unsigned int maxlen, |
Josh Poimboeuf | 9fe7b76 | 2019-07-17 20:36:56 -0500 | [diff] [blame] | 73 | unsigned int *len, enum insn_type *type, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 74 | unsigned long *immediate, struct stack_op *op); |
| 75 | |
| 76 | bool arch_callee_saved_reg(unsigned char reg); |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 77 | |
| 78 | #endif /* _ARCH_H */ |