+cons_putc_locked(
+ char c)
+{
+ if (!disableConsoleOutput)
+ cnputc(c);
+}
+
+static int
+vprintf_internal(const char *fmt, va_list ap_in, void *caller)
+{
+ cpu_data_t * cpu_data_p;
+ if (fmt) {
+ struct console_printbuf_state info_data;
+ cpu_data_p = current_cpu_datap();
+
+ va_list ap;
+ va_copy(ap, ap_in);
+ /*
+ * for early boot printf()s console may not be setup,
+ * fallback to good old cnputc
+ */
+ if (cpu_data_p->cpu_console_buf != NULL) {
+ console_printbuf_state_init(&info_data, TRUE, TRUE);
+ __doprnt(fmt, ap, console_printbuf_putc, &info_data, 16, TRUE);
+ console_printbuf_clear(&info_data);
+ } else {
+ disable_preemption();
+ _doprnt_log(fmt, &ap, cons_putc_locked, 16);
+ enable_preemption();
+ }
+
+ va_end(ap);
+
+ os_log_with_args(OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, fmt, ap_in, caller);
+ }
+ return 0;
+}
+
+__attribute__((noinline,not_tail_called))
+int
+printf(const char *fmt, ...)
+{
+ int ret;
+
+ va_list ap;
+ va_start(ap, fmt);
+ ret = vprintf_internal(fmt, ap, __builtin_return_address(0));
+ va_end(ap);
+
+ return ret;
+}
+
+__attribute__((noinline,not_tail_called))
+int
+vprintf(const char *fmt, va_list ap)
+{
+ return vprintf_internal(fmt, ap, __builtin_return_address(0));
+}
+
+void
+consdebug_putc(char c)
+{
+ if (!disableConsoleOutput)
+ cnputc(c);
+
+ debug_putc(c);
+
+ if (!console_is_serial() && !disable_serial_output)
+ PE_kputc(c);
+}
+
+void
+consdebug_putc_unbuffered(char c)