drivers/ulink: Group adapter commands
[openocd.git] / src / target / armv8_dpm.h
blobc30b04ffa64736666e4ad8dc9cc41cc154f651eb
1 /*
2 * Copyright (C) 2009 by David Brownell
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef OPENOCD_TARGET_ARMV8_DPM_H
16 #define OPENOCD_TARGET_ARMV8_DPM_H
18 #include "arm_dpm.h"
19 #include "helper/bits.h"
21 /* forward-declare struct armv8_common */
22 struct armv8_common;
24 /**
25 * This wraps an implementation of DPM primitives. Each interface
26 * provider supplies a structure like this, which is the glue between
27 * upper level code and the lower level hardware access.
29 * It is a PRELIMINARY AND INCOMPLETE set of primitives, starting with
30 * support for CPU register access.
32 int armv8_dpm_setup(struct arm_dpm *dpm);
33 int armv8_dpm_initialize(struct arm_dpm *dpm);
35 int armv8_dpm_read_current_registers(struct arm_dpm *dpm);
36 int armv8_dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode);
39 int armv8_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp);
41 /* DSCR bits; see ARMv7a arch spec section C10.3.1.
42 * Not all v7 bits are valid in v6.
44 #define DSCR_DEBUG_STATUS_MASK (0x1F << 0)
45 #define DSCR_ERR (0x1 << 6)
46 #define DSCR_SYS_ERROR_PEND (0x1 << 7)
47 #define DSCR_CUR_EL (0x3 << 8)
48 #define DSCR_EL_STATUS_MASK (0xF << 10)
49 #define DSCR_HDE (0x1 << 14)
50 #define DSCR_SDD (0x1 << 16)
51 #define DSCR_NON_SECURE (0x1 << 18)
52 #define DSCR_MA (0x1 << 20)
53 #define DSCR_TDA (0x1 << 21)
54 #define DSCR_INTDIS_MASK (0x3 << 22)
55 #define DSCR_ITE (0x1 << 24)
56 #define DSCR_PIPE_ADVANCE (0x1 << 25)
57 #define DSCR_TXU (0x1 << 26)
58 #define DSCR_RTO (0x1 << 27) /* bit 28 is reserved */
59 #define DSCR_ITO (0x1 << 28)
60 #define DSCR_DTR_TX_FULL (0x1 << 29)
61 #define DSCR_DTR_RX_FULL (0x1 << 30) /* bit 31 is reserved */
65 /* Methods of entry into debug mode */
66 #define DSCRV8_ENTRY_NON_DEBUG (0x2)
67 #define DSCRV8_ENTRY_RESTARTING (0x1)
68 #define DSCRV8_ENTRY_BKPT (0x7)
69 #define DSCRV8_ENTRY_EXT_DEBUG (0x13)
70 #define DSCRV8_ENTRY_HALT_STEP_NORMAL (0x1B)
71 #define DSCRV8_ENTRY_HALT_STEP_EXECLU (0x1F)
72 #define DSCRV8_ENTRY_OS_UNLOCK (0x23)
73 #define DSCRV8_ENTRY_RESET_CATCH (0x27)
74 #define DSCRV8_ENTRY_WATCHPOINT (0x2B)
75 #define DSCRV8_ENTRY_HLT (0x2F)
76 #define DSCRV8_ENTRY_SW_ACCESS_DBG (0x33)
77 #define DSCRV8_ENTRY_EXCEPTION_CATCH (0x37)
78 #define DSCRV8_ENTRY_HALT_STEP (0x3B)
79 #define DSCRV8_HALT_MASK (0x3C)
81 /*DRCR registers*/
82 #define DRCR_CSE (1 << 2)
83 #define DRCR_CSPA (1 << 3)
84 #define DRCR_CBRRQ (1 << 4)
87 /* DTR modes */
88 #define DSCR_EXT_DCC_NON_BLOCKING (0x0 << 20)
89 #define DSCR_EXT_DCC_STALL_MODE (0x1 << 20)
90 #define DSCR_EXT_DCC_FAST_MODE (0x2 << 20) /* bits 22, 23 are reserved */
93 /* DRCR (debug run control register) bits */
94 #define DRCR_HALT (1 << 0)
95 #define DRCR_RESTART (1 << 1)
96 #define DRCR_CLEAR_EXCEPTIONS (1 << 2)
98 /* ECR (Execution Control Register) bits */
99 #define ECR_RCE BIT(1)
101 /* ESR (Event Status Register) bits */
102 #define ESR_RC BIT(1)
104 /* PRSR (processor debug status register) bits */
105 #define PRSR_PU (1 << 0)
106 #define PRSR_SPD (1 << 1)
107 #define PRSR_RESET (1 << 2)
108 #define PRSR_SR (1 << 3)
109 #define PRSR_HALT (1 << 4)
110 #define PRSR_OSLK (1 << 5)
111 #define PRSR_DLK (1 << 6)
112 #define PRSR_EDAD (1 << 7)
113 #define PRSR_SDAD (1 << 8)
114 #define PRSR_EPMAD (1 << 9)
115 #define PRSR_SPMAD (1 << 10)
116 #define PRSR_SDR (1 << 11)
118 /* PRCR (processor debug control register) bits */
119 #define PRCR_CORENPDRQ (1 << 0)
120 #define PRCR_CWRR (1 << 2)
121 #define PRCR_COREPURQ (1 << 3)
123 void armv8_dpm_report_dscr(struct arm_dpm *dpm, uint32_t dcsr);
124 void armv8_dpm_handle_exception(struct arm_dpm *dpm, bool do_restore);
125 enum arm_state armv8_dpm_get_core_state(struct arm_dpm *dpm);
127 #endif /* OPENOCD_TARGET_ARM_DPM_H */