mips32: add per-cpu quirks feature

Introduce the ability to detect CPUs based on CP0 PRId register and
apply cpu specific quirks, which alter the default ejtag behavior.

First of those is EJTAG_QUIRK_PAD_DRET, which makes sure extra NOPs are
placed after the DRET instruction on exit from debug mode. This fixes
resume behavior on Ingenic JZ4780 SoC.

The proper detection of some (currently unsupported) CPUs becomes quite
complicated, so please consult the following Linux kernel code when
adding new CPUs:
* arch/mips/include/asm/cpu.h
* arch/mips/kernel/cpu-probe.c

Change-Id: I0f413d5096cd43ef346b02cea85024985b7face6
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/7859
Tested-by: jenkins
This commit is contained in:
Artur Rojek
2023-08-13 16:47:28 +02:00
committed by Antonio Borneo
parent 74325dc73d
commit 3b38226370
6 changed files with 104 additions and 1 deletions

View File

@@ -13,6 +13,8 @@
#ifndef OPENOCD_TARGET_MIPS32_H
#define OPENOCD_TARGET_MIPS32_H
#include <helper/bits.h>
#include "target.h"
#include "mips32_pracc.h"
@@ -55,6 +57,9 @@
#define MIPS32_SCAN_DELAY_LEGACY_MODE 2000000
/* Insert extra NOPs after the DRET instruction on exit from debug. */
#define EJTAG_QUIRK_PAD_DRET BIT(0)
/* offsets into mips32 core register cache */
enum {
MIPS32_PC = 37,
@@ -91,6 +96,11 @@ struct mips32_common {
enum mips32_isa_mode isa_mode;
enum mips32_isa_imp isa_imp;
/* processor identification register */
uint32_t prid;
/* CPU specific quirks */
uint32_t cpu_quirks;
/* working area for fastdata access */
struct working_area *fast_data_area;
@@ -408,6 +418,8 @@ int mips32_enable_interrupts(struct target *target, int enable);
int mips32_examine(struct target *target);
int mips32_cpu_probe(struct target *target);
int mips32_read_config_regs(struct target *target);
int mips32_register_commands(struct command_context *cmd_ctx);