| 1 | /* Capstone Disassembly Engine */cxx . . $ `<file>/arch/BPF/BPFConstants.h`/ |
| 2 | /* BPF Backend by david942j <[email protected]>, 2019 */ |
| 3 | |
| 4 | /* This file defines constants and macros used for parsing a BPF instruction */ |
| 5 | |
| 6 | #ifndef CS_BPF_CONSTANTS_H |
| 7 | #define CS_BPF_CONSTANTS_Hcxx . . $ `arch/BPF/BPFConstants.h:7:9`! |
| 8 | |
| 9 | #define BPF_CLASScxx . . $ `arch/BPF/BPFConstants.h:9:9`!(code) ((code) & 0x7) |
| 10 | |
| 11 | ///< Instruction classes |
| 12 | #define BPF_CLASS_LDcxx . . $ `arch/BPF/BPFConstants.h:12:9`! 0x00 |
| 13 | #define BPF_CLASS_LDXcxx . . $ `arch/BPF/BPFConstants.h:13:9`! 0x01 |
| 14 | #define BPF_CLASS_STcxx . . $ `arch/BPF/BPFConstants.h:14:9`! 0x02 |
| 15 | #define BPF_CLASS_STXcxx . . $ `arch/BPF/BPFConstants.h:15:9`! 0x03 |
| 16 | #define BPF_CLASS_ALUcxx . . $ `arch/BPF/BPFConstants.h:16:9`! 0x04 |
| 17 | #define BPF_CLASS_JMPcxx . . $ `arch/BPF/BPFConstants.h:17:9`! 0x05 |
| 18 | #define BPF_CLASS_RETcxx . . $ `arch/BPF/BPFConstants.h:18:9`! 0x06 ///< cBPF only |
| 19 | #define BPF_CLASS_MISCcxx . . $ `arch/BPF/BPFConstants.h:19:9`! 0x07 ///< cBPF only |
| 20 | #define BPF_CLASS_ALU64cxx . . $ `arch/BPF/BPFConstants.h:20:9`! 0x07 ///< eBPF only |
| 21 | |
| 22 | #define BPF_OPcxx . . $ `arch/BPF/BPFConstants.h:22:9`!(code) ((code) & 0xf0) |
| 23 | |
| 24 | ///< Types of ALU instruction |
| 25 | #define BPF_ALU_ADDcxx . . $ `arch/BPF/BPFConstants.h:25:9`! 0x00 |
| 26 | #define BPF_ALU_SUBcxx . . $ `arch/BPF/BPFConstants.h:26:9`! 0x10 |
| 27 | #define BPF_ALU_MULcxx . . $ `arch/BPF/BPFConstants.h:27:9`! 0x20 |
| 28 | #define BPF_ALU_DIVcxx . . $ `arch/BPF/BPFConstants.h:28:9`! 0x30 |
| 29 | #define BPF_ALU_ORcxx . . $ `arch/BPF/BPFConstants.h:29:9`! 0x40 |
| 30 | #define BPF_ALU_ANDcxx . . $ `arch/BPF/BPFConstants.h:30:9`! 0x50 |
| 31 | #define BPF_ALU_LSHcxx . . $ `arch/BPF/BPFConstants.h:31:9`! 0x60 |
| 32 | #define BPF_ALU_RSHcxx . . $ `arch/BPF/BPFConstants.h:32:9`! 0x70 |
| 33 | #define BPF_ALU_NEGcxx . . $ `arch/BPF/BPFConstants.h:33:9`! 0x80 |
| 34 | #define BPF_ALU_MODcxx . . $ `arch/BPF/BPFConstants.h:34:9`! 0x90 |
| 35 | #define BPF_ALU_XORcxx . . $ `arch/BPF/BPFConstants.h:35:9`! 0xa0 |
| 36 | #define BPF_ALU_MOVcxx . . $ `arch/BPF/BPFConstants.h:36:9`! 0xb0 ///< eBPF only: mov reg to reg |
| 37 | #define BPF_ALU_ARSHcxx . . $ `arch/BPF/BPFConstants.h:37:9`! 0xc0 ///< eBPF only: sign extending shift right |
| 38 | #define BPF_ALU_ENDcxx . . $ `arch/BPF/BPFConstants.h:38:9`! 0xd0 ///< eBPF only: endianness conversion |
| 39 | |
| 40 | ///< Types of jmp instruction |
| 41 | #define BPF_JUMP_JAcxx . . $ `arch/BPF/BPFConstants.h:41:9`! 0x00 ///< goto |
| 42 | #define BPF_JUMP_JEQcxx . . $ `arch/BPF/BPFConstants.h:42:9`! 0x10 ///< '==' |
| 43 | #define BPF_JUMP_JGTcxx . . $ `arch/BPF/BPFConstants.h:43:9`! 0x20 ///< unsigned '>' |
| 44 | #define BPF_JUMP_JGEcxx . . $ `arch/BPF/BPFConstants.h:44:9`! 0x30 ///< unsigned '>=' |
| 45 | #define BPF_JUMP_JSETcxx . . $ `arch/BPF/BPFConstants.h:45:9`! 0x40 ///< '&' |
| 46 | #define BPF_JUMP_JNEcxx . . $ `arch/BPF/BPFConstants.h:46:9`! 0x50 ///< eBPF only: '!=' */ |
| 47 | #define BPF_JUMP_JSGTcxx . . $ `arch/BPF/BPFConstants.h:47:9`! 0x60 ///< eBPF only: signed '>' |
| 48 | #define BPF_JUMP_JSGEcxx . . $ `arch/BPF/BPFConstants.h:48:9`! 0x70 ///< eBPF only: signed '>=' |
| 49 | #define BPF_JUMP_CALLcxx . . $ `arch/BPF/BPFConstants.h:49:9`! 0x80 ///< eBPF only: function call |
| 50 | #define BPF_JUMP_EXITcxx . . $ `arch/BPF/BPFConstants.h:50:9`! 0x90 ///< eBPF only: exit |
| 51 | #define BPF_JUMP_JLTcxx . . $ `arch/BPF/BPFConstants.h:51:9`! 0xa0 ///< eBPF only: unsigned '<' |
| 52 | #define BPF_JUMP_JLEcxx . . $ `arch/BPF/BPFConstants.h:52:9`! 0xb0 ///< eBPF only: unsigned '<=' |
| 53 | #define BPF_JUMP_JSLTcxx . . $ `arch/BPF/BPFConstants.h:53:9`! 0xc0 ///< eBPF only: signed '<' |
| 54 | #define BPF_JUMP_JSLEcxx . . $ `arch/BPF/BPFConstants.h:54:9`! 0xd0 ///< eBPF only: signed '<=' |
| 55 | |
| 56 | #define BPF_SRCcxx . . $ `arch/BPF/BPFConstants.h:56:9`!(code) ((code) & 0x08) |
| 57 | #define BPF_RVALcxx . . $ `arch/BPF/BPFConstants.h:57:9`!(code) ((code) & 0x18) /* cBPF only: for return types */ |
| 58 | ///< Source operand |
| 59 | #define BPF_SRC_Kcxx . . $ `arch/BPF/BPFConstants.h:59:9`! 0x00 |
| 60 | #define BPF_SRC_Xcxx . . $ `arch/BPF/BPFConstants.h:60:9`! 0x08 |
| 61 | #define BPF_SRC_Acxx . . $ `arch/BPF/BPFConstants.h:61:9`! 0x10 /* cBPF only */ |
| 62 | |
| 63 | #define BPF_SRC_LITTLEcxx . . $ `arch/BPF/BPFConstants.h:63:9`! BPF_SRC_K |
| 64 | #define BPF_SRC_BIGcxx . . $ `arch/BPF/BPFConstants.h:64:9`! BPF_SRC_X |
| 65 | |
| 66 | #define BPF_SIZEcxx . . $ `arch/BPF/BPFConstants.h:66:9`!(code) ((code) & 0x18) |
| 67 | ///< Size modifier |
| 68 | #define BPF_SIZE_Wcxx . . $ `arch/BPF/BPFConstants.h:68:9`! 0x00 ///< word |
| 69 | #define BPF_SIZE_Hcxx . . $ `arch/BPF/BPFConstants.h:69:9`! 0x08 ///< half word |
| 70 | #define BPF_SIZE_Bcxx . . $ `arch/BPF/BPFConstants.h:70:9`! 0x10 ///< byte |
| 71 | #define BPF_SIZE_DWcxx . . $ `arch/BPF/BPFConstants.h:71:9`! 0x18 ///< eBPF only: double word |
| 72 | |
| 73 | #define BPF_MODEcxx . . $ `arch/BPF/BPFConstants.h:73:9`!(code) ((code) & 0xe0) |
| 74 | ///< Mode modifier |
| 75 | #define BPF_MODE_IMMcxx . . $ `arch/BPF/BPFConstants.h:75:9`! 0x00 ///< used for 32-bit mov in cBPF and 64-bit in eBPF |
| 76 | #define BPF_MODE_ABScxx . . $ `arch/BPF/BPFConstants.h:76:9`! 0x20 |
| 77 | #define BPF_MODE_INDcxx . . $ `arch/BPF/BPFConstants.h:77:9`! 0x40 |
| 78 | #define BPF_MODE_MEMcxx . . $ `arch/BPF/BPFConstants.h:78:9`! 0x60 |
| 79 | #define BPF_MODE_LENcxx . . $ `arch/BPF/BPFConstants.h:79:9`! 0x80 ///< cBPF only, reserved in eBPF |
| 80 | #define BPF_MODE_MSHcxx . . $ `arch/BPF/BPFConstants.h:80:9`! 0xa0 ///< cBPF only, reserved in eBPF |
| 81 | #define BPF_MODE_XADDcxx . . $ `arch/BPF/BPFConstants.h:81:9`! 0xc0 ///< eBPF only: exclusive add |
| 82 | |
| 83 | #define BPF_MISCOPcxx . . $ `arch/BPF/BPFConstants.h:83:9`!(code) ((code) & 0x80) |
| 84 | ///< Operation of misc |
| 85 | #define BPF_MISCOP_TAXcxx . . $ `arch/BPF/BPFConstants.h:85:9`! 0x00 |
| 86 | #define BPF_MISCOP_TXAcxx . . $ `arch/BPF/BPFConstants.h:86:9`! 0x80 |
| 87 | |
| 88 | #endif |