TriCore Registers Profile fix for arch "tricore" and "tricore.cs" ##arch

* Others TriCore CPU could require some adjustments on special registers.
This commit is contained in:
kcdq 2024-09-01 11:26:40 +02:00 committed by GitHub
parent 4e47b8841d
commit c0b426bb3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 226 additions and 201 deletions

View File

@ -156,73 +156,81 @@ static bool decode(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) {
static char *get_reg_profile(RArchSession *as) {
const char *p =
"=PC pc\n"
"=SP a10\n"
"=BP a11\n"
"=A0 a4\n"
"=A1 a5\n"
"=A2 a6\n"
"=A3 a7\n"
"=SN a0\n"
"gpr p0 .64 0 0\n"
"gpr a0 .32 0 0\n"
"gpr a1 .32 4 0\n"
"gpr p2 .64 8 0\n"
"gpr a2 .32 8 0\n"
"gpr a3 .32 12 0\n"
"gpr p4 .64 16 0\n"
"gpr a4 .32 16 0\n"
"gpr a5 .32 20 0\n"
"gpr p6 .64 24 0\n"
"gpr a6 .32 24 0\n"
"gpr a7 .32 28 0\n"
"gpr p8 .64 32 0\n"
"gpr a8 .32 32 0\n"
"gpr a9 .32 36 0\n"
"gpr p10 .64 40 0\n"
"gpr sp .64 40 0\n"
"gpr a10 .64 40 0\n"
"gpr a11 .32 44 0\n"
"gpr p12 .64 48 0\n"
"gpr a12 .32 48 0\n"
"gpr a13 .32 52 0\n"
"gpr p14 .64 56 0\n"
"gpr a14 .32 56 0\n"
"gpr a15 .32 60 0\n"
"gpr e0 .64 64 0\n"
"gpr d0 .32 64 0\n"
"gpr d1 .32 68 0\n"
"gpr e2 .64 72 0\n"
"gpr d2 .32 72 0\n"
"gpr d3 .32 76 0\n"
"gpr e4 .64 80 0\n"
"gpr d4 .32 80 0\n"
"gpr d5 .32 84 0\n"
"gpr e6 .64 88 0\n"
"gpr d6 .32 88 0\n"
"gpr d7 .32 92 0\n"
"gpr e8 .64 96 0\n"
"gpr d8 .32 96 0\n"
"gpr d9 .32 100 0\n"
"gpr e10 .64 104 0\n"
"gpr d10 .32 104 0\n"
"gpr d11 .32 108 0\n"
"gpr e12 .64 112 0\n"
"gpr d12 .32 112 0\n"
"gpr d13 .32 114 0\n"
"gpr e14 .64 118 0\n"
"gpr d14 .32 118 0\n"
"gpr d15 .32 120 0\n"
"gpr PSW .32 124 0\n"
"gpr PCXI .32 128 0\n"
"gpr FCX .32 132 0\n"
"gpr LCX .32 136 0\n"
"gpr ISP .32 140 0\n"
"gpr ICR .32 144 0\n"
"gpr PIPN .32 148 0\n"
"gpr BIV .32 152 0\n"
"gpr BTV .32 156 0\n"
"gpr pc .32 160 0\n";
"=PC pc\n"
"=SP a10\n"
"=BP a11\n"
"=A0 a4\n"
"=A1 a5\n"
"=A2 a6\n"
"=A3 a7\n"
"=SN a0\n"
"# General-Purpose Address Registers (A0 - A15)\n"
"gpr a0 .32 0 0\n"
"gpr a1 .32 4 0\n"
"gpr a2 .32 8 0\n"
"gpr a3 .32 12 0\n"
"gpr a4 .32 16 0\n"
"gpr a5 .32 20 0\n"
"gpr a6 .32 24 0\n"
"gpr a7 .32 28 0\n"
"gpr a8 .32 32 0\n"
"gpr a9 .32 36 0\n"
"gpr sp .32 40 0\n"
"gpr a10 .32 40 0\n"
"gpr a11 .32 44 0\n"
"gpr a12 .32 48 0\n"
"gpr a13 .32 52 0\n"
"gpr a14 .32 56 0\n"
"gpr a15 .32 60 0\n"
"# General-Purpose Data Registers (D0 - D15)\n"
"gpr e0 .64 64 0\n"
"gpr d0 .32 64 0\n"
"gpr d1 .32 68 0\n"
"gpr e2 .64 72 0\n"
"gpr d2 .32 72 0\n"
"gpr d3 .32 76 0\n"
"gpr e4 .64 80 0\n"
"gpr d4 .32 80 0\n"
"gpr d5 .32 84 0\n"
"gpr e6 .64 88 0\n"
"gpr d6 .32 88 0\n"
"gpr d7 .32 92 0\n"
"gpr e8 .64 96 0\n"
"gpr d8 .32 96 0\n"
"gpr d9 .32 100 0\n"
"gpr e10 .64 104 0\n"
"gpr d10 .32 104 0\n"
"gpr d11 .32 108 0\n"
"gpr e12 .64 112 0\n"
"gpr d12 .32 112 0\n"
"gpr d13 .32 116 0\n"
"gpr e14 .64 120 0\n"
"gpr d14 .32 120 0\n"
"gpr d15 .32 124 0\n"
"# Special-Purpose Registers\n"
"gpr PSW .32 128 0 # Program Status Word\n"
"gpr PCXI .32 132 0 # Previous Context Information\n"
"gpr FCX .32 136 0 # Free Context List Pointer\n"
"gpr LCX .32 140 0 # Last Context Save Pointer\n"
"gpr ISP .32 144 0 # Interrupt Stack Pointer\n"
"gpr ICR .32 148 0 # Interrupt Control Register\n"
"gpr PIPN .32 152 0 # Pending Interrupt Priority Number\n"
"gpr BIV .32 156 0 # Base Interrupt Vector\n"
"gpr BTV .32 160 0 # Base Trap Vector\n"
"gpr pc .32 164 0 # Program Counter\n"
"# System Control and Configuration Registers\n"
"gpr SYSCON .32 168 0 # System Configuration Register\n"
"gpr DCON2 .32 172 0 # Debug Control Register 2\n"
"gpr CSP .32 176 0 # Context Save Pointer\n"
"gpr MMUCON .32 180 0 # Memory Management Unit Control\n"
"gpr CPU_ID .32 184 0 # CPU Identification Register\n"
"gpr PSWEN .32 188 0 # Program Status Word Enable Register\n"
"gpr CCUDR .32 192 0 # Cache Control Unit Debug Register\n"
"gpr IECON .32 196 0 # Interrupt Enable Configuration Register\n"
"gpr TRAPV .32 200 0 # Trap Vector Register\n"
"gpr BBR .32 204 0 # Base Boundary Register (Optional, depending on use)\n"
"gpr DBGSR .32 208 0 # Debug Status Register (Optional, depending on use)\n"
"gpr PCON .32 212 0 # Peripheral Control Register (Optional, depending on use)\n";
return strdup (p);
}

View File

@ -333,75 +333,84 @@ static bool fini(RArchSession *as) {
return true;
}
// Registers profile perfectly suitable for TC1767 CPU. Others CPU can require minor adjustments.
static char *regs(RArchSession *as) {
const char *p =
"=PC pc\n"
"=SP a10\n"
"=BP a11\n"
"=A0 a4\n"
"=A1 a5\n"
"=A2 a6\n"
"=A3 a7\n"
"=SN a0\n"
"gpr p0 .64 0 0\n"
"gpr a0 .32 0 0\n"
"gpr a1 .32 4 0\n"
"gpr p2 .64 8 0\n"
"gpr a2 .32 8 0\n"
"gpr a3 .32 12 0\n"
"gpr p4 .64 16 0\n"
"gpr a4 .32 16 0\n"
"gpr a5 .32 20 0\n"
"gpr p6 .64 24 0\n"
"gpr a6 .32 24 0\n"
"gpr a7 .32 28 0\n"
"gpr p8 .64 32 0\n"
"gpr a8 .32 32 0\n"
"gpr a9 .32 36 0\n"
"gpr sp .64 40 0\n"
"gpr p10 .64 40 0\n"
"gpr a10 .32 40 0\n"
"gpr a11 .32 44 0\n"
"gpr p12 .64 48 0\n"
"gpr a12 .32 48 0\n"
"gpr a13 .32 52 0\n"
"gpr p14 .64 56 0\n"
"gpr a14 .32 56 0\n"
"gpr a15 .32 60 0\n"
"gpr e0 .64 64 0\n"
"gpr d0 .32 64 0\n"
"gpr d1 .32 68 0\n"
"gpr e2 .64 72 0\n"
"gpr d2 .32 72 0\n"
"gpr d3 .32 76 0\n"
"gpr e4 .64 80 0\n"
"gpr d4 .32 80 0\n"
"gpr d5 .32 84 0\n"
"gpr e6 .64 88 0\n"
"gpr d6 .32 88 0\n"
"gpr d7 .32 92 0\n"
"gpr e8 .64 96 0\n"
"gpr d8 .32 96 0\n"
"gpr d9 .32 100 0\n"
"gpr e10 .64 104 0\n"
"gpr d10 .32 104 0\n"
"gpr d11 .32 108 0\n"
"gpr e12 .64 112 0\n"
"gpr d12 .32 112 0\n"
"gpr d13 .32 114 0\n"
"gpr e14 .64 118 0\n"
"gpr d14 .32 118 0\n"
"gpr d15 .32 120 0\n"
"gpr PSW .32 124 0\n"
"gpr PCXI .32 128 0\n"
"gpr FCX .32 132 0\n"
"gpr LCX .32 136 0\n"
"gpr ISP .32 140 0\n"
"gpr ICR .32 144 0\n"
"gpr PIPN .32 148 0\n"
"gpr BIV .32 152 0\n"
"gpr BTV .32 156 0\n"
"gpr pc .32 160 0\n";
"=PC pc\n"
"=SP a10\n"
"=BP a11\n"
"=A0 a4\n"
"=A1 a5\n"
"=A2 a6\n"
"=A3 a7\n"
"=SN a0\n"
"# General-Purpose Address Registers (A0 - A15)\n"
"gpr a0 .32 0 0\n"
"gpr a1 .32 4 0\n"
"gpr a2 .32 8 0\n"
"gpr a3 .32 12 0\n"
"gpr a4 .32 16 0\n"
"gpr a5 .32 20 0\n"
"gpr a6 .32 24 0\n"
"gpr a7 .32 28 0\n"
"gpr a8 .32 32 0\n"
"gpr a9 .32 36 0\n"
"gpr sp .32 40 0\n"
"gpr a10 .32 40 0\n"
"gpr a11 .32 44 0\n"
"gpr a12 .32 48 0\n"
"gpr a13 .32 52 0\n"
"gpr a14 .32 56 0\n"
"gpr a15 .32 60 0\n"
"# General-Purpose Data Registers (D0 - D15)\n"
"gpr e0 .64 64 0\n"
"gpr d0 .32 64 0\n"
"gpr d1 .32 68 0\n"
"gpr e2 .64 72 0\n"
"gpr d2 .32 72 0\n"
"gpr d3 .32 76 0\n"
"gpr e4 .64 80 0\n"
"gpr d4 .32 80 0\n"
"gpr d5 .32 84 0\n"
"gpr e6 .64 88 0\n"
"gpr d6 .32 88 0\n"
"gpr d7 .32 92 0\n"
"gpr e8 .64 96 0\n"
"gpr d8 .32 96 0\n"
"gpr d9 .32 100 0\n"
"gpr e10 .64 104 0\n"
"gpr d10 .32 104 0\n"
"gpr d11 .32 108 0\n"
"gpr e12 .64 112 0\n"
"gpr d12 .32 112 0\n"
"gpr d13 .32 116 0\n"
"gpr e14 .64 120 0\n"
"gpr d14 .32 120 0\n"
"gpr d15 .32 124 0\n"
"# Special-Purpose Registers\n"
"gpr PSW .32 128 0 # Program Status Word\n"
"gpr PCXI .32 132 0 # Previous Context Information\n"
"gpr FCX .32 136 0 # Free Context List Pointer\n"
"gpr LCX .32 140 0 # Last Context Save Pointer\n"
"gpr ISP .32 144 0 # Interrupt Stack Pointer\n"
"gpr ICR .32 148 0 # Interrupt Control Register\n"
"gpr PIPN .32 152 0 # Pending Interrupt Priority Number\n"
"gpr BIV .32 156 0 # Base Interrupt Vector\n"
"gpr BTV .32 160 0 # Base Trap Vector\n"
"gpr pc .32 164 0 # Program Counter\n"
"# System Control and Configuration Registers\n"
"gpr SYSCON .32 168 0 # System Configuration Register\n"
"gpr DCON2 .32 172 0 # Debug Control Register 2\n"
"gpr CSP .32 176 0 # Context Save Pointer\n"
"gpr MMUCON .32 180 0 # Memory Management Unit Control\n"
"gpr CPU_ID .32 184 0 # CPU Identification Register\n"
"gpr PSWEN .32 188 0 # Program Status Word Enable Register\n"
"gpr CCUDR .32 192 0 # Cache Control Unit Debug Register\n"
"gpr IECON .32 196 0 # Interrupt Enable Configuration Register\n"
"gpr TRAPV .32 200 0 # Trap Vector Register\n"
"gpr BBR .32 204 0 # Base Boundary Register (Optional, depending on use)\n"
"gpr DBGSR .32 208 0 # Debug Status Register (Optional, depending on use)\n"
"gpr PCON .32 212 0 # Peripheral Control Register (Optional, depending on use)\n";
return strdup (p);
}

View File

@ -50,73 +50,81 @@ NAME=TriCore return_0.elf
FILE=bins/tricore/return_0.elf
CMDS=drp
EXPECT=<<EOF
=PC pc
=SP a10
=BP a11
=A0 a4
=A1 a5
=A2 a6
=A3 a7
=SN a0
gpr p0 .64 0 0
gpr a0 .32 0 0
gpr a1 .32 4 0
gpr p2 .64 8 0
gpr a2 .32 8 0
gpr a3 .32 12 0
gpr p4 .64 16 0
gpr a4 .32 16 0
gpr a5 .32 20 0
gpr p6 .64 24 0
gpr a6 .32 24 0
gpr a7 .32 28 0
gpr p8 .64 32 0
gpr a8 .32 32 0
gpr a9 .32 36 0
gpr p10 .64 40 0
gpr sp .64 40 0
gpr a10 .64 40 0
gpr a11 .32 44 0
gpr p12 .64 48 0
gpr a12 .32 48 0
gpr a13 .32 52 0
gpr p14 .64 56 0
gpr a14 .32 56 0
gpr a15 .32 60 0
gpr e0 .64 64 0
gpr d0 .32 64 0
gpr d1 .32 68 0
gpr e2 .64 72 0
gpr d2 .32 72 0
gpr d3 .32 76 0
gpr e4 .64 80 0
gpr d4 .32 80 0
gpr d5 .32 84 0
gpr e6 .64 88 0
gpr d6 .32 88 0
gpr d7 .32 92 0
gpr e8 .64 96 0
gpr d8 .32 96 0
gpr d9 .32 100 0
gpr e10 .64 104 0
gpr d10 .32 104 0
gpr d11 .32 108 0
gpr e12 .64 112 0
gpr d12 .32 112 0
gpr d13 .32 114 0
gpr e14 .64 118 0
gpr d14 .32 118 0
gpr d15 .32 120 0
gpr PSW .32 124 0
gpr PCXI .32 128 0
gpr FCX .32 132 0
gpr LCX .32 136 0
gpr ISP .32 140 0
gpr ICR .32 144 0
gpr PIPN .32 148 0
gpr BIV .32 152 0
gpr BTV .32 156 0
gpr pc .32 160 0
=PC pc
=SP a10
=BP a11
=A0 a4
=A1 a5
=A2 a6
=A3 a7
=SN a0
# General-Purpose Address Registers (A0 - A15)
gpr a0 .32 0 0
gpr a1 .32 4 0
gpr a2 .32 8 0
gpr a3 .32 12 0
gpr a4 .32 16 0
gpr a5 .32 20 0
gpr a6 .32 24 0
gpr a7 .32 28 0
gpr a8 .32 32 0
gpr a9 .32 36 0
gpr sp .32 40 0
gpr a10 .32 40 0
gpr a11 .32 44 0
gpr a12 .32 48 0
gpr a13 .32 52 0
gpr a14 .32 56 0
gpr a15 .32 60 0
# General-Purpose Data Registers (D0 - D15)
gpr e0 .64 64 0
gpr d0 .32 64 0
gpr d1 .32 68 0
gpr e2 .64 72 0
gpr d2 .32 72 0
gpr d3 .32 76 0
gpr e4 .64 80 0
gpr d4 .32 80 0
gpr d5 .32 84 0
gpr e6 .64 88 0
gpr d6 .32 88 0
gpr d7 .32 92 0
gpr e8 .64 96 0
gpr d8 .32 96 0
gpr d9 .32 100 0
gpr e10 .64 104 0
gpr d10 .32 104 0
gpr d11 .32 108 0
gpr e12 .64 112 0
gpr d12 .32 112 0
gpr d13 .32 116 0
gpr e14 .64 120 0
gpr d14 .32 120 0
gpr d15 .32 124 0
# Special-Purpose Registers
gpr PSW .32 128 0 # Program Status Word
gpr PCXI .32 132 0 # Previous Context Information
gpr FCX .32 136 0 # Free Context List Pointer
gpr LCX .32 140 0 # Last Context Save Pointer
gpr ISP .32 144 0 # Interrupt Stack Pointer
gpr ICR .32 148 0 # Interrupt Control Register
gpr PIPN .32 152 0 # Pending Interrupt Priority Number
gpr BIV .32 156 0 # Base Interrupt Vector
gpr BTV .32 160 0 # Base Trap Vector
gpr pc .32 164 0 # Program Counter
# System Control and Configuration Registers
gpr SYSCON .32 168 0 # System Configuration Register
gpr DCON2 .32 172 0 # Debug Control Register 2
gpr CSP .32 176 0 # Context Save Pointer
gpr MMUCON .32 180 0 # Memory Management Unit Control
gpr CPU_ID .32 184 0 # CPU Identification Register
gpr PSWEN .32 188 0 # Program Status Word Enable Register
gpr CCUDR .32 192 0 # Cache Control Unit Debug Register
gpr IECON .32 196 0 # Interrupt Enable Configuration Register
gpr TRAPV .32 200 0 # Trap Vector Register
gpr BBR .32 204 0 # Base Boundary Register (Optional, depending on use)
gpr DBGSR .32 208 0 # Debug Status Register (Optional, depending on use)
gpr PCON .32 212 0 # Peripheral Control Register (Optional, depending on use)
EOF
RUN