jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / target / register.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
6 * *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
9 ***************************************************************************/
10
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 #include "register.h"
16 #include <helper/log.h>
17
18 /**
19 * @file
20 * Holds utilities to work with register caches.
21 *
22 * OpenOCD uses machine registers internally, and exposes them by name
23 * to Tcl scripts. Sets of related registers are grouped into caches.
24 * For example, a CPU core will expose a set of registers, and there
25 * may be separate registers associated with debug or trace modules.
26 */
27
28 struct reg *register_get_by_number(struct reg_cache *first,
29 uint32_t reg_num, bool search_all)
30 {
31 struct reg_cache *cache = first;
32
33 while (cache) {
34 for (unsigned int i = 0; i < cache->num_regs; i++) {
35 if (!cache->reg_list[i].exist)
36 continue;
37 if (cache->reg_list[i].number == reg_num)
38 return &(cache->reg_list[i]);
39 }
40
41 if (!search_all)
42 break;
43
44 cache = cache->next;
45 }
46
47 return NULL;
48 }
49
50 struct reg *register_get_by_name(struct reg_cache *first,
51 const char *name, bool search_all)
52 {
53 struct reg_cache *cache = first;
54
55 while (cache) {
56 for (unsigned int i = 0; i < cache->num_regs; i++) {
57 if (!cache->reg_list[i].exist)
58 continue;
59 if (strcmp(cache->reg_list[i].name, name) == 0)
60 return &(cache->reg_list[i]);
61 }
62
63 if (!search_all)
64 break;
65
66 cache = cache->next;
67 }
68
69 return NULL;
70 }
71
72 struct reg_cache **register_get_last_cache_p(struct reg_cache **first)
73 {
74 struct reg_cache **cache_p = first;
75
76 if (*cache_p)
77 while (*cache_p)
78 cache_p = &((*cache_p)->next);
79 else
80 return first;
81
82 return cache_p;
83 }
84
85 void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache)
86 {
87 while (*cache_p && *cache_p != cache)
88 cache_p = &((*cache_p)->next);
89 if (*cache_p)
90 *cache_p = cache->next;
91 }
92
93 /** Marks the contents of the register cache as invalid (and clean). */
94 void register_cache_invalidate(struct reg_cache *cache)
95 {
96 for (unsigned int n = 0; n < cache->num_regs; n++) {
97 struct reg *reg = &cache->reg_list[n];
98 if (!reg->exist)
99 continue;
100 reg->valid = false;
101 reg->dirty = false;
102 }
103 }
104
105 static int register_get_dummy_core_reg(struct reg *reg)
106 {
107 return ERROR_OK;
108 }
109
110 static int register_set_dummy_core_reg(struct reg *reg, uint8_t *buf)
111 {
112 reg->dirty = true;
113 reg->valid = true;
114
115 return ERROR_OK;
116 }
117
118 static const struct reg_arch_type dummy_type = {
119 .get = register_get_dummy_core_reg,
120 .set = register_set_dummy_core_reg,
121 };
122
123 void register_init_dummy(struct reg *reg)
124 {
125 reg->type = &dummy_type;
126 }

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)