arm_adi_v5: replace dap_lookup_cs_component()
[openocd.git] / src / target / aarch64.c
index d11fd943bd1b9354acb5cd2c880093a205f552b2..d8a9664d72bf9bd4fee86b2e70b098f237fd9a9a 100644 (file)
@@ -333,15 +333,14 @@ static int aarch64_wait_halt_one(struct target *target)
 static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, struct target **p_first)
 {
        int retval = ERROR_OK;
-       struct target_list *head = target->head;
+       struct target_list *head;
        struct target *first = NULL;
 
        LOG_DEBUG("target %s exc %i", target_name(target), exc_target);
 
-       while (head) {
+       foreach_smp_target(head, target->smp_targets) {
                struct target *curr = head->target;
                struct armv8_common *armv8 = target_to_armv8(curr);
-               head = head->next;
 
                if (exc_target && curr == target)
                        continue;
@@ -430,7 +429,7 @@ static int aarch64_halt_smp(struct target *target, bool exc_target)
                struct target_list *head;
                struct target *curr;
 
-               foreach_smp_target(head, target->head) {
+               foreach_smp_target(head, target->smp_targets) {
                        int halted;
 
                        curr = head->target;
@@ -480,7 +479,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
        }
 
        /* poll all targets in the group, but skip the target that serves GDB */
-       foreach_smp_target(head, target->head) {
+       foreach_smp_target(head, target->smp_targets) {
                curr = head->target;
                /* skip calling context */
                if (curr == target)
@@ -745,7 +744,7 @@ static int aarch64_prep_restart_smp(struct target *target, int handle_breakpoint
        struct target *first = NULL;
        uint64_t address;
 
-       foreach_smp_target(head, target->head) {
+       foreach_smp_target(head, target->smp_targets) {
                struct target *curr = head->target;
 
                /* skip calling target */
@@ -800,7 +799,7 @@ static int aarch64_step_restart_smp(struct target *target)
                struct target *curr = target;
                bool all_resumed = true;
 
-               foreach_smp_target(head, target->head) {
+               foreach_smp_target(head, target->smp_targets) {
                        uint32_t prsr;
                        int resumed;
 
@@ -888,7 +887,7 @@ static int aarch64_resume(struct target *target, int current,
                        struct target_list *head;
                        bool all_resumed = true;
 
-                       foreach_smp_target(head, target->head) {
+                       foreach_smp_target(head, target->smp_targets) {
                                uint32_t prsr;
                                int resumed;
 
@@ -1237,7 +1236,7 @@ static int aarch64_set_breakpoint(struct target *target,
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *brp_list = aarch64->brp_list;
 
-       if (breakpoint->set) {
+       if (breakpoint->is_set) {
                LOG_WARNING("breakpoint already set");
                return ERROR_OK;
        }
@@ -1250,7 +1249,7 @@ static int aarch64_set_breakpoint(struct target *target,
                        LOG_ERROR("ERROR Can not find free Breakpoint Register Pair");
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
-               breakpoint->set = brp_i + 1;
+               breakpoint_hw_set(breakpoint, brp_i);
                if (breakpoint->length == 2)
                        byte_addr_select = (3 << (breakpoint->address & 0x02));
                control = ((matchmode & 0x7) << 20)
@@ -1334,7 +1333,7 @@ static int aarch64_set_breakpoint(struct target *target,
                                breakpoint->address & 0xFFFFFFFFFFFFFFFE,
                                breakpoint->length);
 
-               breakpoint->set = 0x11; /* Any nice value but 0 */
+               breakpoint->is_set = true;
        }
 
        /* Ensure that halting debug mode is enable */
@@ -1358,7 +1357,7 @@ static int aarch64_set_context_breakpoint(struct target *target,
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *brp_list = aarch64->brp_list;
 
-       if (breakpoint->set) {
+       if (breakpoint->is_set) {
                LOG_WARNING("breakpoint already set");
                return retval;
        }
@@ -1372,7 +1371,7 @@ static int aarch64_set_context_breakpoint(struct target *target,
                return ERROR_FAIL;
        }
 
-       breakpoint->set = brp_i + 1;
+       breakpoint_hw_set(breakpoint, brp_i);
        control = ((matchmode & 0x7) << 20)
                | (1 << 13)
                | (byte_addr_select << 5)
@@ -1411,7 +1410,7 @@ static int aarch64_set_hybrid_breakpoint(struct target *target, struct breakpoin
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *brp_list = aarch64->brp_list;
 
-       if (breakpoint->set) {
+       if (breakpoint->is_set) {
                LOG_WARNING("breakpoint already set");
                return retval;
        }
@@ -1436,7 +1435,7 @@ static int aarch64_set_hybrid_breakpoint(struct target *target, struct breakpoin
                return ERROR_FAIL;
        }
 
-       breakpoint->set = brp_1 + 1;
+       breakpoint_hw_set(breakpoint, brp_1);
        breakpoint->linked_brp = brp_2;
        control_ctx = ((ctx_machmode & 0x7) << 20)
                | (brp_2 << 16)
@@ -1491,16 +1490,16 @@ static int aarch64_unset_breakpoint(struct target *target, struct breakpoint *br
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *brp_list = aarch64->brp_list;
 
-       if (!breakpoint->set) {
+       if (!breakpoint->is_set) {
                LOG_WARNING("breakpoint not set");
                return ERROR_OK;
        }
 
        if (breakpoint->type == BKPT_HARD) {
                if ((breakpoint->address != 0) && (breakpoint->asid != 0)) {
-                       int brp_i = breakpoint->set - 1;
+                       int brp_i = breakpoint->number;
                        int brp_j = breakpoint->linked_brp;
-                       if ((brp_i < 0) || (brp_i >= aarch64->brp_num)) {
+                       if (brp_i >= aarch64->brp_num) {
                                LOG_DEBUG("Invalid BRP number in breakpoint");
                                return ERROR_OK;
                        }
@@ -1550,12 +1549,12 @@ static int aarch64_unset_breakpoint(struct target *target, struct breakpoint *br
                                return retval;
 
                        breakpoint->linked_brp = 0;
-                       breakpoint->set = 0;
+                       breakpoint->is_set = false;
                        return ERROR_OK;
 
                } else {
-                       int brp_i = breakpoint->set - 1;
-                       if ((brp_i < 0) || (brp_i >= aarch64->brp_num)) {
+                       int brp_i = breakpoint->number;
+                       if (brp_i >= aarch64->brp_num) {
                                LOG_DEBUG("Invalid BRP number in breakpoint");
                                return ERROR_OK;
                        }
@@ -1580,7 +1579,7 @@ static int aarch64_unset_breakpoint(struct target *target, struct breakpoint *br
                                        (uint32_t)brp_list[brp_i].value);
                        if (retval != ERROR_OK)
                                return retval;
-                       breakpoint->set = 0;
+                       breakpoint->is_set = false;
                        return ERROR_OK;
                }
        } else {
@@ -1612,7 +1611,7 @@ static int aarch64_unset_breakpoint(struct target *target, struct breakpoint *br
                                breakpoint->address & 0xFFFFFFFFFFFFFFFE,
                                breakpoint->length);
        }
-       breakpoint->set = 0;
+       breakpoint->is_set = false;
 
        return ERROR_OK;
 }
@@ -1677,7 +1676,7 @@ static int aarch64_remove_breakpoint(struct target *target, struct breakpoint *b
        }
 #endif
 
-       if (breakpoint->set) {
+       if (breakpoint->is_set) {
                aarch64_unset_breakpoint(target, breakpoint);
                if (breakpoint->type == BKPT_HARD)
                        aarch64->brp_num_available++;
@@ -1697,7 +1696,7 @@ static int aarch64_set_watchpoint(struct target *target,
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *wp_list = aarch64->wp_list;
 
-       if (watchpoint->set) {
+       if (watchpoint->is_set) {
                LOG_WARNING("watchpoint already set");
                return ERROR_OK;
        }
@@ -1765,7 +1764,7 @@ static int aarch64_set_watchpoint(struct target *target,
        }
 
        wp_list[wp_i].used = 1;
-       watchpoint->set = wp_i + 1;
+       watchpoint_set(watchpoint, wp_i);
 
        return ERROR_OK;
 }
@@ -1774,18 +1773,18 @@ static int aarch64_set_watchpoint(struct target *target,
 static int aarch64_unset_watchpoint(struct target *target,
        struct watchpoint *watchpoint)
 {
-       int retval, wp_i;
+       int retval;
        struct aarch64_common *aarch64 = target_to_aarch64(target);
        struct armv8_common *armv8 = &aarch64->armv8_common;
        struct aarch64_brp *wp_list = aarch64->wp_list;
 
-       if (!watchpoint->set) {
+       if (!watchpoint->is_set) {
                LOG_WARNING("watchpoint not set");
                return ERROR_OK;
        }
 
-       wp_i = watchpoint->set - 1;
-       if ((wp_i < 0) || (wp_i >= aarch64->wp_num)) {
+       int wp_i = watchpoint->number;
+       if (wp_i >= aarch64->wp_num) {
                LOG_DEBUG("Invalid WP number in watchpoint");
                return ERROR_OK;
        }
@@ -1810,7 +1809,7 @@ static int aarch64_unset_watchpoint(struct target *target,
                        (uint32_t)wp_list[wp_i].value);
        if (retval != ERROR_OK)
                return retval;
-       watchpoint->set = 0;
+       watchpoint->is_set = false;
 
        return ERROR_OK;
 }
@@ -1838,7 +1837,7 @@ static int aarch64_remove_watchpoint(struct target *target,
 {
        struct aarch64_common *aarch64 = target_to_aarch64(target);
 
-       if (watchpoint->set) {
+       if (watchpoint->is_set) {
                aarch64_unset_watchpoint(target, watchpoint);
                aarch64->wp_num_available++;
        }
@@ -2575,20 +2574,13 @@ static int aarch64_examine_first(struct target *target)
        armv8->debug_ap->memaccess_tck = 10;
 
        if (!target->dbgbase_set) {
-               target_addr_t dbgbase;
-               /* Get ROM Table base */
-               uint32_t apid;
-               int32_t coreidx = target->coreid;
-               retval = dap_get_debugbase(armv8->debug_ap, &dbgbase, &apid);
-               if (retval != ERROR_OK)
-                       return retval;
                /* Lookup Processor DAP */
-               retval = dap_lookup_cs_component(armv8->debug_ap, dbgbase, ARM_CS_C9_DEVTYPE_CORE_DEBUG,
-                               &armv8->debug_base, &coreidx);
+               retval = dap_lookup_cs_component(armv8->debug_ap, ARM_CS_C9_DEVTYPE_CORE_DEBUG,
+                               &armv8->debug_base, target->coreid);
                if (retval != ERROR_OK)
                        return retval;
-               LOG_DEBUG("Detected core %" PRId32 " dbgbase: " TARGET_ADDR_FMT
-                               " apid: %08" PRIx32, coreidx, armv8->debug_base, apid);
+               LOG_DEBUG("Detected core %" PRId32 " dbgbase: " TARGET_ADDR_FMT,
+                               target->coreid, armv8->debug_base);
        } else
                armv8->debug_base = target->dbgbase;
 

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)