helper/jim-eventloop: review scope of symbols
[openocd/dnglaze.git] / src / target / dsp563xx_once.c
blob416cb6b598087aa71b5d0797960a037751f747b5
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
24 #include <helper/jim.h>
26 #include "target.h"
27 #include "target_type.h"
28 #include "register.h"
29 #include "dsp563xx.h"
30 #include "dsp563xx_once.h"
32 /** single word instruction */
33 static int dsp563xx_once_ir_exec(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
34 uint8_t go, uint8_t ex)
36 dsp563xx_write_dr_u8(tap, 0,
37 instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
38 dsp563xx_execute_queue();
40 return ERROR_OK;
43 /** single word instruction */
44 static int dsp563xx_once_ir_exec_nq(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
45 uint8_t go, uint8_t ex)
47 dsp563xx_write_dr_u8(tap, 0,
48 instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
50 return ERROR_OK;
53 /** once read register */
54 int dsp563xx_once_reg_read(struct jtag_tap *tap, uint8_t reg, uint32_t * data)
56 uint32_t dr_in;
58 dr_in = 0;
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();
64 *data = dr_in;
66 return ERROR_OK;
69 /** once write register */
70 int dsp563xx_once_reg_write(struct jtag_tap *tap, uint8_t reg, uint32_t data)
72 dsp563xx_once_ir_exec(tap, reg, 0, 0, 0);
73 dsp563xx_write_dr_u32(tap, 0x00, data, 24, 0);
74 dsp563xx_execute_queue();
76 return ERROR_OK;
79 /** single word instruction */
80 int dsp563xx_once_execute_sw_ir(struct jtag_tap *tap, uint32_t opcode)
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();
86 return ERROR_OK;
89 /** double word instruction */
90 int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
91 uint32_t operand)
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();
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();
101 return ERROR_OK;
104 /** single word instruction */
105 int dsp563xx_once_execute_sw_ir_nq(struct jtag_tap *tap, uint32_t opcode)
107 dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
108 dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
110 return ERROR_OK;
113 /** double word instruction */
114 int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode,
115 uint32_t operand)
117 dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
118 dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
120 dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
121 dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
123 return ERROR_OK;