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
53
54
55
56
57
58
59
60
61
|
#pragma once
#include "test/kshell/kshell.h"
/*
* When writing a kernel shell command, make sure to use the following
* I/O functions.
*
* Before VFS is not enabled, the kernel shell will use functions from
* chardev.h to get a pointer the the chardev_t struct for the TTY.
*
* When VFS is enabled, the kernel shell will use the functions from
* vfs_syscall.h to open and close the TTY and perform I/O operations
* on the TTY.
*
* If you use the functions below, this process will be completely
* transparent.
*/
/**
* Replacement for do_write.
*
* @param ksh the kshell to write to
* @param buf the buffer to write out to the kshell
* @param nbytes the maximum number of bytes to write
* @return number of bytes written on sucess and <0 on error
*/
long kshell_write(kshell_t *ksh, const void *buf, size_t nbytes);
/**
* Replacement for do_read.
*
* @param ksh the kshell to read from
* @param buf the buffer to store data read from the kshell
* @param nbytes the maximum number of bytes to read
* @param number of bytes read on success and <0 on error
*/
long kshell_read(kshell_t *ksh, void *buf, size_t nbytes);
/* Unless an error occurs, guarantees that all of buf will be
* written */
/**
* Writes a specified number of bytes from a buffer to the
* kshell. Unlike kshell_write, this function guarantees it will write
* out the desired number of bytes.
*
* @param ksh the kshell to write to
* @param buf the buffer to write out to the kshell
* @param nbytes the number of bytes to write
* @return number of bytes written on success and <0 on error
*/
long kshell_write_all(kshell_t *ksh, void *buf, size_t nbytes);
/* Replacement for printf */
/**
* Write output to a kshell according to a format string.
*
* @param ksh the kshell to write to
* @param fmt the format string
*/
void kprintf(kshell_t *ksh, const char *fmt, ...);
|