ADIv5: Implement function to lookup CoreSight component
authorMarek Vasut <marek.vasut@gmail.com>
Sun, 31 Oct 2010 06:11:47 +0000 (07:11 +0100)
committerMarek Vasut <marek.vasut@gmail.com>
Fri, 5 Nov 2010 10:25:57 +0000 (11:25 +0100)
This patch implements "dap_lookup_cs_component()", which allows to lookup CS
component by it's identification.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
src/target/arm_adi_v5.c
src/target/arm_adi_v5.h

index 4950121afaad36fc87d1291261b5bc023d26355d..81edba4e3ee91adfe9370afbbf2905f2a27f1427 100644 (file)
@@ -1062,6 +1062,47 @@ int dap_get_debugbase(struct adiv5_dap *dap, int apsel,
        return ERROR_OK;
 }
 
        return ERROR_OK;
 }
 
+int dap_lookup_cs_component(struct adiv5_dap *dap, int apsel,
+                       uint32_t dbgbase, uint8_t type, uint32_t *addr)
+{
+       uint32_t apselold;
+       uint32_t romentry, entry_offset = 0, component_base, devtype;
+       int retval = ERROR_FAIL;
+
+       if (apsel >= 256)
+               return ERROR_INVALID_ARGUMENTS;
+
+       apselold = dap->apsel;
+       dap_ap_select(dap, apsel);
+
+       do
+       {
+               retval = mem_ap_read_atomic_u32(dap, (dbgbase&0xFFFFF000) |
+                                               entry_offset, &romentry);
+               if (retval != ERROR_OK)
+                       return retval;
+
+               component_base = (dbgbase & 0xFFFFF000)
+                       + (romentry & 0xFFFFF000);
+
+               if (romentry & 0x1) {
+                       retval = mem_ap_read_atomic_u32(dap,
+                                       (component_base & 0xfffff000) | 0xfcc,
+                                       &devtype);
+                       if ((devtype & 0xff) == type) {
+                               *addr = component_base;
+                               retval = ERROR_OK;
+                               break;
+                       }
+               }
+               entry_offset += 4;
+       } while (romentry > 0);
+
+       dap_ap_select(dap, apselold);
+
+       return retval;
+}
+
 static int dap_info_command(struct command_context *cmd_ctx,
                struct adiv5_dap *dap, int apsel)
 {
 static int dap_info_command(struct command_context *cmd_ctx,
                struct adiv5_dap *dap, int apsel)
 {
index 27a2f2f8a907b7e836f5b669b1d33f4d8ee21b16..6c1808a5cb68c007fa86dd38faf5a76b41c36a85 100644 (file)
@@ -383,6 +383,10 @@ int ahbap_debugport_init(struct adiv5_dap *swjdp);
 int dap_get_debugbase(struct adiv5_dap *dap, int apsel,
                        uint32_t *dbgbase, uint32_t *apid);
 
 int dap_get_debugbase(struct adiv5_dap *dap, int apsel,
                        uint32_t *dbgbase, uint32_t *apid);
 
+/* Lookup CoreSight component */
+int dap_lookup_cs_component(struct adiv5_dap *dap, int apsel,
+                       uint32_t dbgbase, uint8_t type, uint32_t *addr);
+
 struct target;
 
 /* Put debug link into SWD mode */
 struct target;
 
 /* Put debug link into SWD mode */

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)