summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShell <[email protected]>2024-03-22 10:20:14 +0800
committerMeco Man <[email protected]>2024-03-22 18:52:35 -0400
commit22106bb8de655148be8367ac2609582280977ca3 (patch)
tree52028f35ed94542aa00d291dcc7f4072a6f2029c
parent881c81043d40dcbd1f6f43d211ac68ac66132fa0 (diff)
[finsh] feat: add finsh thread entry hook
Signed-off-by: Shell <[email protected]>
-rw-r--r--components/finsh/shell.c18
-rw-r--r--components/finsh/shell.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 0b17a75f00..b21b314525 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -448,10 +448,28 @@ static void shell_push_history(struct finsh_shell *shell)
}
#endif
+#ifdef RT_USING_HOOK
+static void (*_finsh_thread_entry_hook)(void);
+
+/**
+ * @ingroup finsh
+ *
+ * @brief This function set a hook function at the entry of finsh thread
+ *
+ * @param hook the function point to be called
+ */
+void finsh_thread_entry_sethook(void (*hook)(void))
+{
+ _finsh_thread_entry_hook = hook;
+}
+#endif /* RT_USING_HOOK */
+
static void finsh_thread_entry(void *parameter)
{
int ch;
+ RT_OBJECT_HOOK_CALL(_finsh_thread_entry_hook, ());
+
/* normal is echo mode */
#ifndef FINSH_ECHO_DISABLE_DEFAULT
shell->echo_mode = 1;
diff --git a/components/finsh/shell.h b/components/finsh/shell.h
index a74f4dad05..db4a77d556 100644
--- a/components/finsh/shell.h
+++ b/components/finsh/shell.h
@@ -102,4 +102,8 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode);
const char *finsh_get_password(void);
#endif
+#ifdef RT_USING_HOOK
+void finsh_thread_entry_sethook(void (*hook)(void));
+#endif /* RT_USING_HOOK */
+
#endif