[console] Allow usage to be defined independently for each console

Add the concept of a "console usage", such as "standard output" or
"debug messages".  Allow usages to be associated with each console
independently.  For example, to send debugging output via the serial
port, while preventing it from appearing on the local console:

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL
  #define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_DEBUG )

If no usages are explicitly specified, then a default set of usages
will be applied.  For example:

  #define CONSOLE_SERIAL

will have the same affect as

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-03-26 17:25:08 +01:00
parent b35d454422
commit e024cd39a8
11 changed files with 155 additions and 31 deletions

View File

@@ -7,6 +7,9 @@
FILE_LICENCE ( GPL2_OR_LATER );
/** Current console usage */
int console_usage = CONSOLE_USAGE_STDOUT;
/**
* Write a single character to each console device.
*
@@ -26,7 +29,9 @@ void putchar ( int character ) {
putchar ( '\r' );
for_each_table_entry ( console, CONSOLES ) {
if ( ( ! console->disabled ) && console->putchar )
if ( ( ! console->disabled ) &&
( console_usage & console->usage ) &&
console->putchar )
console->putchar ( character );
}
}