aboutsummaryrefslogtreecommitdiff
path: root/source/kernel/arch/x86_64/src/vga.cpp
blob: d25eaa5b8a84ca8f1417a69dba7717aa0bd4114d (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
26
27
28
29
30
#include "kernel/vga.hpp"

#include "boot/asm_pointer.hpp"
#include "boot/pointers.hpp"

#include <string_view>
#include <algorithm>

namespace teachos::kernel::vga
{

  namespace
  {
    auto constinit text_buffer_pointer = boot::asm_pointer{boot::vga_buffer_pointer};

    auto write(char character, std::byte color) -> void
    {
      auto & p = *text_buffer_pointer;
      (*p++) = static_cast<std::byte>(character);
      (*p++) = color;
    };
  }  // namespace

  auto write(std::string_view text, std::byte color) -> void {
    std::ranges::for_each(text, [&](auto character) {
        write(character, color);
    });
  }

}  // namespace teachos::kernel