target/mips: Use 'bool' data type
[openocd.git] / src / target / avr32_regs.c
1 /***************************************************************************
2 * Copyright (C) 2010 by Oleksandr Tymoshenko <gonzo@bluezbox.com> *
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, see <http://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include "target.h"
23 #include "jtag/jtag.h"
24 #include "avr32_jtag.h"
25 #include "avr32_regs.h"
26
27 static int avr32_jtag_read_reg(struct avr32_jtag *jtag_info, int reg,
28 uint32_t *val)
29 {
30 int retval;
31 uint32_t dcsr;
32
33 retval = avr32_jtag_exec(jtag_info, MTDR(AVR32_OCDREG_DCCPU, reg));
34 if (retval != ERROR_OK)
35 return retval;
36
37 do {
38 retval = avr32_jtag_nexus_read(jtag_info,
39 AVR32_OCDREG_DCSR, &dcsr);
40
41 if (retval != ERROR_OK)
42 return retval;
43 } while (!(dcsr & OCDREG_DCSR_CPUD));
44
45 retval = avr32_jtag_nexus_read(jtag_info,
46 AVR32_OCDREG_DCCPU, val);
47
48 return retval;
49 }
50
51 static int avr32_jtag_write_reg(struct avr32_jtag *jtag_info, int reg,
52 uint32_t val)
53 {
54 int retval;
55 uint32_t dcsr;
56
57 /* Restore Status reg */
58 retval = avr32_jtag_nexus_write(jtag_info,
59 AVR32_OCDREG_DCEMU, val);
60 if (retval != ERROR_OK)
61 return retval;
62
63 retval = avr32_jtag_exec(jtag_info, MFDR(reg, AVR32_OCDREG_DCEMU));
64 if (retval != ERROR_OK)
65 return retval;
66 do {
67 retval = avr32_jtag_nexus_read(jtag_info,
68 AVR32_OCDREG_DCSR, &dcsr);
69 } while (!(dcsr & OCDREG_DCSR_EMUD) && (retval == ERROR_OK));
70
71 return retval;
72 }
73
74
75
76 int avr32_jtag_read_regs(struct avr32_jtag *jtag_info, uint32_t *regs)
77 {
78 int i, retval;
79
80 /* read core registers */
81 for (i = 0; i < AVR32NUMCOREREGS - 1; i++)
82 avr32_jtag_read_reg(jtag_info, i, regs + i);
83
84 /* read status register */
85 retval = avr32_jtag_exec(jtag_info, MFSR(0, 0));
86 if (retval != ERROR_OK)
87 return retval;
88
89 retval = avr32_jtag_read_reg(jtag_info, 0, regs + AVR32_REG_SR);
90
91 return retval;
92 }
93
94 int avr32_jtag_write_regs(struct avr32_jtag *jtag_info, uint32_t *regs)
95 {
96 int i, retval;
97
98 retval = avr32_jtag_write_reg(jtag_info, 0, regs[AVR32_REG_SR]);
99 if (retval != ERROR_OK)
100 return retval;
101
102 /* Restore Status reg */
103 retval = avr32_jtag_exec(jtag_info, MTSR(0, 0));
104 if (retval != ERROR_OK)
105 return retval;
106
107 /*
108 * And now the rest of registers
109 */
110 for (i = 0; i < AVR32NUMCOREREGS - 1; i++)
111 avr32_jtag_write_reg(jtag_info, i, regs[i]);
112
113 return ERROR_OK;
114 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)