blob: 13f787e0464f4dbdf0e787b27e0b538cd2eee024 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#include <lib/boot-options/boot-options.h>
#include <stdarg.h>
#include <stdio.h>
#include <phys/stdio.h>
FILE gNullStdout([](void*, ktl::string_view s) -> int { return static_cast<int>(s.length()); },
nullptr);
FILE FILE::stdout_;
UartDriver& GetUartDriver() {
static UartDriver uart;
return uart;
}
void ConfigureStdout(const uart::all::Driver& uart) {
GetUartDriver() = uart;
GetUartDriver().Visit([](auto&& driver) {
driver.Init();
// Update stdout global to write to the configured driver.
FILE::stdout_ = FILE{&driver};
});
}
void debugf(const char* fmt, ...) {
if (gBootOptions && !gBootOptions->phys_verbose) {
return;
}
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}