aboutsummaryrefslogtreecommitdiff
path: root/kernel/include/test/kshell/kshell.h
blob: 9baf4f517667499a51412c0352c06601fc285828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);