xref: /openbmc/qemu/target/hexagon/cpu_bits.h (revision 04b09de1)
1 /*
2  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 
18 #ifndef HEXAGON_CPU_BITS_H
19 #define HEXAGON_CPU_BITS_H
20 
21 #include "qemu/bitops.h"
22 
23 #define PCALIGN 4
24 #define PCALIGN_MASK (PCALIGN - 1)
25 
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
32 
33 #define HEX_EXCP_TRAP0           0x172
34 
35 #define PACKET_WORDS_MAX         4
36 
37 static inline uint32_t parse_bits(uint32_t encoding)
38 {
39     /* The parse bits are [15:14] */
40     return extract32(encoding, 14, 2);
41 }
42 
43 static inline uint32_t iclass_bits(uint32_t encoding)
44 {
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;
50     }
51     return iclass;
52 }
53 
54 static inline bool is_packet_end(uint32_t endocing)
55 {
56     uint32_t bits = parse_bits(endocing);
57     return ((bits == 0x3) || (bits == 0x0));
58 }
59 
60 int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc, GString *buf);
61 
62 #endif
63