@@ -665,6 +665,19 @@ static void cf_check notify_dom0_con_ring(void *unused)
static DECLARE_SOFTIRQ_TASKLET(notify_dom0_con_ring_tasklet,
notify_dom0_con_ring, NULL);
+static bool console_locks_busted;
+
+static void conring_write(const char *str, size_t len)
+{
+ if ( opt_console_to_ring )
+ {
+ conring_puts(str, len);
+
+ if ( !console_locks_busted )
+ tasklet_schedule(¬ify_dom0_con_ring_tasklet);
+ }
+}
+
#ifdef CONFIG_X86
static inline void xen_console_write_debug_port(const char *buf, size_t len)
{
@@ -673,8 +686,43 @@ static inline void xen_console_write_debug_port(const char *buf, size_t len)
: "=&S" (tmp), "=&c" (tmp)
: "0" (buf), "1" (len), "d" (XEN_HVM_DEBUGCONS_IOPORT) );
}
+
+static void xen_console_write(const char *str, size_t len)
+{
+ if ( opt_console_xen )
+ {
+ if ( xen_guest )
+ xen_hypercall_console_write(str, len);
+ else
+ xen_console_write_debug_port(str, len);
+ }
+}
+#else
+static void xen_console_write(const char *str, size_t len)
+{
+}
#endif
+/*
+ * Write characters to console.
+ *
+ * That will handle all possible scenarios working w/ console
+ * - serial console;
+ * - video output;
+ * - __HYPERVISOR_console_io hypercall (x86 only);
+ * - debug I/O port (x86 only);
+ * - forward to Xen event channel.
+ */
+static void console_write(const char *str, size_t len)
+{
+ ASSERT(rspin_is_locked(&console_lock));
+
+ console_serial_puts(str, len);
+ video_puts(str, len);
+ xen_console_write(str, len);
+ conring_write(str, len);
+}
+
static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
unsigned int count)
{
@@ -695,28 +743,8 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
if ( is_hardware_domain(cd) )
{
- /* Use direct console output as it could be interactive */
nrspin_lock_irq(&console_lock);
-
- console_serial_puts(kbuf, kcount);
- video_puts(kbuf, kcount);
-
-#ifdef CONFIG_X86
- if ( opt_console_xen )
- {
- if ( xen_guest )
- xen_hypercall_console_write(kbuf, kcount);
- else
- xen_console_write_debug_port(kbuf, kcount);
- }
-#endif
-
- if ( opt_console_to_ring )
- {
- conring_puts(kbuf, kcount);
- tasklet_schedule(¬ify_dom0_con_ring_tasklet);
- }
-
+ console_write(kbuf, kcount);
nrspin_unlock_irq(&console_lock);
}
else
@@ -817,31 +845,9 @@ long do_console_io(
* *****************************************************
*/
-static bool console_locks_busted;
-
static void __putstr(const char *str)
{
- size_t len = strlen(str);
-
- ASSERT(rspin_is_locked(&console_lock));
-
- console_serial_puts(str, len);
- video_puts(str, len);
-
-#ifdef CONFIG_X86
- if ( opt_console_xen )
- {
- if ( xen_guest )
- xen_hypercall_console_write(str, len);
- else
- xen_console_write_debug_port(str, len);
- }
-#endif
-
- conring_puts(str, len);
-
- if ( !console_locks_busted )
- tasklet_schedule(¬ify_dom0_con_ring_tasklet);
+ console_write(str, strlen(str));
}
static int printk_prefix_check(char *p, char **pp)