From 815361aec2a8fb3e3bece5ab27993ae87244ecbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Sun, 25 Aug 2024 21:50:27 +0200 Subject: [PATCH] Kernel/aarch64: Remove BootPPMParser.{cpp,h} The BootPPMParser has been unused since 0acd87954b. --- Kernel/Arch/aarch64/BootPPMParser.cpp | 111 ------------------------ Kernel/Arch/aarch64/BootPPMParser.h | 38 -------- Kernel/Arch/aarch64/RPi/Framebuffer.cpp | 1 - Kernel/CMakeLists.txt | 1 - Meta/gn/secondary/Kernel/BUILD.gn | 1 - 5 files changed, 152 deletions(-) delete mode 100644 Kernel/Arch/aarch64/BootPPMParser.cpp delete mode 100644 Kernel/Arch/aarch64/BootPPMParser.h diff --git a/Kernel/Arch/aarch64/BootPPMParser.cpp b/Kernel/Arch/aarch64/BootPPMParser.cpp deleted file mode 100644 index b8fe4f25407..00000000000 --- a/Kernel/Arch/aarch64/BootPPMParser.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2021, Marcin Undak - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "BootPPMParser.h" - -namespace Kernel { - -BootPPMParser::BootPPMParser(u8 const* buffer, u32 buffer_size) -{ - m_cursor = reinterpret_cast(buffer); - m_buffer_end = m_cursor + buffer_size; -} - -bool BootPPMParser::parse() -{ - if (!check_position()) { - return false; - } - if (!parse_magic()) { - return false; - } - if (!parse_new_line()) { - return false; - } - if (!parse_comment()) { - return false; - } - if (!parse_integer(image.width)) { - return false; - } - if (!parse_integer(image.height)) { - return false; - } - u32 max_color_value; - if (!parse_integer(max_color_value) || max_color_value != 255) { - return false; - } - - image.pixel_data = reinterpret_cast(m_cursor); - - return true; -} - -bool BootPPMParser::check_position() const -{ - if (m_cursor >= m_buffer_end) { - return false; - } - return true; -} - -bool BootPPMParser::parse_magic() -{ - if (m_cursor[0] != 'P' || m_cursor[1] != '6') { - return false; - } - m_cursor += 2; - - return check_position(); -} - -bool BootPPMParser::parse_new_line() -{ - if (*m_cursor != '\n') { - return false; - } - ++m_cursor; - - return check_position(); -} - -bool BootPPMParser::parse_comment() -{ - if (*m_cursor == '#') { - // Skip to the next new line character - while (check_position() && *m_cursor != '\n') { - ++m_cursor; - } - ++m_cursor; - } - - return check_position(); -} - -bool BootPPMParser::parse_integer(u32& value) -{ - auto begin = m_cursor; - while (check_position() && *m_cursor != ' ' && *m_cursor != '\n') { - ++m_cursor; - } - auto end = m_cursor; - ++m_cursor; - - if (!check_position()) { - return false; - } - - value = 0; - u32 multiplier = 1; - while (--end >= begin) { - value += multiplier * (*end - '0'); - multiplier *= 10; - } - - return true; -} - -} diff --git a/Kernel/Arch/aarch64/BootPPMParser.h b/Kernel/Arch/aarch64/BootPPMParser.h deleted file mode 100644 index 4c007964bcd..00000000000 --- a/Kernel/Arch/aarch64/BootPPMParser.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021, Marcin Undak - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include - -namespace Kernel { - -// Quick parser for .ppm image format (raw PortablePixMap) -// This is much simpler version than userland implementation in PPMLoader.cpp -class BootPPMParser { -public: - struct { - u32 width = 0; - u32 height = 0; - u8 const* pixel_data = nullptr; - } image; - - BootPPMParser(u8 const* buffer, u32 buffer_size); - - bool parse(); - -private: - char const* m_cursor; - char const* m_buffer_end; - - bool check_position() const; - bool parse_magic(); - bool parse_new_line(); - bool parse_comment(); - bool parse_integer(u32& value); -}; - -} diff --git a/Kernel/Arch/aarch64/RPi/Framebuffer.cpp b/Kernel/Arch/aarch64/RPi/Framebuffer.cpp index 7fb4c5a96c1..35611c70373 100644 --- a/Kernel/Arch/aarch64/RPi/Framebuffer.cpp +++ b/Kernel/Arch/aarch64/RPi/Framebuffer.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 6588c1eb98a..75378b7290b 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -492,7 +492,6 @@ elseif("${SERENITY_ARCH}" STREQUAL "aarch64") Arch/aarch64/archctl.cpp Arch/aarch64/boot.S - Arch/aarch64/BootPPMParser.cpp Arch/aarch64/CPUID.cpp Arch/aarch64/CurrentTime.cpp Arch/aarch64/Dummy.cpp diff --git a/Meta/gn/secondary/Kernel/BUILD.gn b/Meta/gn/secondary/Kernel/BUILD.gn index 394452e6d4b..e4ad419f584 100644 --- a/Meta/gn/secondary/Kernel/BUILD.gn +++ b/Meta/gn/secondary/Kernel/BUILD.gn @@ -356,7 +356,6 @@ source_set("arch_sources") { deps = [ ":aarch64_no_mmu" ] sources = [ "Arch/Processor.cpp", - "Arch/aarch64/BootPPMParser.cpp", "Arch/aarch64/CPUID.cpp", "Arch/aarch64/CurrentTime.cpp", "Arch/aarch64/Dummy.cpp",