Rev 2071 | Rev 2093 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2071 | Rev 2089 | ||
|---|---|---|---|
| Line 33... | Line 33... | ||
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| 35 | #ifndef KERN_KCONSOLE_H_ |
35 | #ifndef KERN_KCONSOLE_H_ |
| 36 | #define KERN_KCONSOLE_H_ |
36 | #define KERN_KCONSOLE_H_ |
| 37 | 37 | ||
| 38 | #include <typedefs.h> |
- | |
| 39 | #include <adt/list.h> |
38 | #include <adt/list.h> |
| 40 | #include <synch/spinlock.h> |
39 | #include <synch/spinlock.h> |
| 41 | 40 | ||
| 42 | #define MAX_CMDLINE 256 |
41 | #define MAX_CMDLINE 256 |
| 43 | #define KCONSOLE_HISTORY 10 |
42 | #define KCONSOLE_HISTORY 10 |
| 44 | 43 | ||
| 45 | enum cmd_arg_type { |
44 | typedef enum { |
| 46 | ARG_TYPE_INVALID = 0, |
45 | ARG_TYPE_INVALID = 0, |
| 47 | ARG_TYPE_INT, |
46 | ARG_TYPE_INT, |
| 48 | ARG_TYPE_STRING, |
47 | ARG_TYPE_STRING, |
| 49 | ARG_TYPE_VAR /**< Variable type - either symbol or string */ |
48 | ARG_TYPE_VAR /**< Variable type - either symbol or string */ |
| 50 | }; |
49 | } cmd_arg_type_t; |
| 51 | 50 | ||
| 52 | /** Structure representing one argument of kconsole command line. */ |
51 | /** Structure representing one argument of kconsole command line. */ |
| 53 | struct cmd_arg { |
52 | typedef struct { |
| 54 | cmd_arg_type_t type; /**< Type descriptor. */ |
53 | cmd_arg_type_t type; /**< Type descriptor. */ |
| 55 | void *buffer; /**< Buffer where to store data. */ |
54 | void *buffer; /**< Buffer where to store data. */ |
| 56 | size_t len; /**< Size of the buffer. */ |
55 | size_t len; /**< Size of the buffer. */ |
| 57 | unative_t intval; /**< Integer value */ |
56 | unative_t intval; /**< Integer value */ |
| 58 | cmd_arg_type_t vartype; /**< Resulting type of variable arg */ |
57 | cmd_arg_type_t vartype; /**< Resulting type of variable arg */ |
| 59 | }; |
58 | } cmd_arg_t; |
| 60 | 59 | ||
| 61 | /** Structure representing one kconsole command. */ |
60 | /** Structure representing one kconsole command. */ |
| 62 | struct cmd_info { |
61 | typedef struct { |
| 63 | link_t link; /**< Command list link. */ |
62 | link_t link; /**< Command list link. */ |
| 64 | SPINLOCK_DECLARE(lock); /**< This lock protects everything below. */ |
63 | SPINLOCK_DECLARE(lock); /**< This lock protects everything below. */ |
| 65 | const char *name; /**< Command name. */ |
64 | const char *name; /**< Command name. */ |
| 66 | const char *description; /**< Textual description. */ |
65 | const char *description; /**< Textual description. */ |
| 67 | int (* func)(cmd_arg_t *); /**< Function implementing the command. */ |
66 | int (* func)(cmd_arg_t *); /**< Function implementing the command. */ |
| 68 | count_t argc; /**< Number of arguments. */ |
67 | count_t argc; /**< Number of arguments. */ |
| 69 | cmd_arg_t *argv; /**< Argument vector. */ |
68 | cmd_arg_t *argv; /**< Argument vector. */ |
| 70 | void (* help)(void); /**< Function for printing detailed help. */ |
69 | void (* help)(void); /**< Function for printing detailed help. */ |
| 71 | }; |
70 | } cmd_info_t; |
| 72 | 71 | ||
| 73 | extern spinlock_t cmd_lock; |
72 | extern spinlock_t cmd_lock; |
| 74 | extern link_t cmd_head; |
73 | extern link_t cmd_head; |
| 75 | 74 | ||
| 76 | extern void kconsole_init(void); |
75 | extern void kconsole_init(void); |