1 /*****************************************************************************
2 * Copyright (C) 2016 by Matthias Welwarsky <matthias.welwarsky@sysgo.com> *
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. *
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 ****************************************************************************/
20 #include "target_type.h"
22 #include "arm_adi_v5.h"
24 #include <jtag/jtag.h>
32 static int mem_ap_target_create(struct target
*target
, Jim_Interp
*interp
)
34 struct mem_ap
*mem_ap
;
35 struct adiv5_private_config
*pc
;
37 pc
= (struct adiv5_private_config
*)target
->private_config
;
41 if (pc
->ap_num
== DP_APSEL_INVALID
) {
42 LOG_ERROR("AP number not specified");
46 mem_ap
= calloc(1, sizeof(struct mem_ap
));
48 LOG_ERROR("Out of memory");
52 mem_ap
->ap_num
= pc
->ap_num
;
53 mem_ap
->arm
.common_magic
= ARM_COMMON_MAGIC
;
54 mem_ap
->arm
.dap
= pc
->dap
;
56 target
->arch_info
= mem_ap
;
61 static int mem_ap_init_target(struct command_context
*cmd_ctx
, struct target
*target
)
63 LOG_DEBUG("%s", __func__
);
64 target
->state
= TARGET_UNKNOWN
;
68 static void mem_ap_deinit_target(struct target
*target
)
70 LOG_DEBUG("%s", __func__
);
72 free(target
->private_config
);
73 free(target
->arch_info
);
77 static int mem_ap_arch_state(struct target
*target
)
79 LOG_DEBUG("%s", __func__
);
83 static int mem_ap_poll(struct target
*target
)
85 if (target
->state
== TARGET_UNKNOWN
)
86 target
->state
= TARGET_RUNNING
;
91 static int mem_ap_halt(struct target
*target
)
93 LOG_DEBUG("%s", __func__
);
94 target
->state
= TARGET_HALTED
;
98 static int mem_ap_resume(struct target
*target
, int current
, target_addr_t address
,
99 int handle_breakpoints
, int debug_execution
)
101 LOG_DEBUG("%s", __func__
);
102 target
->state
= TARGET_RUNNING
;
106 static int mem_ap_step(struct target
*target
, int current
, target_addr_t address
,
107 int handle_breakpoints
)
109 LOG_DEBUG("%s", __func__
);
110 target
->state
= TARGET_HALTED
;
114 static int mem_ap_assert_reset(struct target
*target
)
116 target
->state
= TARGET_RESET
;
118 LOG_DEBUG("%s", __func__
);
122 static int mem_ap_examine(struct target
*target
)
124 struct mem_ap
*mem_ap
= target
->arch_info
;
126 if (!target_was_examined(target
)) {
127 mem_ap
->ap
= dap_ap(mem_ap
->arm
.dap
, mem_ap
->ap_num
);
128 target_set_examined(target
);
129 target
->state
= TARGET_UNKNOWN
;
130 return mem_ap_init(mem_ap
->ap
);
136 static int mem_ap_deassert_reset(struct target
*target
)
138 if (target
->reset_halt
)
139 target
->state
= TARGET_HALTED
;
141 target
->state
= TARGET_RUNNING
;
143 LOG_DEBUG("%s", __func__
);
147 static int mem_ap_read_memory(struct target
*target
, target_addr_t address
,
148 uint32_t size
, uint32_t count
, uint8_t *buffer
)
150 struct mem_ap
*mem_ap
= target
->arch_info
;
152 LOG_DEBUG("Reading memory at physical address " TARGET_ADDR_FMT
153 "; size %" PRIu32
"; count %" PRIu32
, address
, size
, count
);
155 if (count
== 0 || buffer
== NULL
)
156 return ERROR_COMMAND_SYNTAX_ERROR
;
158 return mem_ap_read_buf(mem_ap
->ap
, buffer
, size
, count
, address
);
161 static int mem_ap_write_memory(struct target
*target
, target_addr_t address
,
162 uint32_t size
, uint32_t count
,
163 const uint8_t *buffer
)
165 struct mem_ap
*mem_ap
= target
->arch_info
;
167 LOG_DEBUG("Writing memory at physical address " TARGET_ADDR_FMT
168 "; size %" PRIu32
"; count %" PRIu32
, address
, size
, count
);
170 if (count
== 0 || buffer
== NULL
)
171 return ERROR_COMMAND_SYNTAX_ERROR
;
173 return mem_ap_write_buf(mem_ap
->ap
, buffer
, size
, count
, address
);
176 struct target_type mem_ap_target
= {
179 .target_create
= mem_ap_target_create
,
180 .init_target
= mem_ap_init_target
,
181 .deinit_target
= mem_ap_deinit_target
,
182 .examine
= mem_ap_examine
,
183 .target_jim_configure
= adiv5_jim_configure
,
186 .arch_state
= mem_ap_arch_state
,
189 .resume
= mem_ap_resume
,
192 .assert_reset
= mem_ap_assert_reset
,
193 .deassert_reset
= mem_ap_deassert_reset
,
195 .read_memory
= mem_ap_read_memory
,
196 .write_memory
= mem_ap_write_memory
,
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)