Merge remote-tracking branch 'qemu-project/master'
[qemu/ar7.git] / target / hexagon / cpu_bits.h
blob4279281a7107d236f4123ac643e3d0319c9d829f
1 /*
2 * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #ifndef HEXAGON_CPU_BITS_H
19 #define HEXAGON_CPU_BITS_H
21 #include "qemu/bitops.h"
23 #define PCALIGN 4
24 #define PCALIGN_MASK (PCALIGN - 1)
26 #define HEX_EXCP_FETCH_NO_UPAGE 0x012
27 #define HEX_EXCP_INVALID_PACKET 0x015
28 #define HEX_EXCP_INVALID_OPCODE 0x015
29 #define HEX_EXCP_PC_NOT_ALIGNED 0x01e
30 #define HEX_EXCP_PRIV_NO_UREAD 0x024
31 #define HEX_EXCP_PRIV_NO_UWRITE 0x025
33 #define HEX_EXCP_TRAP0 0x172
35 #define PACKET_WORDS_MAX 4
37 static inline uint32_t parse_bits(uint32_t encoding)
39 /* The parse bits are [15:14] */
40 return extract32(encoding, 14, 2);
43 static inline uint32_t iclass_bits(uint32_t encoding)
45 /* The instruction class is encoded in bits [31:28] */
46 uint32_t iclass = extract32(encoding, 28, 4);
47 /* If parse bits are zero, this is a duplex */
48 if (parse_bits(encoding) == 0) {
49 iclass += 16;
51 return iclass;
54 static inline bool is_packet_end(uint32_t endocing)
56 uint32_t bits = parse_bits(endocing);
57 return ((bits == 0x3) || (bits == 0x0));
60 int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc, GString *buf);
62 #endif