struct console_driver vga_console __console_driver = {
.putchar = vga_putc,
- .disabled = 1,
+ .disabled = CONSOLE_DISABLED,
.usage = CONSOLE_DIRECT_VGA,
};
/** VMware logfile console driver */
struct console_driver vmconsole __console_driver = {
.putchar = vmconsole_putchar,
- .disabled = 1,
+ .disabled = CONSOLE_DISABLED,
.usage = CONSOLE_VMWARE,
};
check = inb ( DEBUG_PORT );
if ( check != DEBUG_PORT_CHECK ) {
DBG ( "Debug port not present; disabling console\n" );
- debugcon_console.disabled = 1;
+ debugcon_console.disabled = CONSOLE_DISABLED;
}
}
int console_usage = CONSOLE_USAGE_STDOUT;
/**
- * Write a single character to each console device.
+ * Write a single character to each console device
*
* @v character Character to be written
- * @ret None -
- * @err None -
*
* The character is written out to all enabled console devices, using
* each device's console_driver::putchar() method.
- *
*/
void putchar ( int character ) {
struct console_driver *console;
putchar ( '\r' );
for_each_table_entry ( console, CONSOLES ) {
- if ( ( ! console->disabled ) &&
+ if ( ( ! ( console->disabled & CONSOLE_DISABLED_OUTPUT ) ) &&
( console_usage & console->usage ) &&
console->putchar )
console->putchar ( character );
}
/**
- * Check to see if any input is available on any console.
+ * Check to see if any input is available on any console
*
- * @v None -
- * @ret console Console device that has input available, if any.
- * @ret NULL No console device has input available.
- * @err None -
+ * @ret console Console device that has input available, or NULL
*
* All enabled console devices are checked once for available input
* using each device's console_driver::iskey() method. The first
* console device that has available input will be returned, if any.
- *
*/
static struct console_driver * has_input ( void ) {
struct console_driver *console;
for_each_table_entry ( console, CONSOLES ) {
- if ( ( ! console->disabled ) && console->iskey ) {
+ if ( ( ! ( console->disabled & CONSOLE_DISABLED_INPUT ) ) &&
+ console->iskey ) {
if ( console->iskey () )
return console;
}
}
/**
- * Read a single character from any console.
+ * Read a single character from any console
*
- * @v None -
* @ret character Character read from a console.
- * @err None -
*
* A character will be read from the first enabled console device that
* has input available using that console's console_driver::getchar()
* @endcode
*
* The character read will not be echoed back to any console.
- *
*/
int getchar ( void ) {
struct console_driver *console;
return character;
}
-/** Check for available input on any console.
+/**
+ * Check for available input on any console
*
- * @v None -
- * @ret True Input is available on a console
- * @ret False Input is not available on any console
- * @err None -
+ * @ret is_available Input is available on a console
*
* All enabled console devices are checked once for available input
* using each device's console_driver::iskey() method. If any console
- * device has input available, this call will return True. If this
- * call returns True, you can then safely call getchar() without
+ * device has input available, this call will return true. If this
+ * call returns true, you can then safely call getchar() without
* blocking.
- *
*/
int iskey ( void ) {
return has_input() ? 1 : 0;
.putchar = serial_putc,
.getchar = serial_getc,
.iskey = serial_ischar,
- .disabled = 1,
+ .disabled = CONSOLE_DISABLED,
.usage = CONSOLE_SERIAL,
};
#ifndef _IPXE_CONSOLE_H
#define _IPXE_CONSOLE_H
+#include <stddef.h>
#include <stdio.h>
#include <ipxe/tables.h>
FILE_LICENCE ( GPL2_OR_LATER );
+struct pixel_buffer;
+
+/** A console configuration */
+struct console_configuration {
+ /** Width */
+ unsigned int width;
+ /** Height */
+ unsigned int height;
+ /** Colour depth */
+ unsigned int bpp;
+ /** Background picture, if any */
+ struct pixel_buffer *pixbuf;
+};
+
/**
* A console driver
*
* #__console_driver.
*
* @note Consoles that cannot be used before their initialisation
- * function has completed should set #disabled=1 initially. This
- * allows other console devices to still be used to print out early
- * debugging messages.
- *
+ * function has completed should set #disabled initially. This allows
+ * other console devices to still be used to print out early debugging
+ * messages.
*/
struct console_driver {
- /** Console is disabled.
- *
- * The console's putchar(), getchar() and iskey() methods will
- * not be called while #disabled==1. Typically the console's
- * initialisation functions will set #disabled=0 upon
- * completion.
+ /**
+ * Console disabled flags
*
+ * This is the bitwise OR of zero or more console disabled
+ * flags.
*/
int disabled;
-
- /** Write a character to the console.
+ /**
+ * Write a character to the console
*
* @v character Character to be written
- * @ret None -
- * @err None -
- *
*/
- void ( *putchar ) ( int character );
-
- /** Read a character from the console.
+ void ( * putchar ) ( int character );
+ /**
+ * Read a character from the console
*
- * @v None -
* @ret character Character read
- * @err None -
*
* If no character is available to be read, this method will
* block. The character read should not be echoed back to the
* console.
- *
*/
- int ( *getchar ) ( void );
-
- /** Check for available input.
+ int ( * getchar ) ( void );
+ /**
+ * Check for available input
*
- * @v None -
- * @ret True Input is available
- * @ret False Input is not available
- * @err None -
+ * @ret is_available Input is available
*
- * This should return True if a subsequent call to getchar()
+ * This should return true if a subsequent call to getchar()
* will not block.
- *
*/
- int ( *iskey ) ( void );
-
- /** Console usage bitmask
+ int ( * iskey ) ( void );
+ /**
+ * Console usage bitmask
*
* This is the bitwise OR of zero or more @c CONSOLE_USAGE_XXX
* values.
int usage;
};
+/** Console is disabled for input */
+#define CONSOLE_DISABLED_INPUT 0x0001
+
+/** Console is disabled for output */
+#define CONSOLE_DISABLED_OUTPUT 0x0002
+
+/** Console is disabled for all uses */
+#define CONSOLE_DISABLED ( CONSOLE_DISABLED_INPUT | CONSOLE_DISABLED_OUTPUT )
+
/** Console driver table */
#define CONSOLES __table ( struct console_driver, "consoles" )
/** Encrypted syslog console driver */
struct console_driver syslogs_console __console_driver = {
.putchar = syslogs_putchar,
- .disabled = 1,
+ .disabled = CONSOLE_DISABLED,
.usage = CONSOLE_SYSLOGS,
};
old_server = NULL;
/* Reset encrypted syslog connection */
- syslogs_console.disabled = 1;
+ syslogs_console.disabled = CONSOLE_DISABLED;
intf_restart ( &syslogs, 0 );
/* Do nothing unless we have a log server */
/** Syslog console driver */
struct console_driver syslog_console __console_driver = {
.putchar = syslog_putchar,
- .disabled = 1,
+ .disabled = CONSOLE_DISABLED,
.usage = CONSOLE_SYSLOG,
};
}
/* Fetch log server */
- syslog_console.disabled = 1;
+ syslog_console.disabled = CONSOLE_DISABLED;
old_addr.s_addr = sin_logserver->sin_addr.s_addr;
if ( ( len = fetch_ipv4_setting ( NULL, &syslog_setting,
&sin_logserver->sin_addr ) ) >= 0 ) {