]> git.sur5r.net Git - openocd/blob - src/target/dsp563xx_once.c
target: add basic dsp563xx support
[openocd] / src / target / dsp563xx_once.c
1 /***************************************************************************
2  *   Copyright (C) 2009 by Mathias Kuester                                 *
3  *   mkdorg@users.sourceforge.net                                          *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <helper/jim.h>
25
26 #include "target.h"
27 #include "target_type.h"
28 #include "register.h"
29 #include "dsp563xx.h"
30 #include "dsp563xx_once.h"
31
32 /** single word instruction */
33 int dsp563xx_once_ir_exec(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
34                           uint8_t go, uint8_t ex)
35 {
36         dsp563xx_write_dr_u8(tap, 0,
37                              instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
38         dsp563xx_execute_queue();
39
40         return ERROR_OK;
41 }
42
43 /** single word instruction */
44 int dsp563xx_once_ir_exec_nq(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
45                              uint8_t go, uint8_t ex)
46 {
47         dsp563xx_write_dr_u8(tap, 0,
48                              instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
49
50         return ERROR_OK;
51 }
52
53 /** once read register */
54 int dsp563xx_once_reg_read(struct jtag_tap *tap, uint8_t reg, uint32_t * data)
55 {
56         uint32_t dr_in;
57
58         dr_in = 0;
59
60         dsp563xx_once_ir_exec(tap, reg, 1, 0, 0);
61         dsp563xx_write_dr_u32(tap, &dr_in, 0x00, 24, 0);
62         dsp563xx_execute_queue();
63
64         *data = dr_in;
65
66         return ERROR_OK;
67 }
68
69 /** once write register */
70 int dsp563xx_once_reg_write(struct jtag_tap *tap, uint8_t reg, uint32_t data)
71 {
72         dsp563xx_once_ir_exec(tap, reg, 0, 0, 0);
73         dsp563xx_write_dr_u32(tap, 0x00, data, 24, 0);
74         dsp563xx_execute_queue();
75
76         return ERROR_OK;
77 }
78
79 /** single word instruction */
80 int dsp563xx_once_execute_sw_ir(struct jtag_tap *tap, uint32_t opcode)
81 {
82         dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
83         dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
84         dsp563xx_execute_queue();
85
86         return ERROR_OK;
87 }
88
89 /** double word instruction */
90 int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
91                                 uint32_t operand)
92 {
93         dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
94         dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
95         dsp563xx_execute_queue();
96
97         dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
98         dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
99         dsp563xx_execute_queue();
100
101         return ERROR_OK;
102 }
103
104 /** single word instruction */
105 int dsp563xx_once_execute_sw_ir_nq(struct jtag_tap *tap, uint32_t opcode)
106 {
107         dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
108         dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
109
110         return ERROR_OK;
111 }
112
113 /** double word instruction */
114 int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode,
115                                    uint32_t operand)
116 {
117         dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
118         dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
119
120         dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
121         dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
122
123         return ERROR_OK;
124 }