b57361f88254a4b3fe17ed67d5ce66bc13e4f94f
[fw/openocd] / src / target / aarch64.h
1 /***************************************************************************
2  *   Copyright (C) 2015 by David Ung                                       *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  ***************************************************************************/
18
19 #ifndef OPENOCD_TARGET_AARCH64_H
20 #define OPENOCD_TARGET_AARCH64_H
21
22 #include "armv8.h"
23
24 #define AARCH64_COMMON_MAGIC 0x411fc082
25
26 #define CPUDBG_CPUID    0xD00
27 #define CPUDBG_CTYPR    0xD04
28 #define CPUDBG_TTYPR    0xD0C
29 #define ID_AA64PFR0_EL1 0xD20
30 #define ID_AA64DFR0_EL1 0xD28
31 #define CPUDBG_LOCKACCESS 0xFB0
32 #define CPUDBG_LOCKSTATUS 0xFB4
33
34 #define BRP_NORMAL 0
35 #define BRP_CONTEXT 1
36
37 #define AARCH64_PADDRDBG_CPU_SHIFT 13
38
39 enum aarch64_isrmasking_mode {
40         AARCH64_ISRMASK_OFF,
41         AARCH64_ISRMASK_ON,
42 };
43
44 struct aarch64_brp {
45         int used;
46         int type;
47         target_addr_t value;
48         uint32_t control;
49         uint8_t brpn;
50 };
51
52 struct aarch64_common {
53         int common_magic;
54
55         /* Context information */
56         uint32_t system_control_reg;
57         uint32_t system_control_reg_curr;
58
59         /* Breakpoint register pairs */
60         int brp_num_context;
61         int brp_num;
62         int brp_num_available;
63         struct aarch64_brp *brp_list;
64
65         /* Watchpoint register pairs */
66         int wp_num;
67         int wp_num_available;
68         struct aarch64_brp *wp_list;
69
70         struct armv8_common armv8_common;
71
72         enum aarch64_isrmasking_mode isrmasking_mode;
73 };
74
75 static inline struct aarch64_common *
76 target_to_aarch64(struct target *target)
77 {
78         return container_of(target->arch_info, struct aarch64_common, armv8_common.arm);
79 }
80
81 #endif /* OPENOCD_TARGET_AARCH64_H */