Browse Source

[console] Add concept of generic console configuration

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
c501c980e0

+ 4
- 0
src/arch/i386/image/bootsector.c View File

30
 #include <realmode.h>
30
 #include <realmode.h>
31
 #include <biosint.h>
31
 #include <biosint.h>
32
 #include <bootsector.h>
32
 #include <bootsector.h>
33
+#include <ipxe/console.h>
33
 
34
 
34
 /** Vector for storing original INT 18 handler
35
 /** Vector for storing original INT 18 handler
35
  *
36
  *
60
 		      unsigned int drive ) {
61
 		      unsigned int drive ) {
61
 	int discard_b, discard_D, discard_d;
62
 	int discard_b, discard_D, discard_d;
62
 
63
 
64
+	/* Reset console, since boot sector will probably use it */
65
+	console_reset();
66
+
63
 	DBG ( "Booting from boot sector at %04x:%04x\n", segment, offset );
67
 	DBG ( "Booting from boot sector at %04x:%04x\n", segment, offset );
64
 
68
 
65
 	/* Hook INTs 18 and 19 to capture failure paths */
69
 	/* Hook INTs 18 and 19 to capture failure paths */

+ 4
- 0
src/arch/i386/image/pxe_image.c View File

33
 #include <ipxe/segment.h>
33
 #include <ipxe/segment.h>
34
 #include <ipxe/netdevice.h>
34
 #include <ipxe/netdevice.h>
35
 #include <ipxe/features.h>
35
 #include <ipxe/features.h>
36
+#include <ipxe/console.h>
36
 
37
 
37
 FEATURE ( FEATURE_IMAGE, "PXE", DHCP_EB_FEATURE_PXE, 1 );
38
 FEATURE ( FEATURE_IMAGE, "PXE", DHCP_EB_FEATURE_PXE, 1 );
38
 
39
 
74
 	/* Set PXE command line */
75
 	/* Set PXE command line */
75
 	pxe_cmdline = image->cmdline;
76
 	pxe_cmdline = image->cmdline;
76
 
77
 
78
+	/* Reset console since PXE NBP will probably use it */
79
+	console_reset();
80
+
77
 	/* Start PXE NBP */
81
 	/* Start PXE NBP */
78
 	rc = pxe_start_nbp();
82
 	rc = pxe_start_nbp();
79
 
83
 

+ 32
- 0
src/core/console.c View File

121
 int iskey ( void ) {
121
 int iskey ( void ) {
122
 	return has_input() ? 1 : 0;
122
 	return has_input() ? 1 : 0;
123
 }
123
 }
124
+
125
+/**
126
+ * Configure console
127
+ *
128
+ * @v config		Console configuration
129
+ * @ret rc		Return status code
130
+ *
131
+ * The configuration is passed to all configurable consoles, including
132
+ * those which are currently disabled.  Consoles may choose to enable
133
+ * or disable themselves depending upon the configuration.
134
+ *
135
+ * If configuration fails, then all consoles will be reset.
136
+ */
137
+int console_configure ( struct console_configuration *config ) {
138
+	struct console_driver *console;
139
+	int rc;
140
+
141
+	/* Try to configure each console */
142
+	for_each_table_entry ( console, CONSOLES ) {
143
+		if ( ( console->configure ) &&
144
+		     ( ( rc = console->configure ( config ) ) != 0 ) )
145
+				goto err;
146
+	}
147
+
148
+	return 0;
149
+
150
+ err:
151
+	/* Reset all consoles, avoiding a potential infinite loop */
152
+	if ( config )
153
+		console_reset();
154
+	return rc;
155
+}

+ 4
- 0
src/core/init.c View File

20
 FILE_LICENCE ( GPL2_OR_LATER );
20
 FILE_LICENCE ( GPL2_OR_LATER );
21
 
21
 
22
 #include <ipxe/device.h>
22
 #include <ipxe/device.h>
23
+#include <ipxe/console.h>
23
 #include <ipxe/init.h>
24
 #include <ipxe/init.h>
24
 
25
 
25
 /** @file
26
 /** @file
95
 			startup_fn->shutdown ( flags );
96
 			startup_fn->shutdown ( flags );
96
 	}
97
 	}
97
 
98
 
99
+	/* Reset console */
100
+	console_reset();
101
+
98
 	started = 0;
102
 	started = 0;
99
 }
103
 }

+ 17
- 0
src/include/ipxe/console.h View File

77
 	 * will not block.
77
 	 * will not block.
78
 	 */
78
 	 */
79
 	int ( * iskey ) ( void );
79
 	int ( * iskey ) ( void );
80
+	/**
81
+	 * Configure console
82
+	 *
83
+	 * @v config		Console configuration, or NULL to reset
84
+	 * @ret rc		Return status code
85
+	 */
86
+	int ( * configure ) ( struct console_configuration *config );
80
 	/**
87
 	/**
81
 	 * Console usage bitmask
88
 	 * Console usage bitmask
82
 	 *
89
 	 *
170
 
177
 
171
 extern int iskey ( void );
178
 extern int iskey ( void );
172
 extern int getkey ( unsigned long timeout );
179
 extern int getkey ( unsigned long timeout );
180
+extern int console_configure ( struct console_configuration *config );
181
+
182
+/**
183
+ * Reset console
184
+ *
185
+ */
186
+static inline __attribute__ (( always_inline )) void console_reset ( void ) {
187
+
188
+	console_configure ( NULL );
189
+}
173
 
190
 
174
 #endif /* _IPXE_CONSOLE_H */
191
 #endif /* _IPXE_CONSOLE_H */

Loading…
Cancel
Save