]> Git Repo - binutils.git/blob - sim/pru/pru.h
Update copyright year range in all GDB files
[binutils.git] / sim / pru / pru.h
1 /* Copyright 2016-2021 Free Software Foundation, Inc.
2    Contributed by Dimitar Dimitrov <[email protected]>
3
4    This file is part of the PRU simulator.
5
6    This library is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef PRU_H
20 #define PRU_H
21
22 #include "config.h"
23 #include "opcode/pru.h"
24
25 /* Needed for handling the dual PRU address space.  */
26 #define IMEM_ADDR_MASK  ((1u << 23) - 1)
27
28 #define IMEM_ADDR_DEFAULT 0x20000000
29
30 /* Define memory sizes to allocate for simulated target.  Sizes are
31    artificially large to accommodate execution of compiler test suite.
32    Please synchronize with the linker script for prusim target.  */
33 #define DMEM_DEFAULT_SIZE (64 * 1024 * 1024)
34
35 /* 16-bit word addressable space.  */
36 #define IMEM_DEFAULT_SIZE (64 * 4 * 1024)
37
38 /* For AM335x SoCs.  */
39 #define XFRID_SCRATCH_BANK_0      10
40 #define XFRID_SCRATCH_BANK_1      11
41 #define XFRID_SCRATCH_BANK_2      12
42 #define XFRID_SCRATCH_BANK_PEER   14
43 #define XFRID_MAX                 255
44
45 #define CPU     (cpu->pru_cpu)
46
47 #define PC              (CPU.pc)
48 #define PC_byteaddr     ((PC << 2) | PC_ADDR_SPACE_MARKER)
49
50 /* Various opcode fields.  */
51 #define RS1 extract_regval (CPU.regs[GET_INSN_FIELD (RS1, inst)], \
52                             GET_INSN_FIELD (RS1SEL, inst))
53 #define RS2 extract_regval (CPU.regs[GET_INSN_FIELD (RS2, inst)], \
54                             GET_INSN_FIELD (RS2SEL, inst))
55
56 #define RS2_w0 extract_regval (CPU.regs[GET_INSN_FIELD (RS2, inst)], \
57                                RSEL_15_0)
58
59 #define XBBO_BASEREG (CPU.regs[GET_INSN_FIELD (RS1, inst)])
60
61 #define RS1SEL GET_INSN_FIELD (RS1SEL, inst)
62 #define RS1_WIDTH regsel_width (RS1SEL)
63 #define RDSEL GET_INSN_FIELD (RDSEL, inst)
64 #define RD_WIDTH regsel_width (RDSEL)
65 #define RD_REGN GET_INSN_FIELD (RD, inst)
66 #define IO GET_INSN_FIELD (IO, inst)
67 #define IMM8 GET_INSN_FIELD (IMM8, inst)
68 #define IMM16 GET_INSN_FIELD (IMM16, inst)
69 #define WAKEONSTATUS GET_INSN_FIELD (WAKEONSTATUS, inst)
70 #define CB GET_INSN_FIELD (CB, inst)
71 #define RDB GET_INSN_FIELD (RDB, inst)
72 #define XFR_WBA GET_INSN_FIELD (XFR_WBA, inst)
73 #define LOOP_JMPOFFS GET_INSN_FIELD (LOOP_JMPOFFS, inst)
74 #define BROFF ((uint32_t) GET_BROFF_SIGNED (inst))
75
76 #define _BURSTLEN_CALCULATE(BITFIELD)                                       \
77   ((BITFIELD) >= LSSBBO_BYTECOUNT_R0_BITS7_0 ?                              \
78   (CPU.regs[0] >> ((BITFIELD) - LSSBBO_BYTECOUNT_R0_BITS7_0) * 8) & 0xff    \
79   : (BITFIELD) + 1)
80
81 #define BURSTLEN _BURSTLEN_CALCULATE (GET_BURSTLEN (inst))
82 #define XFR_LENGTH _BURSTLEN_CALCULATE (GET_INSN_FIELD (XFR_LENGTH, inst))
83
84 #define DO_XIN(wba,regn,rdb,l)    \
85   pru_sim_xin (sd, cpu, (wba), (regn), (rdb), (l))
86 #define DO_XOUT(wba,regn,rdb,l)   \
87   pru_sim_xout (sd, cpu, (wba), (regn), (rdb), (l))
88 #define DO_XCHG(wba,regn,rdb,l)   \
89   pru_sim_xchg (sd, cpu, (wba), (regn), (rdb), (l))
90
91 #define RAISE_SIGILL(sd)  sim_engine_halt ((sd), NULL, NULL, PC_byteaddr, \
92                                            sim_stopped, SIM_SIGILL)
93 #define RAISE_SIGINT(sd)  sim_engine_halt ((sd), NULL, NULL, PC_byteaddr, \
94                                            sim_stopped, SIM_SIGINT)
95
96 #define MAC_R25_MAC_MODE_MASK     (1u << 0)
97 #define MAC_R25_ACC_CARRY_MASK    (1u << 1)
98
99 #define CARRY   CPU.carry
100 #define CTABLE  CPU.ctable
101
102 #define PC_ADDR_SPACE_MARKER    CPU.pc_addr_space_marker
103
104 #define LOOPTOP           CPU.loop.looptop
105 #define LOOPEND           CPU.loop.loopend
106 #define LOOP_IN_PROGRESS  CPU.loop.loop_in_progress
107 #define LOOPCNT           CPU.loop.loop_counter
108
109 /* 32 GP registers plus PC.  */
110 #define NUM_REGS        33
111
112 #endif /* PRU_H */
This page took 0.030838 seconds and 4 git commands to generate.