aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-03-26 17:25:08 +0100
committerMichael Brown <mcb30@ipxe.org>2012-03-26 17:40:01 +0100
commite024cd39a877ea1b37b9004dbd8f33448418cb36 (patch)
tree8bc44239bc5920d06b8381edef5aa37a4784aaf3 /src/include/ipxe
parentb35d454422a97b89a7128be4d4e9ff7a8f176466 (diff)
downloadipxe-e024cd39a877ea1b37b9004dbd8f33448418cb36.zip
ipxe-e024cd39a877ea1b37b9004dbd8f33448418cb36.tar.gz
ipxe-e024cd39a877ea1b37b9004dbd8f33448418cb36.tar.bz2
[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>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/console.h51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/include/ipxe/console.h b/src/include/ipxe/console.h
index 5188f98..f70dd71 100644
--- a/src/include/ipxe/console.h
+++ b/src/include/ipxe/console.h
@@ -75,6 +75,13 @@ struct console_driver {
*
*/
int ( *iskey ) ( void );
+
+ /** Console usage bitmask
+ *
+ * This is the bitwise OR of zero or more @c CONSOLE_USAGE_XXX
+ * values.
+ */
+ int usage;
};
/** Console driver table */
@@ -99,7 +106,49 @@ struct console_driver {
*/
#define __console_driver __table_entry ( CONSOLES, 01 )
-/* Function prototypes */
+/**
+ * @defgroup consoleusage Console usages
+ * @{
+ */
+
+/** Standard output */
+#define CONSOLE_USAGE_STDOUT 0x0001
+
+/** Debug messages */
+#define CONSOLE_USAGE_DEBUG 0x0002
+
+/** All console usages */
+#define CONSOLE_USAGE_ALL ( CONSOLE_USAGE_STDOUT | CONSOLE_USAGE_DEBUG )
+
+/** @} */
+
+/**
+ * Test to see if console has an explicit usage
+ *
+ * @v console Console definition (e.g. CONSOLE_PCBIOS)
+ * @ret explicit Console has an explicit usage
+ *
+ * This relies upon the trick that the expression ( 2 * N + 1 ) will
+ * be valid even if N is defined to be empty, since it will then
+ * evaluate to give ( 2 * + 1 ) == ( 2 * +1 ) == 2.
+ */
+#define CONSOLE_EXPLICIT( console ) ( ( 2 * console + 1 ) != 2 )
+
+extern int console_usage;
+
+/**
+ * Set console usage
+ *
+ * @v usage New console usage
+ * @ret old_usage Previous console usage
+ */
+static inline __attribute__ (( always_inline )) int
+console_set_usage ( int usage ) {
+ int old_usage = console_usage;
+
+ console_usage = usage;
+ return old_usage;
+}
extern int iskey ( void );
extern int getkey ( unsigned long timeout );