1 /***************************************************************************
2 * Copyright (C) 2007 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
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. *
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. *
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 ***************************************************************************/
24 #include "replacements.h"
27 #include "target_request.h"
28 #include "binarybuffer.h"
35 command_t
*target_request_cmd
= NULL
;
37 int target_asciimsg(target_t
*target
, u32 length
)
39 char *msg
= malloc(CEIL(length
+ 1, 4) * 4);
40 debug_msg_receiver_t
*c
= target
->dbgmsg
;
42 target
->type
->target_request_data(target
, CEIL(length
, 4), (u8
*)msg
);
49 command_print(c
->cmd_ctx
, "%s", msg
);
56 int target_hexmsg(target_t
*target
, int size
, u32 length
)
58 u8
*data
= malloc(CEIL(length
* size
, 4) * 4);
61 debug_msg_receiver_t
*c
= target
->dbgmsg
;
64 DEBUG("size: %i, length: %i", size
, length
);
66 target
->type
->target_request_data(target
, CEIL(length
* size
, 4), (u8
*)data
);
69 for (i
= 0; i
< length
; i
++)
74 line_len
+= snprintf(line
+ line_len
, 128 - line_len
, "%8.8x ", le_to_h_u32(data
+ (4*i
)));
77 line_len
+= snprintf(line
+ line_len
, 128 - line_len
, "%4.4x ", le_to_h_u16(data
+ (2*i
)));
80 line_len
+= snprintf(line
+ line_len
, 128 - line_len
, "%2.2x ", data
[i
]);
84 if ((i
%8 == 7) || (i
== length
- 1))
90 command_print(c
->cmd_ctx
, "%s", line
);
103 /* handle requests from the target received by a target specific
104 * side-band channel (e.g. ARM7/9 DCC)
106 int target_request(target_t
*target
, u32 request
)
108 target_req_cmd_t target_req_cmd
= request
& 0xff;
110 switch (target_req_cmd
)
112 case TARGET_REQ_TRACEMSG
:
113 trace_point(target
, (request
& 0xffffff00) >> 8);
115 case TARGET_REQ_DEBUGMSG
:
116 if (((request
& 0xff00) >> 8) == 0)
118 target_asciimsg(target
, (request
& 0xffff0000) >> 16);
122 target_hexmsg(target
, (request
& 0xff00) >> 8, (request
& 0xffff0000) >> 16);
125 /* case TARGET_REQ_SEMIHOSTING:
129 ERROR("unknown target request: %2.2x", target_req_cmd
);
136 int add_debug_msg_receiver(struct command_context_s
*cmd_ctx
, target_t
*target
)
138 debug_msg_receiver_t
**p
= &target
->dbgmsg
;
141 return ERROR_INVALID_ARGUMENTS
;
143 /* see if there's already a list */
146 /* find end of linked list */
153 /* add new debug message receiver */
154 (*p
) = malloc(sizeof(debug_msg_receiver_t
));
155 (*p
)->cmd_ctx
= cmd_ctx
;
158 /* enable callback */
159 target
->dbg_msg_enabled
= 1;
164 debug_msg_receiver_t
* find_debug_msg_receiver(struct command_context_s
*cmd_ctx
, target_t
*target
)
167 debug_msg_receiver_t
**p
= &target
->dbgmsg
;
169 /* if no target has been specified search all of them */
172 /* if no targets haven been specified */
184 if ((*p
)->cmd_ctx
== cmd_ctx
)
191 target
= target
->next
;
192 } while (target
&& all_targets
);
197 int delete_debug_msg_receiver(struct command_context_s
*cmd_ctx
, target_t
*target
)
199 debug_msg_receiver_t
**p
;
200 debug_msg_receiver_t
*c
;
203 /* if no target has been specified search all of them */
206 /* if no targets haven been specified */
220 debug_msg_receiver_t
*next
= c
->next
;
221 if (c
->cmd_ctx
== cmd_ctx
)
227 /* disable callback */
228 target
->dbg_msg_enabled
= 0;
237 target
= target
->next
;
238 } while (target
&& all_targets
);
243 int handle_target_request_debugmsgs_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
245 target_t
*target
= get_current_target(cmd_ctx
);
249 /* see if reciever is already registered */
250 if (find_debug_msg_receiver(cmd_ctx
, target
) != NULL
)
255 if (!strcmp(args
[0], "enable"))
257 /* don't register if this command context is already receiving */
261 add_debug_msg_receiver(cmd_ctx
, target
);
264 else if (!strcmp(args
[0], "disable"))
266 /* no need to delete a receiver if none is registered */
270 delete_debug_msg_receiver(cmd_ctx
, target
);
275 command_print(cmd_ctx
, "usage: target_request debugmsgs ['enable'|'disable']");
279 command_print(cmd_ctx
, "receiving debug messages from current target %s",
280 (receiving
) ? "enabled" : "disabled");
285 int target_request_register_commands(struct command_context_s
*cmd_ctx
)
288 register_command(cmd_ctx
, NULL
, "target_request", NULL
, COMMAND_ANY
, "target_request commands");
290 register_command(cmd_ctx
, target_request_cmd
, "debugmsgs", handle_target_request_debugmsgs_command
,
291 COMMAND_EXEC
, "enable/disable reception of debug messgages from target");
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)