From e45ea1d89b8f82d17d86bd91007c513e74881e67 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Thu, 26 May 2022 04:37:26 +0200 Subject: [PATCH] Removed the framebuffer code: I will not be using it until it is reimplemented in userspace --- src/fb.cpp | 48 ------------------------------------------------ src/fb.hpp | 40 ---------------------------------------- src/kernel.cpp | 29 ----------------------------- 3 files changed, 117 deletions(-) delete mode 100644 src/fb.cpp delete mode 100644 src/fb.hpp diff --git a/src/fb.cpp b/src/fb.cpp deleted file mode 100644 index ff0beca..0000000 --- a/src/fb.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "serial.hpp" -#include "utils.hpp" -#include "fb.hpp" - -os::color os::operator*(color c1, color c2) { - return { - .r = std::uint8_t(int(c1.r) * int(c2.r) / 256), - .g = std::uint8_t(int(c1.g) * int(c2.g) / 256), - .b = std::uint8_t(int(c1.b) * int(c2.b) / 256), - }; -} - -os::framebuffer::framebuffer(std::uint64_t addr, std::uint32_t pitch, std::uint32_t width, std::uint32_t height, std::uint8_t bpp, std::uint8_t type, const std::uint8_t* color_info) { - address = phys_ptr(addr); - this->pitch = pitch; - this->width = width; - this->height = height; - this->bpp = bpp; - os::assert(type == 1, "Framebuffer not in direct RGB mode."); - os::assert(bpp == 32, "Framebuffer bpp != 32."); - - r_pos = color_info[0]; - r_mask = (1 << color_info[1]) - 1; - g_pos = color_info[2]; - g_mask = (1 << color_info[3]) - 1; - b_pos = color_info[4]; - b_mask = (1 << color_info[5]) - 1; -} -void os::framebuffer::putpixel(std::size_t x, std::size_t y, color c) { - *reinterpret_cast(&address[pitch * y + x * bpp / 8]) = color_to_data(c); -} -void os::framebuffer::clear(color c) { - for (std::size_t x = 0; x < width; x++) { - for (std::size_t y = 0; y < height; y++) { - putpixel(x, y, c); - } - } -} -std::size_t os::framebuffer::get_width() const { - return width; -} -std::size_t os::framebuffer::get_height() const { - return height; -} - -std::uint32_t os::framebuffer::color_to_data(color c) const { -return ((std::uint32_t(c.r) & r_mask) << r_pos) | ((std::uint32_t(c.g) & g_mask) << g_pos) | ((std::uint32_t(c.b) & b_mask) << b_pos); -} diff --git a/src/fb.hpp b/src/fb.hpp deleted file mode 100644 index 7acb6af..0000000 --- a/src/fb.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include "phys_ptr.hpp" - -namespace os { - -struct color { - std::uint8_t r; - std::uint8_t g; - std::uint8_t b; -}; -color operator*(color c1, color c2); - -class framebuffer { -public: - framebuffer() = default; - framebuffer(std::uint64_t addr, std::uint32_t pitch, std::uint32_t width, std::uint32_t height, std::uint8_t bpp, std::uint8_t type, const std::uint8_t* color_info); - void putpixel(std::size_t x, std::size_t y, color c); - void clear(color c); - std::size_t get_width() const; - std::size_t get_height() const; - -private: - std::uint32_t color_to_data(color c) const; - - phys_ptr address = nullptr; - std::size_t pitch; - std::size_t width; - std::size_t height; - std::uint8_t bpp; - std::uint8_t r_pos; - std::uint8_t r_mask; - std::uint8_t g_pos; - std::uint8_t g_mask; - std::uint8_t b_pos; - std::uint8_t b_mask; -}; - -} diff --git a/src/kernel.cpp b/src/kernel.cpp index 01ae69b..3ca6bd4 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -1,6 +1,5 @@ #include "multiboot2.hpp" #include "paging.hpp" -#include "fb.hpp" #include "utils.hpp" #include "serial.hpp" #include "interrupts.hpp" @@ -54,26 +53,8 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr info_end{(info.get_phys_addr() + info->total_size + 0x1000 - 1) / 0x1000 * 0x1000}; // Round end up. bool info_pages_wholly_usable = false; - os::framebuffer framebuffer; - for (auto it = multiboot2::next(info); it->type != multiboot2::info::type_t::end; it = multiboot2::next(it)) { switch (it->type) { - case multiboot2::info::type_t::framebuffer_info: - os::print("Framebuffer:\n"); - os::print(multiboot2::framebuffer_addr(it)); - os::print("->"); - os::print(multiboot2::framebuffer_addr(it) + multiboot2::framebuffer_pitch(it) * multiboot2::framebuffer_height(it)); - os::printc('\n'); - framebuffer = os::framebuffer( - multiboot2::framebuffer_addr(it), - multiboot2::framebuffer_pitch(it), - multiboot2::framebuffer_width(it), - multiboot2::framebuffer_height(it), - multiboot2::framebuffer_bpp(it), - multiboot2::framebuffer_type(it), - multiboot2::color_info(it) - ); - break; case multiboot2::info::type_t::memory_map: for (std::size_t i = 0; i < multiboot2::memory_map_number_of_entries(it); i++) { if (multiboot2::memory_map_type(it, i) == 1) { @@ -122,16 +103,6 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr