MCPcopy Create free account
hub / github.com/HelenOS/helenos / cmd_register

Function cmd_register

kernel/generic/src/console/kconsole.c:113–155  ·  view source on GitHub ↗

Register kconsole command. * * @param cmd Structure describing the command. * * @return False on failure, true on success. * */

Source from the content-addressed store, hash-verified

111 *
112 */
113bool cmd_register(cmd_info_t *cmd)
114{
115 spinlock_lock(&cmd_lock);
116
117 /*
118 * Make sure the command is not already listed.
119 */
120 list_foreach(cmd_list, link, cmd_info_t, hlp) {
121 if (hlp == cmd) {
122 /* The command is already there. */
123 spinlock_unlock(&cmd_lock);
124 return false;
125 }
126
127 /* Avoid deadlock. */
128 if (hlp < cmd) {
129 spinlock_lock(&hlp->lock);
130 spinlock_lock(&cmd->lock);
131 } else {
132 spinlock_lock(&cmd->lock);
133 spinlock_lock(&hlp->lock);
134 }
135
136 if (str_cmp(hlp->name, cmd->name) == 0) {
137 /* The command is already there. */
138 spinlock_unlock(&hlp->lock);
139 spinlock_unlock(&cmd->lock);
140 spinlock_unlock(&cmd_lock);
141 return false;
142 }
143
144 spinlock_unlock(&hlp->lock);
145 spinlock_unlock(&cmd->lock);
146 }
147
148 /*
149 * Now the command can be added.
150 */
151 list_append(&cmd->link, &cmd_list);
152
153 spinlock_unlock(&cmd_lock);
154 return true;
155}
156
157/** Print count times a character */
158_NO_TRACE static void print_cc(char32_t ch, size_t count)

Callers 3

debugger_initFunction · 0.85
cmd_initFunction · 0.85
exc_initFunction · 0.85

Calls 4

spinlock_lockFunction · 0.85
spinlock_unlockFunction · 0.85
str_cmpFunction · 0.50
list_appendFunction · 0.50

Tested by

no test coverage detected