aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/debug/qemu_output.cpp
blob: 0af5bdc76f28e7daa99b9ec5874c407e0dcd609c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "x86_64/debug/qemu_output.hpp"

#include "kapi/cio.hpp"

#include <algorithm>
#include <string_view>

namespace teachos::debug::x86_64
{

  qemu_output::qemu_output(output_device & lower)
      : m_lower{lower}
      , m_present{port::read() == port::address}
  {}

  auto qemu_output::write(cio::output_stream stream, std::string_view text) -> void
  {
    if (m_present)
    {
      std::ranges::for_each(text, port::write<port::value_type>);
    }
    m_lower.write(stream, text);
  }

}  // namespace teachos::debug::x86_64