com32: canonicalize DEBUG to mean <dprintf.h>
[syslinux/sherbszt.git] / com32 / hdt / hdt-cli.h
blob98246b4d99f7f8d83d49a57c7f0e83793e0a4f84
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
12 * conditions:
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
29 #ifndef DEFINE_HDT_CLI_H
30 #define DEFINE_HDT_CLI_H
31 #include <stdio.h>
32 #include <getkey.h>
33 #include <dprintf.h>
35 #include "hdt-common.h"
37 #define MAX_LINE_SIZE 256
39 #define CLI_SPACE " "
40 #define CLI_LF "\n"
41 #define CLI_MENU "menu"
42 #define CLI_CLEAR "clear"
43 #define CLI_EXIT "exit"
44 #define CLI_HELP "help"
45 #define CLI_REBOOT "reboot"
46 #define CLI_SHOW "show"
47 #define CLI_SET "set"
48 #define CLI_MODE "mode"
49 #define CLI_HDT "hdt"
50 #define CLI_PCI "pci"
51 #define CLI_PXE "pxe"
52 #define CLI_KERNEL "kernel"
53 #define CLI_SYSLINUX "syslinux"
54 #define CLI_VESA "vesa"
55 #define CLI_SUMMARY "summary"
56 #define CLI_COMMANDS "commands"
57 #define CLI_DMI "dmi"
58 #define CLI_CPU "cpu"
59 #define CLI_DISK "disk"
60 #define CLI_SHOW_LIST "list"
61 #define CLI_IRQ "irq"
62 #define CLI_MODES "modes"
63 #define CLI_VPD "vpd"
64 #define CLI_MEMORY "memory"
65 #define CLI_ENABLE "enable"
66 #define CLI_DISABLE "disable"
68 typedef enum {
69 INVALID_MODE,
70 EXIT_MODE,
71 HDT_MODE,
72 PCI_MODE,
73 DMI_MODE,
74 CPU_MODE,
75 PXE_MODE,
76 KERNEL_MODE,
77 SYSLINUX_MODE,
78 VESA_MODE,
79 DISK_MODE,
80 VPD_MODE,
81 MEMORY_MODE,
82 } cli_mode_t;
84 #define PROMPT_SIZE 32
85 #define MAX_HISTORY_SIZE 32
86 #define INPUT hdt_cli.history[hdt_cli.history_pos]
87 struct s_cli {
88 cli_mode_t mode;
89 char prompt[PROMPT_SIZE];
90 uint8_t cursor_pos;
91 char history[MAX_HISTORY_SIZE+1][MAX_LINE_SIZE];
92 int history_pos;
93 int max_history_pos;
95 struct s_cli hdt_cli;
97 /* Describe a cli mode */
98 struct cli_mode_descr {
99 const unsigned int mode;
100 const char *name;
101 /* Handle 1-token commands */
102 struct cli_module_descr *default_modules;
103 /* Handle show <module> <args> */
104 struct cli_module_descr *show_modules;
105 /* Handle set <module> <args> */
106 struct cli_module_descr *set_modules;
109 /* Describe a subset of commands in a module (default, show, set, ...) */
110 struct cli_module_descr {
111 struct cli_callback_descr *modules;
112 void (*default_callback) (int argc, char **argv,
113 struct s_hardware * hardware);
116 /* Describe a callback (belongs to a mode and a module) */
117 struct cli_callback_descr {
118 const char *name;
119 void (*exec) (int argc, char **argv, struct s_hardware * hardware);
122 /* Manage aliases */
123 #define MAX_ALIASES 2
124 struct cli_alias {
125 const char *command; /* Original command */
126 const int nb_aliases; /* Size of aliases array */
127 const char **aliases; /* List of aliases */
130 /* List of implemented modes */
131 extern struct cli_mode_descr *list_modes[];
132 struct cli_mode_descr hdt_mode;
133 struct cli_mode_descr dmi_mode;
134 struct cli_mode_descr syslinux_mode;
135 struct cli_mode_descr pxe_mode;
136 struct cli_mode_descr kernel_mode;
137 struct cli_mode_descr cpu_mode;
138 struct cli_mode_descr pci_mode;
139 struct cli_mode_descr vesa_mode;
140 struct cli_mode_descr disk_mode;
141 struct cli_mode_descr vpd_mode;
142 struct cli_mode_descr memory_mode;
144 /* cli helpers */
145 void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found);
146 void find_cli_callback_descr(const char *module_name,
147 struct cli_module_descr *modules_list,
148 struct cli_callback_descr **module_found);
149 cli_mode_t mode_s_to_mode_t(char *name);
151 void set_mode(cli_mode_t mode, struct s_hardware *hardware);
152 void start_cli_mode(struct s_hardware *hardware);
153 void start_auto_mode(struct s_hardware *hardware);
154 void main_show(char *item, struct s_hardware *hardware);
156 #define CLI_HISTORY "history"
157 void print_history(int argc, char **argv, struct s_hardware * hardware);
159 // DMI STUFF
160 #define CLI_DMI_BASE_BOARD "base_board"
161 #define CLI_DMI_BATTERY "battery"
162 #define CLI_DMI_BIOS "bios"
163 #define CLI_DMI_CHASSIS "chassis"
164 #define CLI_DMI_MEMORY "memory"
165 #define CLI_DMI_MEMORY_BANK "bank"
166 #define CLI_DMI_PROCESSOR "cpu"
167 #define CLI_DMI_SYSTEM "system"
168 #define CLI_DMI_IPMI "ipmi"
169 #define CLI_DMI_CACHE "cache"
170 #define CLI_DMI_OEM "oem"
171 #define CLI_DMI_SECURITY "security"
172 #define CLI_DMI_LIST CLI_SHOW_LIST
173 void main_show_dmi(int argc, char **argv, struct s_hardware *hardware);
174 void show_dmi_memory_modules(int argc, char **argv,
175 struct s_hardware *hardware);
176 void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware);
178 // PCI STUFF
179 #define CLI_PCI_DEVICE "device"
180 void main_show_pci(int argc, char **argv, struct s_hardware *hardware);
181 void cli_detect_pci(struct s_hardware *hardware);
183 // CPU STUFF
184 void main_show_cpu(int argc, char **argv, struct s_hardware *hardware);
186 // DISK STUFF
187 void disks_summary(int argc, char **argv, struct s_hardware *hardware);
189 // PXE STUFF
190 void main_show_pxe(int argc, char **argv, struct s_hardware *hardware);
192 // KERNEL STUFF
193 void main_show_kernel(int argc, char **argv, struct s_hardware *hardware);
195 // SYSLINUX STUFF
196 void main_show_syslinux(int argc, char **argv, struct s_hardware *hardware);
198 // VESA STUFF
199 void main_show_vesa(int argc, char **argv, struct s_hardware *hardware);
201 // VPD STUFF
202 void main_show_vpd(int argc __unused, char **argv __unused,
203 struct s_hardware *hardware);
204 #endif