Commit Graph

12386 Commits

Author SHA1 Message Date
Antonio Borneo 6da4025167 target: cortex_m: replace 'implementor' with 'implementer'
ARM documentation for Cortex-M reports the field 'implementer' in
the register CPUID.
OpenOCD used the miss-spelled 'implementor'. Fix it!

Change-Id: I854d223971ae7a49346e1f7491c2c0415f5e2c1d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8318
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
2024-07-13 22:19:55 +00:00
Antonio Borneo fbb16b05da target: cortex_m: add detection for Cortex-M52
Add Cortex-M52 to the list of known Cortex-M implementations to
allow detection of the core.
Values checked against the ARM document "Arm China Cortex®-M52
Processor Technical Reference Manual" 102776_0002_06_en.

Reported-by: Joseph Yiu <Joseph.Yiu@arm.com>
Change-Id: Id0bde8a0476f76799b7274835db9690f975e2dd6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8317
Tested-by: jenkins
2024-07-13 22:19:33 +00:00
Antonio Borneo df7a31f536 target: cortex_m: fix detection of STAR-MC1 device
The detection of Cortex-M STAR-MC1 was introduced with [1], at a
time when OpenOCD was only checking the field PartNo of the CPUID
register.
Later-on [2], OpenOCD extended the check to the field implementer
of CPUID register. The value for ARM (0x41) implementer was used
to all the Cortex-M, but no feedback for STAR-MC1 was available. A
comment reporting the possible mismatch was added.

As reported on OpenOCD mailing-list, the technical reference manual
for STAR-MC1 is now available [3] and it reports the implementer
as ARM China (0x63) [3].

Fix the STAR-MC1 implementer accordingly.

Reported-by: Joseph Yiu <Joseph.Yiu@arm.com>
Change-Id: I8ed1064a847b73065528ee7032be967b5c58b431
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Link: [1] 7dc4be3157 ("target/arm: Add support with identify STAR-MC1")
Fixes: [2] 05ee889155 ("target/cortex_m: check core implementor field")
Link: [3] https://www.armchina.com/download/Documents/Application-Notes/Technical-Reference-Manual?infoId=160
Reviewed-on: https://review.openocd.org/c/openocd/+/8316
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2024-07-13 22:19:04 +00:00
Marc Schink ed80a182ce tcl: Replace 'hla_' prefix with 'hla' command group
Change-Id: I99ec2dc7f300352d091cf9eb807a690901c33307
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8338
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-07-13 22:18:17 +00:00
Marc Schink 4d99e77419 jtag/hla: Restructure commands
Use a command group 'hla' with subcommands instead of individual
commands with 'hla_' prefix.

The old commands are still available to ensure backwards compatibility,
but are marked as deprecated.

Change-Id: I612e3cc080d308735932aea0f11001428eadc570
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8335
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-07-13 16:48:53 +00:00
Mark Zhuang 7957208cf6 openocd: fix some coding style
Add space around math operators.

Change-Id: I50fce3da283a78ba02bf70b6a752f7bf778d79f5
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7585
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-07-13 16:47:44 +00:00
Antonio Borneo 990869f7ec openocd: build: prevent old clone to fail on git submodules
Working on an old local git repository, the git sub-modules could
have been set before last changes in .gitmodules.
The script 'bootstrap' does not update the url of the repositories
and this can cause the script to fail.

Add 'git submodule sync' to the script to update the url of the
repositories.
While there, fuse 'git submodule init' and git submodule update'
in a single command.

Reported-by: Karl Hammar <karl@aspodata.se>
Change-Id: I61412f804dbbb7a843aa009139ddb4b8e71beefb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8375
Tested-by: jenkins
2024-07-13 16:47:12 +00:00
Marc Schink 6ed058933c doc: Refurbish manual page
Remove the outdated option '--pipe' and bring the description of OpenOCD
up to date without focus on JTAG only.

Change-Id: If52e936a366dde21c1dd514bd3960d100b540e77
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8347
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-07-13 16:46:36 +00:00
Marc Schink 636f003eee AUTHORS: Refer to source code and Git history
The list of authors and contributors is not maintained and outdated for
years now. Refer to the source code and Git history instead of keeping a
separate list.

Change-Id: I9a92e8e0d5073b56030bc36086b76e28de96389f
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8346
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-07-13 16:46:06 +00:00
Marc Schink 31e0fc4a7a doc: Remove outdated '-pipe' option
Change-Id: Ie3a7a3aaf69485f16b2447bd1dfa7622b584c7c0
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8348
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-07-13 16:45:34 +00:00
Antonio Borneo 2fe392ef50 flash: psoc6: drop use of 'coreid' to identify the CPU
The flag '-coreid' is used by the command 'target create' to
specify the debug controller of the target, either in case of a
single debug controller for multiple CPU (e.g. RISC-V harts) or
in case of multiple CPU on a DAP access port (e.g. Cortex-A SMP
cluster).
It is also currently used to specify the CPU ID in a SMP cluster,
but this is going to be reworked.

This flag has no effects on Cortex-M; ARM specifies that only one
CPU Cortex-M can occupy the DAP access port by using hardcoded
addresses.

The flash driver 'psoc6' uses the flag '-coreid' to detect if the
current target is the Cortex-M0 on AP#1 or the Cortex-M4 on AP#2
in the SoC.
There are other ways to run such detection, without using such
unrelated '-coreid' flag, e.g. using the AP number or the arch
type of the target.

Use the arch type to detect Cortex-M0 (ARM_ARCH_V6M) vs Cortex-M4
(ARM_ARCH_V7M).
Drop the flags '-coreid' from the psoc6 configuration file.

Change-Id: I0b9601c160dd4f2421a03ce6e3e7c55c6212f714
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8128
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2024-07-13 16:44:53 +00:00
Antonio Borneo c9f22c79df doc: document 'target create' flags '-dbgbase' and '-coreid'
Add to the command 'target create' the description for the flags
'-dbgbase' and '-coreid'.
Report that '-coreid' is currently used for purposes other than
CPU detection/examination, and that such uses are going to be
re-considered.

Change-Id: I25c839e3653101234c5862ce9da77019a5bb3249
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8129
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2024-07-13 16:44:26 +00:00
Evgeniy Naydanov 87c581a80d
Merge pull request #1099 from en-sc/en-sc/sb-addr-batch
target/riscv: write SB address using batch
2024-07-12 14:18:34 +03:00
Evgeniy Naydanov 6d4ad0033e target/riscv: write SB address using batch
Reduces the number of JTAG queue flushes.

Change-Id: Id103f5da1a3ea3177447046711e0e62a22c98c75
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-10 13:08:20 +03:00
Evgeniy Naydanov 2f29b804be
Merge pull request #1096 from en-sc/en-sc/run-batch-busy
target/riscv: reset `dmi.busy` after batches
2024-07-09 14:29:04 +03:00
Evgeniy Naydanov 59ce92aaeb
Merge pull request #1083 from en-sc/en-sc/deprecate-reset-timeout
target/riscv: deprecate `riscv set_reset_timeout_sec`
2024-07-09 14:28:42 +03:00
Evgeniy Naydanov f34e531bd7
Merge pull request #1081 from en-sc/en-sc/sb_read_v1
target/riscv: use batch interface in `read_memory_bus_v1()`
2024-07-09 14:28:15 +03:00
Evgeniy Naydanov 57d2553cec
Merge pull request #1093 from en-sc/en-sc/v-ext-csrs
target/riscv: vector CSRs are optional
2024-07-09 14:27:53 +03:00
Tommy Murphy 205e4c8b97 Align include guards with OpenOCD coding guidelines
Fixes: https://github.com/riscv-collab/riscv-openocd/issues/1097
2024-07-09 11:03:33 +01:00
Evgeniy Naydanov f3abfe49fd target/riscv: deprecate `riscv set_reset_timeout_sec`
Change-Id: I46bf3e4dab2a99c97b7ab133a85c13332365f9b7
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-04 12:20:38 +03:00
Evgeniy Naydanov f5f5f6dd2a
Merge pull request #1082 from en-sc/en-sc/sbcs-read
target/riscv: simplify `sbcs` read in `write_memory_bus_v1()`
2024-07-04 12:17:08 +03:00
Evgeniy Naydanov c05a10d318 target/riscv: reset `dmi.busy` after batches
Additionally, avoid calling `riscv_batch_finished_scans()` /
decrementing reset counter if the batch run failed.

Change-Id: I3eb7b23e4dc029090e92e3e543719824add623e1
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-03 11:32:39 +03:00
Evgeniy Naydanov 6ea577d3f5 target/riscv: vector CSRs are optional
This is a fix to a mistake made in
ea7e17491d.

The newly introduced `gdb_regno_exist()` function was missing a part
regarding vector CSRs.
Link: ea7e17491d (diff-b4aa16f9e42cb8f0934baa7c8e0ec9c70a369bef98b99b26ae2e896c8aa95d6aL6163-L6171)

Change-Id: I0361ea4dce8df5be748e2c6e7e6838029d3a7120
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-03 11:27:31 +03:00
Evgeniy Naydanov aa4fcee9d1 target/riscv: use batch interface in `read_memory_bus_v1()`
Fixes #1080

Change-Id: Ifc1a48fcd0b28f7cdb1e5ad3cbd20d53ea3560a5
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-03 11:17:55 +03:00
Evgeniy Naydanov 4b5668bdaa
Merge pull request #1087 from en-sc/en-sc/delay-types
target/riscv: replace `info->*_delay` with `riscv_scan_delays`
2024-07-03 10:54:28 +03:00
Evgeniy Naydanov e9eca80c31
Merge pull request #1084 from en-sc/en-sc/ref-reg-files
target/riscv: separate register cache stuff into files
2024-07-03 10:52:05 +03:00
Evgeniy Naydanov 4455f7f3c8 target/riscv: simplify `sbcs` read in `write_memory_bus_v1()`
Change-Id: Ifc94614eaaa191925d44d8963cd6d1e5e8427cba
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-02 20:14:11 +03:00
Evgeniy Naydanov 3883b03aaa target/riscv: separate register cache stuff into files
This commit creates file structure for register cache related
functions.
Specifically:

* `riscv_reg.h` -- general interface to registers. Safe to use after
  register cache initialization is successful.
* `riscv_reg_impl.h` -- helper functions to use while implementing
  register cache initialization.
* `riscv_reg.c` -- definitions of functions from `riscv_reg.h` and
  `riscv_reg_impl.h`.
* `riscv-011_reg.h` -- register cache interface specific to 0.11
  targets.
* `riscv-013_reg.h` -- register cache interface specific to 0.13+
  targets.
* `riscv-011/0.13.h` -- version-specific methods used to access
  registers. Will be extended as needed once other functionality (not
  related to register access) is separated (e.g. DM/DTM specific stuff).

Change-Id: I7918f78d0d79b97188c5703efd0296660e529f2a
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-02 10:15:20 +03:00
Evgeniy Naydanov aa9a3fa348 target/riscv: replace `info->*_delay` with `riscv_scan_delays`
* Improves error handling.
* Handles possible overflow.

Change-Id: Iae0df9356af06cc21dc71c86ba7c923d1515bdc5
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-07-01 15:42:42 +03:00
Evgeniy Naydanov c6bb902629
Merge pull request #1085 from en-sc/en-sc/checkpatch-check-git
.github/workflows: check git revisions instead of a diff
2024-07-01 10:00:15 +03:00
Evgeniy Naydanov ad871cb11b
Merge pull request #1094 from en-sc/en-sc/from_upstream
Merge up to ad87fbd1cf from upstream
2024-07-01 09:59:07 +03:00
Tomas Vanek 23c33e1d3a target/cortex_m: workaround Cortex-M7 erratum 3092511
When an asynchronous exception occurs at the same time
as a breakpoint event (either hardware breakpoint or software breakpoint),
it is possible for the processor to halt at the beginning of the
exception handler instead of the instruction address pointed
by the breakpoint.

During debug entry in exception handler state and with BKPT bit set
as the only break reason in DFSR, check if there is a breakpoint, which
have triggered the debug halt. If there is no such breakpoint,
resume execution. The processor services the interrupt and
halts again at the correct breakpoint address.

The workaround is not needed during target algo run (debug_execution)
because interrupts are disabled in PRIMASK register.

Also after single step the workaround resume never takes place:
the situation is treated as error.

Link: https://developer.arm.com/documentation/SDEN1068427/latest/
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I8b23f39cedd7dccabe7e7066d616fb972b69f769
Reviewed-on: https://review.openocd.org/c/openocd/+/8332
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Liviu Ionescu
2024-07-01 03:32:22 +00:00
Evgeniy Naydanov 2eedd74197 Merge up to ad87fbd1cf from upstream
Conflicts:

* `doc/openocd.texi`: due to d382c95d57,
resolved by selecting the upstream version.

* `src/server/gdb_server.c`: between
944fe66f10 and
92e8823ebd. Resolved by adopting the use
of `LOG_TARGET_*`.
* `src/target/target.c`: between
639e68a621 and
c5358c84ad, selected the version from
`riscv-openocd`.

Change-Id: Ic1327f25e147945e0ec82947a82452501e8ee5de
2024-06-25 14:51:18 +03:00
Tomas Vanek ad87fbd1cf tcl/interface: support for Raspberry Pi 5
Make sure raspberrypi-native.cfg cannot be used on RPi5.

Add raspberrypi5-gpiod.cfg which uses linuxgpiod adapter driver.
Issue a warning if PCIe is in power save mode.

While on it, re-format warnings issued from Tcl to look similar
to LOG_WARNING() output.

Change-Id: If19b0350bd5fff83d9a0c65999e33b161fb6957a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8333
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2024-06-25 07:23:18 +00:00
Antonio Borneo 67be8188bb Remove other '_s' suffix from structs
Most of the work is already done by [1].
Remove few more '_s' suffix and also fix some comment referring to
the old name of the struct.

Link: https://review.openocd.org/c/openocd/+/8340
Change-Id: Ifddc401c3b05e62ece3aa7926af1e78f0c4a671e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8341
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2024-06-23 09:33:47 +00:00
Marc Schink 6b984a54c9 Remove '_s' suffix from structs
Change-Id: I956acce316e60252b317daa41274403d87f704b8
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8340
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-06-23 09:33:33 +00:00
Marc Schink 92e8823ebd server/gdb: Use LOG_TARGET_xxx() to show target name
The output "gdb port disabled" is confusing without reference to the
target. Use LOG_TARGET_INFO() to output the target name.

While at it, use LOG_TARGET_xxx() for all log statements where the
target name is already used.

Change-Id: I70b134145837db623e008a4a6c0be0008d9a0d87
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8313
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-06-23 09:33:13 +00:00
Timur Golubovich 23ba602ca5 remote_bitbang: fix assertion failure for the cases when connection is abruptly terminated
Changes affect the function remote_bitbang_fill_buf.
When read_socket returns 0, socket reached EOF and there is
no data to read. But if request was blocking, the caller
expected some data. Such situations should be treated as ERROR.

Change-Id: I02ed484e61fb776c1625f6e36ab14c85891939b2
Signed-off-by: Timur Golubovich <timur.golubovich@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8325
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-06-23 09:32:08 +00:00
Antonio Borneo dde096e03f itm: fix default initialization
Commit f9509c92db ("itm: rework itm commands before 'init'")
ignores the default enable of ITM channel 0, that is applied when
no 'itm port[s]' is issued.

Call armv7m_trace_itm_config() unconditionally to handle it.

Change-Id: I3e85d0b063ed38c1552f6af9ea9eea2e76aa9025
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Paul Fertser <fercerpav@gmail.com>
Fixes: f9509c92db ("itm: rework itm commands before 'init'")
Reviewed-on: https://review.openocd.org/c/openocd/+/7900
Reviewed-by: <post@frankplowman.com>
Tested-by: jenkins
2024-06-23 09:30:43 +00:00
Antonio Borneo 198fecf5e4 target: aarch64: access reg SPSR_EL1 only in EL1, EL2 and EL3
The register SPSR_EL1 is accessible and it's content is relevant
only when the target is in EL1 or EL2 or EL3.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd5384000, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $SPSR_EL1
or through OpenOCD command
        reg SPSR_EL1

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.

Change-Id: Ia0f984d52920cc32b8ee31157d62c13dea616a3a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8276
Tested-by: jenkins
2024-06-23 09:29:43 +00:00
Antonio Borneo b5dfef7577 target: aarch64: access reg ESR_EL1 only in EL1, EL2 and EL3
The register ESR_EL1 is accessible and it's content is relevant
only when the target is in EL1 or EL2 or EL3.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd5385200, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $ESR_EL1
or through OpenOCD command
        reg ESR_EL1

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.

Change-Id: Icd65470c279e5cfd03091db6435cdaa1c447644c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8275
Tested-by: jenkins
2024-06-23 09:29:37 +00:00
Antonio Borneo f39f136e01 target: aarch64: access reg ELR_EL1 only in EL1, EL2 and EL3
The register ELR_EL1 is accessible and it's content is relevant
only when the target is in EL1 or EL2 or EL3.

Without this patch, an error:
	Error: Opcode 0xd5384020, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
	x/p $ELR_EL1
or through OpenOCD command
	reg ELR_EL1

Detect the EL and return error if the register cannot be accessed.

Change-Id: I402dda4cd9dae502b05572fc6c1a8f0edf349bb1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8274
Tested-by: jenkins
2024-06-23 09:29:29 +00:00
Antonio Borneo 2a63fabd09 target: aarch64: access reg SPSR_EL2 only in EL2 and EL3
The register SPSR_EL2 is accessible and it's content is relevant
only when the target is in EL2 or EL3.
Virtualization SW in EL1 can also access it, but this either
triggers a trap to EL2 or returns SPSR_EL1. Debugger should not
mix the real SPSR_EL2 with the virtual register.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd53c4000, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $SPSR_EL2
or through OpenOCD command
        reg SPSR_EL2

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.

Change-Id: If3792296b36282c08d597dd46cfe044d6b8288ea
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8273
Tested-by: jenkins
2024-06-23 09:29:22 +00:00
Antonio Borneo 766a84b798 target: aarch64: access reg ESR_EL2 only in EL2 and EL3
The register ESR_EL2 is accessible and it's content is relevant
only when the target is in EL2 or EL3.
Virtualization SW in EL1 can also access it, but this either
triggers a trap to EL2 or returns ESR_EL1. Debugger should not mix
the real ESR_EL2 with the virtual register.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd53c5200, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $ESR_EL2
or through OpenOCD command
        reg ESR_EL2

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.

Change-Id: Icb32b44886d50907f29b068ce61e4be8bed10208
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8272
Tested-by: jenkins
2024-06-23 09:29:16 +00:00
Antonio Borneo 190176a6bc target: aarch64: access reg ELR_EL2 only in EL2 and EL3
The register ELR_EL2 is accessible and it's content is relevant
only when the target is in EL2 or EL3.
Virtualization SW in EL1 can also access it, but this either
triggers a trap to EL2 or returns ELR_EL1. Debugger should not mix
the real ELR_EL2 with the virtual register.

Without this patch, an error:
	Error: Opcode 0xd53c4020, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
	x/p $ELR_EL2
or through OpenOCD command
	reg ELR_EL2

Detect the EL and return error if the register cannot be accessed.

Change-Id: Idf02b42a7339df83260c1e44ceabbb05fbf392b9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8271
Tested-by: jenkins
2024-06-23 09:29:04 +00:00
Antonio Borneo 405e78771b target: aarch64: access reg SPSR_EL3 only in EL3
The register SPSR_EL3 is accessible and it's content is relevant
only when the target is in EL3.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd53e4000, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $SPSR_EL3
or through OpenOCD command
        reg SPSR_EL3

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.

Change-Id: I00849d99feeb96589c426fcafda98127dbd19a67
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8270
Tested-by: jenkins
2024-06-23 09:28:48 +00:00
Antonio Borneo 2306809160 target: aarch64: access reg ESR_EL3 only in EL3
The register ESR_EL3 is accessible and it's content is relevant
only when the target is in EL3.
Plus, the register is 64 bits wide.

Without this patch, an error:
	Error: Opcode 0xd53e5200, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
        x/p $ESR_EL3
or through OpenOCD command
        reg ESR_EL3

Detect the EL and return error if the register cannot be accessed.
Handle the register as 64 bits.
Drop the FIXME comment on Aarch32 case, as the register exists in
Aarch64 only.

Change-Id: Ie8c69dc7b50ae81a52506cf151c8e64e15752d0d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8269
Tested-by: jenkins
2024-06-23 09:28:40 +00:00
Antonio Borneo 8c75e47603 target: aarch64: access reg ELR_EL3 only in EL3
The register ELR_EL3 is accessible and it's content is relevant
only when the target is in EL3.

Without this patch, an error:
	Error: Opcode 0xd53e4020, DSCR.ERR=1, DSCR.EL=1
is triggered by GDB register window or through GDB command
	x/p $ELR_EL3
or through OpenOCD command
	reg ELR_EL3

Detect the EL and return error if the register cannot be accessed.

Change-Id: I545abb196e5c34e462c7e5d5d3ec952e588642da
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8268
Tested-by: jenkins
2024-06-23 09:28:32 +00:00
Antonio Borneo bcd6a10223 target: armv8_dpm: silence error on register R/W
The command 'gdb_report_register_access_error' is used to silence
errors while reading registers and not reporting them to GDB.
Nevertheless, the error is printed by a LOG_ERROR() in armv8_dpm.

Change the message to LOG_DEBUG().
It will still cause the error to be propagated and eventually
printed by the caller (e.g. by the command 'reg').

Change-Id: Ic0db74fa28235d686ddd21a5960c52ae003e0931
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8267
Tested-by: jenkins
2024-06-23 09:28:21 +00:00
Antonio Borneo 91043cecee target: aarch64: align armv8_read_reg() and armv8_read_reg32()
These functions are today always called with non-NULL parameter
regval, so the actual check is not needed.
Anyway, for any future code change, check the parameter at the
entry of the functions and return error if it is not valid.
Simplify the check to assign the result value and align the code
of the two functions.

Change-Id: Ie4d98063006d70d9e2bcfc00bc930133caf33515
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8266
Tested-by: jenkins
2024-06-23 09:28:08 +00:00