/* * x86 instruction attribute tables * * Written by Masami Hiramatsu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifdef __KERNEL__ #include #include #include #else #include "insn.h" #include "inat.h" #endif /* Attribute tables are generated from opcode map */ #include "inat-tables.c" /* Attribute search APIs */ insn_attr_t inat_get_opcode_attribute(u8 opcode) { return inat_primary_table[opcode]; } insn_attr_t inat_get_escape_attribute(u8 opcode, u8 last_pfx, insn_attr_t esc_attr) { const insn_attr_t *table; insn_attr_t lpfx_attr = inat_get_opcode_attribute(last_pfx); int n, m; n = INAT_ESCAPE_NUM(esc_attr); m = INAT_LPREFIX_NUM(lpfx_attr); table = inat_escape_tables[n][0]; if (!table) return 0; if (INAT_HAS_VARIANT(table[opcode]) && m) { table = inat_escape_tables[n][m]; if (!table) return 0; } return table[opcode]; } #define REGBITS(modrm) (((modrm) >> 3) & 0x7) insn_attr_t inat_get_group_attribute(u8 modrm, u8 last_pfx, insn_attr_t grp_attr) { const insn_attr_t *table; insn_attr_t lpfx_attr = inat_get_opcode_attribute(last_pfx); int n, m; n = INAT_GROUP_NUM(grp_attr); m = INAT_LPREFIX_NUM(lpfx_attr); table = inat_group_tables[n][0]; if (!table) return INAT_GROUP_COMMON(grp_attr); if (INAT_HAS_VARIANT(table[REGBITS(modrm)]) && m) { table = inat_escape_tables[n][m]; if (!table) return INAT_GROUP_COMMON(grp_attr); } return table[REGBITS(modrm)] | INAT_GROUP_COMMON(grp_attr); }