1 /*
2  * Copyright (c) 2008-2009 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include <lk/compiler.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <sys/types.h>
14 
15 __BEGIN_CDECLS
16 
17 /* command args */
18 typedef struct {
19     const char *str;
20     unsigned long u;
21     unsigned long long ull;
22     void *p;
23     long i;
24     bool b;
25 } console_cmd_args;
26 
27 typedef int (*console_cmd_func)(int argc, const console_cmd_args *argv);
28 
29 #define CMD_AVAIL_NORMAL (0x1 << 0)
30 #define CMD_AVAIL_PANIC  (0x1 << 1)
31 #define CMD_AVAIL_ALWAYS (CMD_AVAIL_NORMAL | CMD_AVAIL_PANIC)
32 
33 __END_CDECLS
34 
35 /* Register a static block of commands at init time when lib/console is
36  * paret of the build. Otherwise stub out these definitions so that they do
37  * not get included.
38  */
39 #if WITH_LIB_CONSOLE
40 
41 /* pull the equivalent strctures and macros out of lib/console's headers */
42 #include <lib/console/cmd.h>
43 
44 #else
45 
46 /* no command blocks, so null them out */
47 #define STATIC_COMMAND_START
48 #define STATIC_COMMAND_END(name)
49 #define STATIC_COMMAND_START_NAMED(name)
50 #define STATIC_COMMAND_END_NAMED(name)
51 
52 #define STATIC_COMMAND(command_str, help_str, func)
53 #define STATIC_COMMAND_MASKED(command_str, help_str, func, availability_mask)
54 
55 
56 #endif
57