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 12 __BEGIN_CDECLS 13 14 /* Previously, this file was included to get access to defining a console 15 * command. This logic has been moved into the following header, which is 16 * what in almost every case what regular code wants to include instead of 17 * this file. 18 */ 19 #include <lk/console_cmd.h> 20 #include <lib/console/cmd.h> 21 22 typedef struct console console_t; 23 24 /* create an instance of the console */ 25 /* TODO: actually implement the history option. Currently always implements history according 26 * to the build variable CONSOLE_ENABLE_HISTORY. */ 27 console_t *console_create(bool with_history); 28 29 /* Run the main console loop. Will set the current console TLS pointer as a side effect */ 30 void console_start(console_t *con); 31 32 /* Routines to let code directly run commands in an existing console */ 33 /* NOTE: Passing null as first argument selects the current console associated with the current thread */ 34 int console_run_script(console_t *con, const char *string); 35 int console_run_script_locked(console_t *con, const char *string); // special case from inside a command 36 void console_abort_script(console_t *con); 37 38 /* Get/set the current console in the thread's TLS slot reserved for it. 39 * New threads will inherit the pointer from the parent thread. 40 * 41 * TODO: use a ref count to keep the console from being destroyed from underneath it. 42 */ 43 console_t *console_get_current(void); 44 console_t *console_set_current(console_t *con); // returns old console pointer 45 46 console_cmd_func console_get_command_handler(const char *command); 47 48 /* panic shell api */ 49 void panic_shell_start(void); 50 51 /* enable the panic shell if we're being built */ 52 #if !defined(ENABLE_PANIC_SHELL) && PLATFORM_SUPPORTS_PANIC_SHELL 53 #define ENABLE_PANIC_SHELL 1 54 #endif 55 56 __END_CDECLS 57