230008a556513f6f060063bcf226df4f68368dde
[fw/openocd] / src / target / cortex_a8.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dominic Rath                                    *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   Copyright (C) 2006 by Magnus Lundin                                   *
6  *   lundin@mlu.mine.nu                                                    *
7  *                                                                         *
8  *   Copyright (C) 2008 by Spencer Oliver                                  *
9  *   spen@spen-soft.co.uk                                                  *
10  *                                                                         *
11  *   Copyright (C) 2009 by Dirk Behme                                      *
12  *   dirk.behme@gmail.com - copy from cortex_m3                            *
13  *                                                                         *
14  *   This program is free software; you can redistribute it and/or modify  *
15  *   it under the terms of the GNU General Public License as published by  *
16  *   the Free Software Foundation; either version 2 of the License, or     *
17  *   (at your option) any later version.                                   *
18  *                                                                         *
19  *   This program is distributed in the hope that it will be useful,       *
20  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
21  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
22  *   GNU General Public License for more details.                          *
23  *                                                                         *
24  *   You should have received a copy of the GNU General Public License     *
25  *   along with this program; if not, write to the                         *
26  *   Free Software Foundation, Inc.,                                       *
27  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
28  ***************************************************************************/
29 #ifndef CORTEX_A8_H
30 #define CORTEX_A8_H
31
32 #include "target.h"
33 #include "armv7a.h"
34
35 extern char* cortex_a8_state_strings[];
36
37 #define CORTEX_A8_COMMON_MAGIC 0x411fc082
38
39 #define CPUID           0x54011D00
40 /* Debug Control Block */
41 #define CPUDBG_DIDR             0x000
42 #define CPUDBG_WFAR             0x018
43 #define CPUDBG_VCR      0x01C
44 #define CPUDBG_ECR      0x024
45 #define CPUDBG_DSCCR    0x028
46 #define CPUDBG_DTRRX    0x080
47 #define CPUDBG_ITR      0x084
48 #define CPUDBG_DSCR     0x088
49 #define CPUDBG_DTRTX    0x08c
50 #define CPUDBG_DRCR     0x090
51 #define CPUDBG_BVR_BASE 0x100
52 #define CPUDBG_BCR_BASE 0x140
53 #define CPUDBG_WVR_BASE 0x180
54 #define CPUDBG_WCR_BASE 0x1C0
55
56 #define CPUDBG_OSLAR    0x300
57 #define CPUDBG_OSLSR    0x304
58 #define CPUDBG_OSSRR    0x308
59
60 #define CPUDBG_PRCR     0x310
61 #define CPUDBG_PRSR     0x314
62
63 #define CPUDBG_CPUID    0xD00
64 #define CPUDBG_CTYPR    0xD04
65 #define CPUDBG_TTYPR    0xD0C
66 #define CPUDBG_LOCKACCESS 0xFB0
67 #define CPUDBG_LOCKSTATUS 0xFB4
68 #define CPUDBG_AUTHSTATUS 0xFB8
69
70 #define BRP_NORMAL 0
71 #define BRP_CONTEXT 1
72
73 /* DSCR Bit offset */
74 #define DSCR_CORE_HALTED                0
75 #define DSCR_CORE_RESTARTED     1
76 #define DSCR_EXT_INT_EN                 13
77 #define DSCR_HALT_DBG_MODE              14
78 #define DSCR_MON_DBG_MODE               15
79 #define DSCR_INSTR_COMP                 24
80 #define DSCR_DTR_TX_FULL                29
81 #define DSCR_DTR_RX_FULL                30
82
83 struct cortex_a8_brp
84 {
85         int used;
86         int type;
87         uint32_t value;
88         uint32_t control;
89         uint8_t         BRPn;
90 };
91
92 struct cortex_a8_wrp
93 {
94         int used;
95         int type;
96         uint32_t value;
97         uint32_t control;
98         uint8_t         WRPn;
99 };
100
101 struct cortex_a8_common
102 {
103         int common_magic;
104         struct arm_jtag jtag_info;
105
106         /* Context information */
107         uint32_t cpudbg_dscr;
108         uint32_t nvic_dfsr;  /* Debug Fault Status Register - shows reason for debug halt */
109         uint32_t nvic_icsr;  /* Interrupt Control State Register - shows active and pending IRQ */
110
111         /* Saved cp15 registers */
112         uint32_t cp15_control_reg;
113         uint32_t cp15_aux_control_reg;
114
115         /* Breakpoint register pairs */
116         int brp_num_context;
117         int brp_num;
118         int brp_num_available;
119 //      int brp_enabled;
120         struct cortex_a8_brp *brp_list;
121
122         /* Watchpoint register pairs */
123         int wrp_num;
124         int wrp_num_available;
125         struct cortex_a8_wrp *wrp_list;
126
127         /* Interrupts */
128         int intlinesnum;
129         uint32_t *intsetenable;
130
131         /* Use cortex_a8_read_regs_through_mem for fast register reads */
132         int fast_reg_read;
133
134         struct armv7a_common armv7a_common;
135 };
136
137 static inline struct cortex_a8_common *
138 target_to_cortex_a8(struct target *target)
139 {
140         return container_of(target->arch_info, struct cortex_a8_common,
141                         armv7a_common.armv4_5_common);
142 }
143
144 int cortex_a8_init_arch_info(struct target *target,
145                 struct cortex_a8_common *cortex_a8, struct jtag_tap *tap);
146
147 #endif /* CORTEX_A8_H */