xaizek / tos (License: GPLv3 only) (since 2018-12-07)
This is an alternative version of sources presented as part of Write Your Own OS video tutorial by Viktor Engelmann.
<root> / src / print.cpp (82fcc3f23e7c3db9a3098a90baa086ce22ab6f5e) (1,043B) (mode 100644) [raw]
#include "print.hpp"

#include <cstdint>

#include "hwcomm/Screen.hpp"

hwcomm::Screen &
getScreen()
{
    static hwcomm::Screen screen;
    return screen;
}

void
detail::kprint(const char str[])
{
    getScreen().print(str);
}

void
detail::kprint(std::uint8_t byte)
{
    static const char hex[] = "0123456789ABCDEF";

    char msg[] = "00";
    msg[0] = hex[(byte >> 4) & 0xF];
    msg[1] = hex[byte & 0xF];
    detail::kprint(msg);
}

void
detail::kprint(std::uint16_t word)
{
    detail::kprint(static_cast<std::uint8_t>(word >> 8));
    detail::kprint(static_cast<std::uint8_t>(word & 0xff));
}

void
detail::kprint(std::uint32_t dword)
{
    detail::kprint(static_cast<std::uint16_t>(dword >> 16));
    detail::kprint(static_cast<std::uint16_t>(dword & 0xffff));
}

void
detail::kprint(std::uint64_t dword)
{
    detail::kprint(static_cast<std::uint32_t>(dword >> 32));
    detail::kprint(static_cast<std::uint32_t>(dword & 0xffffffff));
}

void
detail::kprint(void *ptr)
{
    detail::kprint(reinterpret_cast<std::uintptr_t>(ptr));
}
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/tos

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/tos

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master