Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Cortex-R support #1657

Merged
merged 50 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fcafc6b
adiv5: Defined a proper Cortex-R architecture type and corrected the …
dragonmux Aug 8, 2023
d8cad9d
cortexr: Began implementing a probe routine for detecting and handlin…
dragonmux Aug 8, 2023
7b0df18
cortexr: Added Cortex-R definitions for and a call to cortex_read_cpu…
dragonmux Aug 8, 2023
94c8446
cortexr: Implemented support for reading and writing memory on Cortex…
dragonmux Aug 8, 2023
71f7d8c
cortexr: Defined various registers found in the debug address space
dragonmux Aug 9, 2023
11b4aa7
cortexr: Implemented a mechanism for reading coprocessor registers
dragonmux Aug 9, 2023
bf3fde3
cortexr: Implemented a mechanism for writing coprocessor registers
dragonmux Aug 9, 2023
dec1369
cortexr: Implemented support for checking if a device implements hard…
dragonmux Aug 9, 2023
6c61ec0
cortexr: Added a post-probe message for reporting unknown devices
dragonmux Aug 9, 2023
dbc7232
cortexr: Added some documentation on where and how to find the archit…
dragonmux Aug 9, 2023
581cc45
cortexr: Handle when the core has a floating point unit
dragonmux Aug 9, 2023
1ce2887
cortexr: Read out and decode the number of breakpoints and watchpoint…
dragonmux Aug 9, 2023
ef77c48
cortexr: Implemented readout and decoding of the processor cache info…
dragonmux Aug 10, 2023
212d54b
cortexr: Implemented support for halting the target core
dragonmux Aug 10, 2023
c2e3b4c
cortexr: Implemented handling for polling if the core is halted and why
dragonmux Aug 10, 2023
a69408d
cortexr: Implemented support for resuming the target core
dragonmux Aug 10, 2023
1ac620e
cortexr: Implemented core halting prior to executing coprocessor inst…
dragonmux Aug 10, 2023
9c782fb
cortexr: Implemented a save/restore mechanism for r0-r15 + CPSR
dragonmux Aug 11, 2023
5a6dec3
cortexr: Implemented a save/restore mechanism for d0-d15 + FPSCR
dragonmux Aug 11, 2023
485e86a
cortexr: Implemented save/restore for the SPSRs
dragonmux Aug 11, 2023
d5666cd
cortexr: Tidied up the register save/restore code to properly abstrac…
dragonmux Aug 11, 2023
1a57878
cortexr: Implemented support for building the XML target description …
dragonmux Aug 14, 2023
dd9d021
cortexr: Implemented support for building the XML target description …
dragonmux Aug 14, 2023
b59c5b4
cortexr: Implemented cortexr_regs_{read,write} based atop the save/re…
dragonmux Aug 11, 2023
6d4e0fc
cortexr: Refactored the breakpoint and watchpoint definitions into th…
dragonmux Aug 12, 2023
02f6ddd
cortexr: Implemented attach
dragonmux Aug 12, 2023
3379fd3
cortexr: Implemented detach
dragonmux Aug 13, 2023
0b22190
cortexr: Implemented single register IO
dragonmux Aug 14, 2023
bf691ed
cortexr: Implemented support for hardware breakpoints
dragonmux Sep 29, 2023
1afefa7
cortexr: Implemented support for single-stepping the core
dragonmux Sep 29, 2023
b4aacb1
cortexr: Enable halting debug mode when the processor halts
dragonmux Sep 29, 2023
290a5c7
cortexr: Refactored out the breakpoint setup logic into its own function
dragonmux Sep 29, 2023
74c8723
cortexr: Implemented handling for ARM vs Thumb breakpoints
dragonmux Sep 30, 2023
85dbcdd
cortexr: Implemented support for watchpoints
dragonmux Sep 30, 2023
706fd85
cortexr: Implemented handling for disabling interrupts during single …
dragonmux Oct 7, 2023
c6c78fb
cortexr: Implemented readout of the processor features to check for t…
dragonmux Oct 7, 2023
465d77e
cortexr: Implemented readout of the memory model to configure how we …
dragonmux Oct 7, 2023
f0f40ba
cortexr: Implemented extremely basic support for handling watchpoints…
dragonmux Oct 9, 2023
bfafbc1
cortexr: Reordered some of the target structure initialisation so thi…
dragonmux Oct 9, 2023
a97666b
cortexr: Implemented handling for when an instruction launch that rea…
dragonmux Oct 10, 2023
dcae3fc
cortexr: Began overhauling `cortexr_mem_read()` to support reading me…
dragonmux Oct 10, 2023
1466d6d
cortexr: Implemented an error reporting mechanism for data and MMU fa…
dragonmux Oct 10, 2023
dff4825
cortexr: Implemented fault handling for `cortexr_mem_read()` to clean…
dragonmux Oct 10, 2023
006002a
cortexr: Implemented a slow path memory reader for `cortexr_mem_read()`
dragonmux Oct 11, 2023
79d3044
cortexr: Added fault handling for `cortexr_run_insn()`
dragonmux Oct 11, 2023
a59ca06
cortexr: Implemented fault handling for `cortexr_mem_read_slow()` to …
dragonmux Oct 11, 2023
0d568fe
cortexr: Refactored out the data fault post-processing from `cortexr_…
dragonmux Oct 11, 2023
4ca538f
cortexr: Implemented handling for when an instruction launch that wri…
dragonmux Oct 11, 2023
564e48d
cortexr: Began overhauling `cortexr_mem_write()` to support writing m…
dragonmux Oct 11, 2023
a5f7eeb
cortexr: Implemented a slow path memory writer for `cortexr_mem_write()`
dragonmux Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PROBE_HOST ?= native
PLATFORM_DIR = platforms/$(PROBE_HOST)
VPATH += $(PLATFORM_DIR) target
ENABLE_DEBUG ?=
ENABLE_DEBUG ?= 0
ENABLE_CORTEXR ?= 0

SYS = $(shell $(CC) -dumpmachine)

Expand Down Expand Up @@ -89,6 +90,11 @@ ifeq (,$(filter all_platforms,$(MAKECMDGOALS)))
include $(PLATFORM_DIR)/Makefile.inc
endif

ifeq ($(ENABLE_CORTEXR), 1)
CFLAGS += -DENABLE_CORTEXR
SRC += cortexr.c
endif

ifneq ($(PC_HOSTED),1)
# Output memory usage information
LDFLAGS += -Wl,--print-memory-usage
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/hosted/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ SYS := $(shell $(CC) -dumpmachine)
CFLAGS += -DENABLE_DEBUG -DPLATFORM_HAS_DEBUG
CFLAGS +=-I ./target

ENABLE_CORTEXR := 1

# Clang requires some special handling here: -gnu means MinGW
# while -msvc means Clang/CL. We don't currently support the latter
# and we need the former to fit the formula of `x86_64-w64-mingw32`
Expand Down
7 changes: 6 additions & 1 deletion src/target/adiv5.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef enum arm_arch {
aa_nosupport,
aa_cortexm,
aa_cortexa,
aa_cortexr,
aa_end
} arm_arch_e;

Expand Down Expand Up @@ -243,7 +244,7 @@ static const struct {
{0xc08, 0x00, 0, aa_cortexa, cidc_dc, ARM_COMPONENT_STR("Cortex-A8 Debug", "(Debug Unit)")},
{0xc09, 0x00, 0, aa_cortexa, cidc_dc, ARM_COMPONENT_STR("Cortex-A9 Debug", "(Debug Unit)")},
{0xc0f, 0x00, 0, aa_nosupport, cidc_unknown, ARM_COMPONENT_STR("Cortex-A15 Debug", "(Debug Unit)")}, /* support? */
{0xc14, 0x00, 0, aa_nosupport, cidc_unknown, ARM_COMPONENT_STR("Cortex-R4 Debug", "(Debug Unit)")}, /* support? */
{0xc14, 0x15, 0, aa_cortexr, cidc_unknown, ARM_COMPONENT_STR("Cortex-R4", "(Debug Unit)")},
{0xcd0, 0x00, 0, aa_nosupport, cidc_unknown, ARM_COMPONENT_STR("Atmel DSU", "(Device Service Unit)")},
{0xd20, 0x00, 0x2a04, aa_cortexm, cidc_gipc, ARM_COMPONENT_STR("Cortex-M23", "(System Control Space)")},
{0xd20, 0x11, 0, aa_nosupport, cidc_dc, ARM_COMPONENT_STR("Cortex-M23", "(Trace Port Interface Unit)")},
Expand Down Expand Up @@ -687,6 +688,10 @@ static void adiv5_component_probe(
DEBUG_INFO("%s-> cortexa_probe\n", indent + 1);
cortexa_probe(ap, addr);
break;
case aa_cortexr:
DEBUG_INFO("%s-> cortexr_probe\n", indent + 1);
cortexr_probe(ap, addr);
break;
default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions src/target/cortex.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ void cortex_read_cpuid(target_s *target)
case CORTEX_A9:
target->core = "A9";
break;
case CORTEX_R4:
target->core = "R4";
break;
case CORTEX_R5:
target->core = "R5";
break;
case STAR_MC1:
target->core = "STAR-MC1";
break;
Expand Down
5 changes: 5 additions & 0 deletions src/target/cortex.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#define CORTEX_M33 0xd210U
#define STAR_MC1 0x1320U

/* Cortex-R CPU IDs */
#define CORTEX_R4 0xc140U
#define CORTEX_R5 0xc150U

/* Cortex-A CPU IDs */
#define CORTEX_A5 0xc050U
#define CORTEX_A7 0xc070U
Expand All @@ -65,6 +69,7 @@
#define CORTEX_REG_MSP 17U
#define CORTEX_REG_PSP 18U
#define CORTEX_REG_SPECIAL 19U
#define CORTEX_REG_FPCSR 49U

#define CORTEX_CPUID_PARTNO_MASK 0xfff0U
#define CORTEX_CPUID_REVISION_MASK 0x00f00000U
Expand Down
Loading