mirror of
https://github.com/ipxe/ipxe
synced 2025-12-19 11:00:27 +03:00
[console] Add concept of generic console configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -121,3 +121,35 @@ int getchar ( void ) {
|
||||
int iskey ( void ) {
|
||||
return has_input() ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure console
|
||||
*
|
||||
* @v config Console configuration
|
||||
* @ret rc Return status code
|
||||
*
|
||||
* The configuration is passed to all configurable consoles, including
|
||||
* those which are currently disabled. Consoles may choose to enable
|
||||
* or disable themselves depending upon the configuration.
|
||||
*
|
||||
* If configuration fails, then all consoles will be reset.
|
||||
*/
|
||||
int console_configure ( struct console_configuration *config ) {
|
||||
struct console_driver *console;
|
||||
int rc;
|
||||
|
||||
/* Try to configure each console */
|
||||
for_each_table_entry ( console, CONSOLES ) {
|
||||
if ( ( console->configure ) &&
|
||||
( ( rc = console->configure ( config ) ) != 0 ) )
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
/* Reset all consoles, avoiding a potential infinite loop */
|
||||
if ( config )
|
||||
console_reset();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#include <ipxe/device.h>
|
||||
#include <ipxe/console.h>
|
||||
#include <ipxe/init.h>
|
||||
|
||||
/** @file
|
||||
@@ -95,5 +96,8 @@ void shutdown ( int flags ) {
|
||||
startup_fn->shutdown ( flags );
|
||||
}
|
||||
|
||||
/* Reset console */
|
||||
console_reset();
|
||||
|
||||
started = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user