diff options
author | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
---|---|---|
committer | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
commit | c63f340d90800895f007de64b7d2d14624263331 (patch) | |
tree | 2c0849fa597dd6da831c8707b6f2603403778d7b /kernel/include/test/kshell/kshell.h |
Created student weenix repository
Diffstat (limited to 'kernel/include/test/kshell/kshell.h')
-rw-r--r-- | kernel/include/test/kshell/kshell.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/kernel/include/test/kshell/kshell.h b/kernel/include/test/kshell/kshell.h new file mode 100644 index 0000000..9baf4f5 --- /dev/null +++ b/kernel/include/test/kshell/kshell.h @@ -0,0 +1,52 @@ +#pragma once + +#include "types.h" + +typedef struct kshell kshell_t; + +typedef long (*kshell_cmd_func_t)(kshell_t *, size_t argc, char **argv); + +/** + * Process init function for a new kshell. + */ +void *kshell_proc_run(long tty, void *arg2); + +/** + * Adds a command to the global command table for kernel shells. + * + * Note: When writing commands for the kernel shell, you _MUST_ use + * the I/O functions from kshell_io.h instead of normal I/O + * functions. See comment in kshell_io.h for more information. + * + * @param name the name of the command. Typing this name into the + * shell will execute the command. + * @param command the command to add to the shell + * @param desc a description of the command. This is what will be + * printed by the command 'help <command>' + */ +void kshell_add_command(const char *name, kshell_cmd_func_t command, + const char *desc); + +/** + * Allocates and initializes a kshell. + * + * @param bd the byte device the kshell will read from and write to + * @return a kshell + */ +kshell_t *kshell_create(uint8_t ttyid); + +/** + * Destroys a kshell. + * + * @param ksh the kshell to destroy + */ +void kshell_destroy(kshell_t *ksh); + +/** + * Reads from the kshell's byte device and attempts to execute a + * command. + * + * @param ksh the kshell to execute commands with + * @return the number of bytes read + */ +long kshell_execute_next(kshell_t *ksh); |