28
28
*
29
29
--------------------------------------------- */
30
30
31
- /**
32
- * \file
33
- * \brief the command to access auxiliary registers
34
- */
31
+ /**
32
+ * \file
33
+ * \brief the command to access auxiliary registers
34
+ */
35
35
36
36
37
37
#include "cmds_arc_cfg.h"
@@ -64,17 +64,22 @@ static void _auxiliary_register_dump(uint32_t start_addr, uint32_t end_addr, voi
64
64
VALID_EXTOBJ_NORTN (extobj );
65
65
66
66
p = start_addr ;
67
+
67
68
while (p <= end_addr ) {
68
69
CMD_DEBUG ("0x%08x: " , p );
70
+
69
71
for (x = 0 ; x < MAXROWS ; x ++ ) {
70
72
val = _arc_aux_read (p ); /* read aux register */
71
73
CMD_DEBUG ("0x%08x " , val );
72
74
np = p + 1 ;
75
+
73
76
if (np < p ) {
74
77
brk = 1 ;
75
78
break ;
76
79
}
80
+
77
81
p = np ;
82
+
78
83
if (p > end_addr ) {
79
84
break ;
80
85
}
@@ -95,10 +100,12 @@ static void _auxiliary_register_dump(uint32_t start_addr, uint32_t end_addr, voi
95
100
static void cmd_lr_help (char * cmd_name , void * extobj )
96
101
{
97
102
VALID_EXTOBJ_NORTN (extobj );
103
+
98
104
if (cmd_name == NULL ) {
99
105
/* cmd_name not valid */
100
106
return ;
101
107
}
108
+
102
109
CMD_DEBUG ("Usage: %s [OPTION]... <ADD> <VAL> [NUM]\r\n"
103
110
"Read auxiliary register\r\n"
104
111
" -h/H/? Show the help information\r\n"
@@ -130,24 +137,28 @@ static int cmd_lr(int argc, char **argv, void *extobj)
130
137
NTSHELL_IO_GET (extobj );
131
138
132
139
/* show the help information, if the option is "-h" */
133
- if (argc == 2 && ntlibc_strcmp (argv [1 ],"-h" ) == 0x00 ) {
140
+ if (argc == 2 && ntlibc_strcmp (argv [1 ],"-h" ) == 0x00 ) {
134
141
cmd_lr_help (argv [0 ], extobj );
135
142
goto error_exit ;
136
143
}
144
+
137
145
/* the parameter checking */
138
146
if ((argc > 3 ) || (argc < 2 )) {
139
147
ercd = E_SYS ;
140
148
CMD_DEBUG ("command error!\r\n" );
141
149
CMD_DEBUG ("Try '%s -h' for more information\r\n" , argv [0 ]);
142
150
goto error_exit ;
143
151
}
152
+
144
153
argv_tp = (char * * )(& argv [1 ]);
154
+
145
155
/* parse 1th argument: start aux reg index */
146
156
if (xatoi (& argv_tp [0 ], & val )) {
147
157
start_addr = (uint32_t ) val ;
148
158
} else {
149
159
arg_err_flag = arg_err_flag | FIRST_ARG_ERR ;
150
160
}
161
+
151
162
/* parse 2nd argument: aux reg size that you want to display */
152
163
if (argc == 3 ) {
153
164
if (xatoi (& argv_tp [1 ], & val )) {
@@ -167,6 +178,7 @@ static int cmd_lr(int argc, char **argv, void *extobj)
167
178
168
179
/* calc end address */
169
180
end_addr = start_addr + size - 1 ;
181
+
170
182
if ((end_addr < start_addr ) && (size > 1 )) { /* wrap? */
171
183
end_addr = 0xfffffffc ;
172
184
}
@@ -188,10 +200,12 @@ static int cmd_lr(int argc, char **argv, void *extobj)
188
200
static void cmd_sr_help (char * cmd_name , void * extobj )
189
201
{
190
202
VALID_EXTOBJ_NORTN (extobj );
203
+
191
204
if (cmd_name == NULL ) {
192
205
/* cmd_name not valid */
193
206
return ;
194
207
}
208
+
195
209
CMD_DEBUG ("Usage: %s [OPTION]... <ADD> <VAL> [NUM]\r\n"
196
210
"Write auxiliary register\r\n"
197
211
" -h/H/? Show the help information\r\n"
@@ -220,11 +234,13 @@ static int cmd_sr(int argc, char **argv, void *extobj)
220
234
221
235
VALID_EXTOBJ (extobj , -1 );
222
236
NTSHELL_IO_GET (extobj );
237
+
223
238
/* show the help information, if the option is "-h" */
224
- if (argc == 2 && ntlibc_strcmp (argv [1 ],"-h" ) == 0x00 ) {
239
+ if (argc == 2 && ntlibc_strcmp (argv [1 ],"-h" ) == 0x00 ) {
225
240
cmd_sr_help (argv [0 ], extobj );
226
241
goto error_exit ;
227
242
}
243
+
228
244
/* the parameter checking */
229
245
if ((argc > 4 ) || (argc < 3 )) {
230
246
ercd = E_SYS ;
@@ -234,18 +250,21 @@ static int cmd_sr(int argc, char **argv, void *extobj)
234
250
}
235
251
236
252
argv_tp = (char * * )(& argv [1 ]);
253
+
237
254
/* parse 1th argument: start aux reg index */
238
255
if (xatoi (& argv_tp [0 ], & val )) {
239
256
start_addr = (uint32_t ) val ;
240
257
} else {
241
258
arg_err_flag = arg_err_flag | FIRST_ARG_ERR ;
242
259
}
260
+
243
261
/* parse 2nd argument: reg value */
244
262
if (xatoi (& argv_tp [1 ], & val )) {
245
263
reg_val = (uint32_t ) val ;
246
264
} else {
247
265
arg_err_flag = arg_err_flag | SECOND_ARG_ERR ;
248
266
}
267
+
249
268
/* parse 3rd argument: reg amount to write */
250
269
if (argc == 4 ) {
251
270
if (xatoi (& argv_tp [2 ], & val )) {
@@ -265,6 +284,7 @@ static int cmd_sr(int argc, char **argv, void *extobj)
265
284
266
285
/* calc end address */
267
286
end_addr = start_addr + size - 1 ;
287
+
268
288
if (end_addr < start_addr ) { /* wrap? */
269
289
end_addr = 0xfffffffc ;
270
290
}
@@ -292,7 +312,7 @@ static CMD_TABLE_T sr_cmd = {"sr", "Write auxiliary register", cmd_sr, NULL};
292
312
/**
293
313
* register aux register write or read command
294
314
*/
295
- CMD_TABLE_T * register_ntshell_cmd_aux (CMD_TABLE_T * prev )
315
+ CMD_TABLE_T * register_ntshell_cmd_aux (CMD_TABLE_T * prev )
296
316
{
297
317
prev = ntshell_usrcmd_register (& lr_cmd , prev );
298
318
return ntshell_usrcmd_register (& sr_cmd , prev );
0 commit comments