From dfe5a2d665714e1cdedc7f6a38be9394b1d27a6c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 24 Jan 2024 14:43:46 +0200 Subject: [PATCH] All: Cleanup all files Add newline to end of files and remove whitespace from end of lines --- BAN/BAN/String.cpp | 4 +- BAN/BAN/StringView.cpp | 2 +- BAN/BAN/Time.cpp | 4 +- BAN/include/BAN/Array.h | 4 +- BAN/include/BAN/Atomic.h | 2 +- BAN/include/BAN/ByteSpan.h | 4 +- BAN/include/BAN/CircularQueue.h | 4 +- BAN/include/BAN/Endianness.h | 2 +- BAN/include/BAN/Formatter.h | 6 +- BAN/include/BAN/Function.h | 4 +- BAN/include/BAN/Hash.h | 2 +- BAN/include/BAN/HashMap.h | 2 +- BAN/include/BAN/HashSet.h | 4 +- BAN/include/BAN/Iteration.h | 2 +- BAN/include/BAN/LinkedList.h | 4 +- BAN/include/BAN/Math.h | 2 +- BAN/include/BAN/Optional.h | 4 +- BAN/include/BAN/Queue.h | 2 +- BAN/include/BAN/ScopeGuard.h | 2 +- BAN/include/BAN/Sort.h | 2 +- BAN/include/BAN/Span.h | 2 +- BAN/include/BAN/StringView.h | 2 +- BAN/include/BAN/Time.h | 2 +- BAN/include/BAN/Traits.h | 2 +- BAN/include/BAN/UTF8.h | 4 +- BAN/include/BAN/UniqPtr.h | 4 +- BAN/include/BAN/Variant.h | 6 +- BAN/include/BAN/Vector.h | 2 +- BAN/include/BAN/WeakPtr.h | 2 +- LibELF/LibELF/ELF.cpp | 6 +- LibELF/LibELF/LoadableELF.cpp | 10 +-- LibELF/include/LibELF/ELF.h | 4 +- LibELF/include/LibELF/LoadableELF.h | 2 +- LibELF/include/LibELF/Types.h | 2 +- LibELF/include/LibELF/Values.h | 2 +- bootloader/bios/a20_line.S | 8 +-- bootloader/bios/disk.S | 2 +- bootloader/bios/linker.ld | 2 +- bootloader/installer/main.cpp | 2 +- kernel/arch/i386/GDT.cpp | 8 +-- kernel/arch/i386/IDT.cpp | 8 +-- kernel/arch/i386/MMU.cpp | 4 +- kernel/arch/i386/SpinLock.S | 2 +- kernel/arch/i386/linker.ld | 2 +- kernel/arch/x86_64/GDT.cpp | 6 +- kernel/arch/x86_64/IDT.cpp | 6 +- kernel/arch/x86_64/PageTable.cpp | 10 +-- kernel/arch/x86_64/interrupts.S | 2 +- kernel/arch/x86_64/linker.ld | 2 +- kernel/icxxabi.cpp | 10 +-- kernel/include/kernel/ACPI.h | 4 +- kernel/include/kernel/API/DirectoryEntry.h | 2 +- kernel/include/kernel/APIC.h | 2 +- kernel/include/kernel/CPUID.h | 48 ++++++------- kernel/include/kernel/CriticalScope.h | 2 +- kernel/include/kernel/Debug.h | 2 +- kernel/include/kernel/Device/Device.h | 2 +- .../include/kernel/Device/FramebufferDevice.h | 2 +- kernel/include/kernel/Device/NullDevice.h | 2 +- kernel/include/kernel/Device/ZeroDevice.h | 2 +- kernel/include/kernel/Errors.h | 2 +- kernel/include/kernel/FS/DevFS/FileSystem.h | 4 +- kernel/include/kernel/FS/Ext2/Definitions.h | 2 +- kernel/include/kernel/FS/Ext2/FileSystem.h | 6 +- kernel/include/kernel/FS/Ext2/Inode.h | 4 +- kernel/include/kernel/FS/FileSystem.h | 2 +- kernel/include/kernel/FS/Inode.h | 2 +- kernel/include/kernel/FS/Pipe.h | 2 +- kernel/include/kernel/FS/ProcFS/FileSystem.h | 2 +- kernel/include/kernel/FS/ProcFS/Inode.h | 2 +- kernel/include/kernel/FS/TmpFS/FileSystem.h | 2 +- kernel/include/kernel/FS/VirtualFileSystem.h | 2 +- kernel/include/kernel/Font.h | 2 +- kernel/include/kernel/GDT.h | 2 +- kernel/include/kernel/IDT.h | 2 +- kernel/include/kernel/IO.h | 2 +- kernel/include/kernel/Input/KeyEvent.h | 2 +- kernel/include/kernel/Input/MouseEvent.h | 4 +- kernel/include/kernel/InterruptController.h | 2 +- kernel/include/kernel/InterruptStack.h | 2 +- kernel/include/kernel/LockGuard.h | 4 +- kernel/include/kernel/MMIO.h | 2 +- kernel/include/kernel/Memory/DMARegion.h | 4 +- .../include/kernel/Memory/FileBackedRegion.h | 2 +- .../kernel/Memory/MemoryBackedRegion.h | 4 +- kernel/include/kernel/Memory/MemoryRegion.h | 4 +- kernel/include/kernel/Memory/PageTable.h | 4 +- kernel/include/kernel/Memory/PageTableScope.h | 2 +- kernel/include/kernel/Memory/PhysicalRange.h | 4 +- kernel/include/kernel/Memory/Types.h | 2 +- kernel/include/kernel/Memory/VirtualRange.h | 2 +- kernel/include/kernel/Networking/E1000.h | 14 ++-- .../include/kernel/Networking/NetworkDriver.h | 2 +- kernel/include/kernel/OpenFileDescriptorSet.h | 2 +- kernel/include/kernel/PCI.h | 4 +- kernel/include/kernel/Panic.h | 2 +- kernel/include/kernel/Process.h | 2 +- kernel/include/kernel/Scheduler.h | 2 +- kernel/include/kernel/Semaphore.h | 2 +- kernel/include/kernel/SpinLock.h | 2 +- .../kernel/Storage/ATA/AHCI/Definitions.h | 70 +++++++++---------- .../include/kernel/Storage/ATA/AHCI/Device.h | 6 +- kernel/include/kernel/Storage/ATA/ATABus.h | 2 +- .../kernel/Storage/ATA/ATAController.h | 2 +- .../kernel/Storage/ATA/ATADefinitions.h | 2 +- kernel/include/kernel/Storage/ATA/ATADevice.h | 4 +- kernel/include/kernel/Storage/DiskCache.h | 2 +- .../include/kernel/Storage/NVMe/Definitions.h | 4 +- .../kernel/Storage/StorageController.h | 2 +- kernel/include/kernel/Storage/StorageDevice.h | 2 +- kernel/include/kernel/Terminal/Serial.h | 4 +- kernel/include/kernel/Terminal/TTY.h | 2 +- .../include/kernel/Terminal/TerminalDriver.h | 2 +- kernel/include/kernel/Terminal/termios.h | 2 +- kernel/include/kernel/Thread.h | 6 +- kernel/include/kernel/Timer/HPET.h | 2 +- kernel/include/kernel/Timer/PIT.h | 2 +- kernel/include/kernel/Timer/Timer.h | 4 +- kernel/kernel/ACPI.cpp | 6 +- kernel/kernel/APIC.cpp | 4 +- kernel/kernel/BootInfo.cpp | 4 +- kernel/kernel/Credentials.cpp | 2 +- kernel/kernel/Debug.cpp | 4 +- kernel/kernel/Device/Device.cpp | 2 +- kernel/kernel/Device/FramebufferDevice.cpp | 6 +- kernel/kernel/Device/NullDevice.cpp | 2 +- kernel/kernel/Device/ZeroDevice.cpp | 2 +- kernel/kernel/Errors.cpp | 2 +- kernel/kernel/FS/DevFS/FileSystem.cpp | 2 +- kernel/kernel/FS/Ext2/FileSystem.cpp | 2 +- kernel/kernel/FS/Ext2/Inode.cpp | 2 +- kernel/kernel/FS/Inode.cpp | 2 +- kernel/kernel/FS/Pipe.cpp | 2 +- kernel/kernel/FS/TmpFS/FileSystem.cpp | 4 +- kernel/kernel/FS/TmpFS/Inode.cpp | 6 +- kernel/kernel/FS/VirtualFileSystem.cpp | 2 +- kernel/kernel/Font.cpp | 8 +-- kernel/kernel/Input/KeyboardLayout.cpp | 2 +- kernel/kernel/Input/PS2/Controller.cpp | 4 +- kernel/kernel/Input/PS2/Keyboard.cpp | 3 + kernel/kernel/Input/PS2/Mouse.cpp | 2 +- kernel/kernel/Memory/DMARegion.cpp | 2 +- kernel/kernel/Memory/FileBackedRegion.cpp | 2 +- kernel/kernel/Memory/Heap.cpp | 2 +- kernel/kernel/Memory/MemoryBackedRegion.cpp | 6 +- kernel/kernel/Memory/MemoryRegion.cpp | 2 +- kernel/kernel/Memory/VirtualRange.cpp | 4 +- kernel/kernel/Memory/kmalloc.cpp | 8 +-- kernel/kernel/OpenFileDescriptorSet.cpp | 12 ++-- kernel/kernel/PCI.cpp | 6 +- kernel/kernel/PIC.cpp | 2 +- kernel/kernel/Process.cpp | 36 +++++----- kernel/kernel/SSP.cpp | 2 +- kernel/kernel/Scheduler.cpp | 6 +- kernel/kernel/Semaphore.cpp | 2 +- kernel/kernel/SpinLock.cpp | 10 +-- kernel/kernel/Storage/ATA/AHCI/Controller.cpp | 2 +- kernel/kernel/Storage/ATA/AHCI/Device.cpp | 14 ++-- kernel/kernel/Storage/ATA/ATABus.cpp | 4 +- kernel/kernel/Storage/ATA/ATAController.cpp | 2 +- kernel/kernel/Storage/ATA/ATADevice.cpp | 4 +- kernel/kernel/Storage/DiskCache.cpp | 4 +- kernel/kernel/Storage/NVMe/Controller.cpp | 4 +- kernel/kernel/Storage/NVMe/Queue.cpp | 2 +- kernel/kernel/Storage/Partition.cpp | 2 +- kernel/kernel/Storage/StorageDevice.cpp | 4 +- kernel/kernel/Syscall.cpp | 2 +- kernel/kernel/Terminal/Serial.cpp | 4 +- kernel/kernel/Terminal/VirtualTTY.cpp | 8 +-- kernel/kernel/Thread.cpp | 6 +- kernel/kernel/Timer/HPET.cpp | 4 +- kernel/kernel/Timer/RTC.cpp | 4 +- kernel/kernel/Timer/Timer.cpp | 2 +- kernel/ubsan.cpp | 2 +- libc/fcntl.cpp | 2 +- libc/grp.cpp | 10 +-- libc/include/sys/cdefs.h | 2 +- libc/include/sys/resource.h | 2 +- libc/include/sys/select.h | 4 +- libc/include/sys/stat.h | 2 +- libc/include/sys/sysmacros.h | 2 +- libc/include/unistd.h | 2 +- libc/malloc.cpp | 4 +- libc/math.S | 2 +- libc/printf_impl.cpp | 2 +- libc/pwd.cpp | 4 +- libc/scanf_impl.cpp | 4 +- libc/signal.cpp | 2 +- libc/stdio.cpp | 2 +- libc/stdlib.cpp | 2 +- libc/sys/wait.cpp | 2 +- libc/time.cpp | 2 +- libc/unistd.cpp | 4 +- script/build.sh | 2 +- script/image.sh | 2 +- script/install-bootloader.sh | 2 +- script/shell-completion/zsh/_bos | 1 - toolchain/binutils-2.39.patch | 2 +- toolchain/build.sh | 2 +- userspace/Shell/main.cpp | 18 ++--- userspace/aoc2023/day10/main.cpp | 6 +- userspace/aoc2023/day11/main.cpp | 2 +- userspace/aoc2023/day12/main.cpp | 6 +- userspace/aoc2023/day14/main.cpp | 2 +- userspace/aoc2023/day16/main.cpp | 2 +- userspace/aoc2023/day17/main.cpp | 6 +- userspace/aoc2023/day18/main.cpp | 4 +- userspace/aoc2023/day19/main.cpp | 8 +-- userspace/aoc2023/day2/main.cpp | 4 +- userspace/aoc2023/day20/main.cpp | 2 +- userspace/aoc2023/day21/main.cpp | 2 +- userspace/aoc2023/day23/main.cpp | 4 +- userspace/aoc2023/day24/main.cpp | 4 +- userspace/aoc2023/day25/main.cpp | 6 +- userspace/aoc2023/day3/main.cpp | 8 +-- userspace/aoc2023/day5/main.cpp | 4 +- userspace/image/Netbpm.cpp | 2 +- userspace/image/main.cpp | 2 +- userspace/init/main.cpp | 4 +- userspace/loadkeys/main.cpp | 2 +- userspace/meminfo/main.cpp | 2 +- userspace/rm/main.cpp | 2 +- userspace/sleep/main.cpp | 2 +- userspace/sudo/main.cpp | 2 +- userspace/tee/main.cpp | 4 +- userspace/test-mouse/main.cpp | 6 +- 226 files changed, 466 insertions(+), 460 deletions(-) diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index e67322fc..40389f14 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -249,11 +249,11 @@ namespace BAN return {}; if (has_sso() && fits_in_sso(new_size)) return {}; - + char* new_data = (char*)allocator(new_size + 1); if (new_data == nullptr) return Error::from_errno(ENOMEM); - + if (m_size) memcpy(new_data, data(), m_size + 1); diff --git a/BAN/BAN/StringView.cpp b/BAN/BAN/StringView.cpp index fe306985..2caa52b8 100644 --- a/BAN/BAN/StringView.cpp +++ b/BAN/BAN/StringView.cpp @@ -193,4 +193,4 @@ namespace BAN return m_data; } -} \ No newline at end of file +} diff --git a/BAN/BAN/Time.cpp b/BAN/BAN/Time.cpp index fab1db09..73237a89 100644 --- a/BAN/BAN/Time.cpp +++ b/BAN/BAN/Time.cpp @@ -38,7 +38,7 @@ namespace BAN } BAN::Time from_unix_time(uint64_t unix_time) - { + { BAN::Time time {}; time.second = unix_time % 60; unix_time /= 60; @@ -68,4 +68,4 @@ namespace BAN return time; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Array.h b/BAN/include/BAN/Array.h index 65f9c661..97329613 100644 --- a/BAN/include/BAN/Array.h +++ b/BAN/include/BAN/Array.h @@ -39,7 +39,7 @@ namespace BAN const Span span() const { return Span(m_data, size()); } constexpr size_type size() const; - + const T* data() const { return m_data; } T* data() { return m_data; } @@ -109,4 +109,4 @@ namespace BAN return S; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Atomic.h b/BAN/include/BAN/Atomic.h index 52a2ff7a..f07393ff 100644 --- a/BAN/include/BAN/Atomic.h +++ b/BAN/include/BAN/Atomic.h @@ -39,4 +39,4 @@ namespace BAN T m_value; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/ByteSpan.h b/BAN/include/BAN/ByteSpan.h index d54403e3..24ae2468 100644 --- a/BAN/include/BAN/ByteSpan.h +++ b/BAN/include/BAN/ByteSpan.h @@ -125,7 +125,7 @@ namespace BAN } value_type* data() { return m_data; } - const value_type* data() const { return m_data; } + const value_type* data() const { return m_data; } size_type size() const { return m_size; } @@ -137,4 +137,4 @@ namespace BAN using ByteSpan = ByteSpanGeneral; using ConstByteSpan = ByteSpanGeneral; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/CircularQueue.h b/BAN/include/BAN/CircularQueue.h index a0413c12..553fb53a 100644 --- a/BAN/include/BAN/CircularQueue.h +++ b/BAN/include/BAN/CircularQueue.h @@ -32,7 +32,7 @@ namespace BAN size_type size() const { return m_size; } bool empty() const { return size() == 0; } bool full() const { return size() == capacity(); } - + static constexpr size_type capacity() { return S; } private: @@ -110,4 +110,4 @@ namespace BAN return (T*)(m_storage + index * sizeof(T)); } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Endianness.h b/BAN/include/BAN/Endianness.h index 0a39be7e..0d4b7411 100644 --- a/BAN/include/BAN/Endianness.h +++ b/BAN/include/BAN/Endianness.h @@ -77,4 +77,4 @@ namespace BAN T raw; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Formatter.h b/BAN/include/BAN/Formatter.h index 56432f3a..b5f268a3 100644 --- a/BAN/include/BAN/Formatter.h +++ b/BAN/include/BAN/Formatter.h @@ -192,7 +192,7 @@ namespace BAN::Formatter if (sign) *(--ptr) = '-'; - + print(putc, ptr); } @@ -205,10 +205,10 @@ namespace BAN::Formatter frac_part = -frac_part; print_integer(putc, int_part, format); - + if (format.percision > 0) putc('.'); - + for (int i = 0; i < format.percision; i++) { frac_part *= format.base; diff --git a/BAN/include/BAN/Function.h b/BAN/include/BAN/Function.h index 85c8ed74..305b34b1 100644 --- a/BAN/include/BAN/Function.h +++ b/BAN/include/BAN/Function.h @@ -56,7 +56,7 @@ namespace BAN return true; return false; } - + void clear() { if (*this) @@ -145,4 +145,4 @@ namespace BAN alignas(CallableBase) uint8_t m_storage[m_size] { 0 }; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Hash.h b/BAN/include/BAN/Hash.h index b13e8250..035e3be5 100644 --- a/BAN/include/BAN/Hash.h +++ b/BAN/include/BAN/Hash.h @@ -47,4 +47,4 @@ namespace BAN } }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/HashMap.h b/BAN/include/BAN/HashMap.h index 508ddab5..4328b2ba 100644 --- a/BAN/include/BAN/HashMap.h +++ b/BAN/include/BAN/HashMap.h @@ -66,7 +66,7 @@ namespace BAN ErrorOr rebucket(size_type); LinkedList& get_bucket(const Key&); const LinkedList& get_bucket(const Key&) const; - + private: Vector> m_buckets; size_type m_size = 0; diff --git a/BAN/include/BAN/HashSet.h b/BAN/include/BAN/HashSet.h index a734c826..ecff41ae 100644 --- a/BAN/include/BAN/HashSet.h +++ b/BAN/include/BAN/HashSet.h @@ -19,7 +19,7 @@ namespace BAN using size_type = size_t; using iterator = IteratorDouble; using const_iterator = ConstIteratorDouble; - + public: HashSet() = default; HashSet(const HashSet&); @@ -206,4 +206,4 @@ namespace BAN template> using HashSetUnstable = HashSet; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Iteration.h b/BAN/include/BAN/Iteration.h index 512a7de0..f90385a1 100644 --- a/BAN/include/BAN/Iteration.h +++ b/BAN/include/BAN/Iteration.h @@ -9,4 +9,4 @@ namespace BAN Break }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/LinkedList.h b/BAN/include/BAN/LinkedList.h index 626b7dbe..e558925d 100644 --- a/BAN/include/BAN/LinkedList.h +++ b/BAN/include/BAN/LinkedList.h @@ -287,7 +287,7 @@ namespace BAN { Node* node = (Node*)BAN::allocator(sizeof(Node)); if (node == nullptr) - return Error::from_errno(ENOMEM); + return Error::from_errno(ENOMEM); return node; } @@ -396,4 +396,4 @@ namespace BAN return m_current; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index ca1252ce..617d3309 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -119,4 +119,4 @@ namespace BAN::Math return result; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Optional.h b/BAN/include/BAN/Optional.h index 862fee78..01551c15 100644 --- a/BAN/include/BAN/Optional.h +++ b/BAN/include/BAN/Optional.h @@ -72,7 +72,7 @@ namespace BAN Optional::Optional(const T& value) : m_has_value(true) { - new (m_storage) T(value); + new (m_storage) T(value); } template @@ -192,4 +192,4 @@ namespace BAN m_has_value = false; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Queue.h b/BAN/include/BAN/Queue.h index db5f1e42..60847b33 100644 --- a/BAN/include/BAN/Queue.h +++ b/BAN/include/BAN/Queue.h @@ -225,4 +225,4 @@ namespace BAN return {}; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/ScopeGuard.h b/BAN/include/BAN/ScopeGuard.h index 18526291..d514d0e0 100644 --- a/BAN/include/BAN/ScopeGuard.h +++ b/BAN/include/BAN/ScopeGuard.h @@ -25,4 +25,4 @@ namespace BAN bool m_enabled { true }; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Sort.h b/BAN/include/BAN/Sort.h index 8182bf0f..b85bda6e 100644 --- a/BAN/include/BAN/Sort.h +++ b/BAN/include/BAN/Sort.h @@ -120,7 +120,7 @@ namespace BAN::sort if (parent == 0) break; - + parent--; } } diff --git a/BAN/include/BAN/Span.h b/BAN/include/BAN/Span.h index a04c22a3..8db901b7 100644 --- a/BAN/include/BAN/Span.h +++ b/BAN/include/BAN/Span.h @@ -131,4 +131,4 @@ namespace BAN return Span(m_data + start, length); } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/StringView.h b/BAN/include/BAN/StringView.h index 68f61fbe..6163e424 100644 --- a/BAN/include/BAN/StringView.h +++ b/BAN/include/BAN/StringView.h @@ -44,7 +44,7 @@ namespace BAN bool empty() const; size_type size() const; - + const char* data() const; private: diff --git a/BAN/include/BAN/Time.h b/BAN/include/BAN/Time.h index 7b756103..b3c420c3 100644 --- a/BAN/include/BAN/Time.h +++ b/BAN/include/BAN/Time.h @@ -34,4 +34,4 @@ namespace BAN::Formatter print(putc, "{} {} {} {2}:{2}:{2} GMT+0 {4}", week_days[time.week_day], months[time.month], time.day, time.hour, time.minute, time.second, time.year); } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Traits.h b/BAN/include/BAN/Traits.h index 58850af6..d9690ee5 100644 --- a/BAN/include/BAN/Traits.h +++ b/BAN/include/BAN/Traits.h @@ -102,4 +102,4 @@ namespace BAN template struct equal { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } }; template struct greater { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs > rhs; } }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/UTF8.h b/BAN/include/BAN/UTF8.h index f2a127a0..918d1be1 100644 --- a/BAN/include/BAN/UTF8.h +++ b/BAN/include/BAN/UTF8.h @@ -28,7 +28,7 @@ namespace BAN::UTF8 for (uint32_t i = 1; i < length; i++) if ((bytes[i] & 0xC0) != 0x80) return UTF8::invalid; - + switch (length) { case 1: return ((bytes[0] & 0x80) != 0x00) ? UTF8::invalid : bytes[0]; @@ -78,4 +78,4 @@ namespace BAN::UTF8 return true; } -} \ No newline at end of file +} diff --git a/BAN/include/BAN/UniqPtr.h b/BAN/include/BAN/UniqPtr.h index 96dbd399..3b49f575 100644 --- a/BAN/include/BAN/UniqPtr.h +++ b/BAN/include/BAN/UniqPtr.h @@ -67,7 +67,7 @@ namespace BAN T* operator->() { ASSERT(m_pointer); - return m_pointer; + return m_pointer; } const T* operator->() const @@ -95,4 +95,4 @@ namespace BAN friend class UniqPtr; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Variant.h b/BAN/include/BAN/Variant.h index a7944bda..97de1680 100644 --- a/BAN/include/BAN/Variant.h +++ b/BAN/include/BAN/Variant.h @@ -140,14 +140,14 @@ namespace BAN Variant(T&& value) requires (can_have() && !is_lvalue_reference_v) : m_index(detail::index()) { - new (m_storage) T(move(value)); + new (m_storage) T(move(value)); } template Variant(const T& value) requires (can_have() && !is_lvalue_reference_v) : m_index(detail::index()) { - new (m_storage) T(value); + new (m_storage) T(value); } ~Variant() @@ -292,4 +292,4 @@ namespace BAN size_t m_index { invalid_index() }; }; -} \ No newline at end of file +} diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index 2a59ab6b..934d5432 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -38,7 +38,7 @@ namespace BAN ErrorOr emplace(size_type, Args&&...); ErrorOr insert(size_type, T&&); ErrorOr insert(size_type, const T&); - + iterator begin() { return iterator(m_data); } iterator end() { return iterator(m_data + m_size); } const_iterator begin() const { return const_iterator(m_data); } diff --git a/BAN/include/BAN/WeakPtr.h b/BAN/include/BAN/WeakPtr.h index 687f4204..0c35620a 100644 --- a/BAN/include/BAN/WeakPtr.h +++ b/BAN/include/BAN/WeakPtr.h @@ -104,4 +104,4 @@ namespace BAN friend class Weakable; }; -} \ No newline at end of file +} diff --git a/LibELF/LibELF/ELF.cpp b/LibELF/LibELF/ELF.cpp index 16d17b0f..f1b4ebe4 100644 --- a/LibELF/LibELF/ELF.cpp +++ b/LibELF/LibELF/ELF.cpp @@ -77,7 +77,7 @@ namespace LibELF return BAN::Error::from_errno(EINVAL); } - if (m_data[EI_MAG0] != ELFMAG0 || + if (m_data[EI_MAG0] != ELFMAG0 || m_data[EI_MAG1] != ELFMAG1 || m_data[EI_MAG2] != ELFMAG2 || m_data[EI_MAG3] != ELFMAG3) @@ -252,7 +252,7 @@ namespace LibELF break; default: ASSERT(false); - } + } #endif (void)header; return true; @@ -375,7 +375,7 @@ namespace LibELF break; default: ASSERT(false); - } + } #endif (void)header; return true; diff --git a/LibELF/LibELF/LoadableELF.cpp b/LibELF/LibELF/LoadableELF.cpp index ebdb037a..b8bccc17 100644 --- a/LibELF/LibELF/LoadableELF.cpp +++ b/LibELF/LibELF/LoadableELF.cpp @@ -66,7 +66,7 @@ namespace LibELF size_t nread = TRY(m_inode->read(0, BAN::ByteSpan::from(m_file_header))); ASSERT(nread == sizeof(m_file_header)); - if (m_file_header.e_ident[EI_MAG0] != ELFMAG0 || + if (m_file_header.e_ident[EI_MAG0] != ELFMAG0 || m_file_header.e_ident[EI_MAG1] != ELFMAG1 || m_file_header.e_ident[EI_MAG2] != ELFMAG2 || m_file_header.e_ident[EI_MAG3] != ELFMAG3) @@ -93,7 +93,7 @@ namespace LibELF if (m_file_header.e_ident[EI_CLASS] != ELFCLASS64) #endif { - dprintln("Not in native format"); + dprintln("Not in native format"); return BAN::Error::from_errno(EINVAL); } @@ -240,13 +240,13 @@ namespace LibELF m_physical_page_count++; memset((void*)vaddr, 0x00, PAGE_SIZE); - + if (vaddr / PAGE_SIZE < BAN::Math::div_round_up(program_header.p_vaddr + program_header.p_filesz, PAGE_SIZE)) { size_t vaddr_offset = 0; if (vaddr < program_header.p_vaddr) vaddr_offset = program_header.p_vaddr - vaddr; - + size_t file_offset = 0; if (vaddr > program_header.p_vaddr) file_offset = vaddr - program_header.p_vaddr; @@ -267,7 +267,7 @@ namespace LibELF ASSERT_NOT_REACHED(); } - + BAN::ErrorOr> LoadableELF::clone(Kernel::PageTable& new_page_table) { auto* elf_ptr = new LoadableELF(new_page_table, m_inode); diff --git a/LibELF/include/LibELF/ELF.h b/LibELF/include/LibELF/ELF.h index eda87e92..a36c9dd0 100644 --- a/LibELF/include/LibELF/ELF.h +++ b/LibELF/include/LibELF/ELF.h @@ -68,7 +68,7 @@ namespace LibELF {} //#endif BAN::ErrorOr load(); - + bool parse_elf64_file_header(const Elf64FileHeader&); bool parse_elf64_program_header(const Elf64ProgramHeader&); bool parse_elf64_section_header(const Elf64SectionHeader&); @@ -86,4 +86,4 @@ namespace LibELF //#endif }; -} \ No newline at end of file +} diff --git a/LibELF/include/LibELF/LoadableELF.h b/LibELF/include/LibELF/LoadableELF.h index cd143119..3bdad48f 100644 --- a/LibELF/include/LibELF/LoadableELF.h +++ b/LibELF/include/LibELF/LoadableELF.h @@ -54,4 +54,4 @@ namespace LibELF bool m_loaded { false }; }; -} \ No newline at end of file +} diff --git a/LibELF/include/LibELF/Types.h b/LibELF/include/LibELF/Types.h index 2fab8e3e..bcaf0cc3 100644 --- a/LibELF/include/LibELF/Types.h +++ b/LibELF/include/LibELF/Types.h @@ -183,4 +183,4 @@ namespace LibELF using ElfNativeProgramHeader = Elf64ProgramHeader; #endif -} \ No newline at end of file +} diff --git a/LibELF/include/LibELF/Values.h b/LibELF/include/LibELF/Values.h index e2ec5836..a3422657 100644 --- a/LibELF/include/LibELF/Values.h +++ b/LibELF/include/LibELF/Values.h @@ -137,4 +137,4 @@ namespace LibELF PF_MASKPROC = 0xFF000000, }; -} \ No newline at end of file +} diff --git a/bootloader/bios/a20_line.S b/bootloader/bios/a20_line.S index 7b68b73c..62e36cde 100644 --- a/bootloader/bios/a20_line.S +++ b/bootloader/bios/a20_line.S @@ -31,7 +31,7 @@ check_a20: movb $0xFF, %ds:(%si) cmpb $0xFF, %es:(%di) - + pop %ax movb %al, %ds:(%si) @@ -40,7 +40,7 @@ check_a20: movw $0, %ax je .check_a20_done - + movw $1, %ax .check_a20_done: @@ -68,7 +68,7 @@ enable_a20_ps2: call .enable_a20_ps2_wait1 movb $0xD0, %al outb %al, $0x64 - + call .enable_a20_ps2_wait2 inb $0x60, %al pushw %ax @@ -77,7 +77,7 @@ enable_a20_ps2: call .enable_a20_ps2_wait1 movb $0xD1, %al outb %al, $0x64 - + call .enable_a20_ps2_wait1 popw %ax orw $2, %ax diff --git a/bootloader/bios/disk.S b/bootloader/bios/disk.S index e5b13b2f..4471c127 100644 --- a/bootloader/bios/disk.S +++ b/bootloader/bios/disk.S @@ -418,7 +418,7 @@ find_root_partition: decl %ecx subl %ecx, %eax sbbl $0, %ebx - + # ecx: min(partition count, 0xFFFFFFFF) movl $0xFFFFFFFF, %edx movl %eax, %ecx diff --git a/bootloader/bios/linker.ld b/bootloader/bios/linker.ld index 87de1da5..22a33b0e 100644 --- a/bootloader/bios/linker.ld +++ b/bootloader/bios/linker.ld @@ -14,4 +14,4 @@ SECTIONS . = ALIGN(512); .bss : { *(.bss) } -} \ No newline at end of file +} diff --git a/bootloader/installer/main.cpp b/bootloader/installer/main.cpp index 8e3f0145..f1d4cc22 100644 --- a/bootloader/installer/main.cpp +++ b/bootloader/installer/main.cpp @@ -42,4 +42,4 @@ int main(int argc, char** argv) std::cout << "bootloader installed" << std::endl; return 0; -} \ No newline at end of file +} diff --git a/kernel/arch/i386/GDT.cpp b/kernel/arch/i386/GDT.cpp index dba89c59..d5ada22b 100644 --- a/kernel/arch/i386/GDT.cpp +++ b/kernel/arch/i386/GDT.cpp @@ -63,7 +63,7 @@ namespace Kernel::GDT uint8_t flags : 4; uint8_t base3; } __attribute__((packed)); - + struct { uint32_t low; @@ -101,7 +101,7 @@ namespace Kernel::GDT { s_tss = new TaskStateSegment(); ASSERT(s_tss); - + memset(s_tss, 0x00, sizeof(TaskStateSegment)); s_tss->ss0 = 0x10; s_tss->esp0 = (uintptr_t)g_boot_stack_top; @@ -127,7 +127,7 @@ namespace Kernel::GDT void initialize() { constexpr uint32_t descriptor_count = 6; - s_gdt = new SegmentDescriptor[descriptor_count]; + s_gdt = new SegmentDescriptor[descriptor_count]; ASSERT(s_gdt); s_gdtr.address = (uint64_t)s_gdt; @@ -144,4 +144,4 @@ namespace Kernel::GDT flush_tss(0x28); } -} \ No newline at end of file +} diff --git a/kernel/arch/i386/IDT.cpp b/kernel/arch/i386/IDT.cpp index 5e6576af..33626a56 100644 --- a/kernel/arch/i386/IDT.cpp +++ b/kernel/arch/i386/IDT.cpp @@ -123,7 +123,7 @@ namespace IDT } dprintln("Spurious irq"); - return; + return; found: if (s_irq_handlers[irq]) s_irq_handlers[irq](); @@ -174,7 +174,7 @@ found: "addl $16, %esp;" "popw %es;" "popw %ds;" - + // NOTE: following instructions are same as in 'popa', except we skip eax // since it holds the return value of the syscall. "popl %edi;" @@ -185,7 +185,7 @@ found: "popl %edx;" "popl %ecx;" "addl $4, %esp;" - + "iret;" ); @@ -267,4 +267,4 @@ found: flush_idt(); } -} \ No newline at end of file +} diff --git a/kernel/arch/i386/MMU.cpp b/kernel/arch/i386/MMU.cpp index 4dbecfda..4946a7ed 100644 --- a/kernel/arch/i386/MMU.cpp +++ b/kernel/arch/i386/MMU.cpp @@ -76,7 +76,7 @@ namespace Kernel { if (s_instance == nullptr) return; - + // Here we copy the s_instances paging structs since they are // global for every process @@ -84,7 +84,7 @@ namespace Kernel uint64_t* pdpt = (uint64_t*)kmalloc(sizeof(uint64_t) * 4, 32); ASSERT(pdpt); - + for (uint32_t pdpte = 0; pdpte < 4; pdpte++) { if (!(global_pdpt[pdpte] & Flags::Present)) diff --git a/kernel/arch/i386/SpinLock.S b/kernel/arch/i386/SpinLock.S index 8d803d82..1b139d6a 100644 --- a/kernel/arch/i386/SpinLock.S +++ b/kernel/arch/i386/SpinLock.S @@ -16,4 +16,4 @@ spinlock_lock_asm: spinlock_unlock_asm: movl 4(%esp), %eax movl $0, (%eax) - ret \ No newline at end of file + ret diff --git a/kernel/arch/i386/linker.ld b/kernel/arch/i386/linker.ld index 14170192..8a5fd7a9 100644 --- a/kernel/arch/i386/linker.ld +++ b/kernel/arch/i386/linker.ld @@ -25,4 +25,4 @@ SECTIONS } g_kernel_end = .; -} \ No newline at end of file +} diff --git a/kernel/arch/x86_64/GDT.cpp b/kernel/arch/x86_64/GDT.cpp index 0637cc28..2617ad51 100644 --- a/kernel/arch/x86_64/GDT.cpp +++ b/kernel/arch/x86_64/GDT.cpp @@ -39,7 +39,7 @@ namespace Kernel::GDT uint8_t flags : 4; uint8_t base3; } __attribute__((packed)); - + struct { uint32_t low; @@ -81,7 +81,7 @@ namespace Kernel::GDT { memset(&s_tss, 0x00, sizeof(TaskStateSegment)); s_tss.iopb = sizeof(TaskStateSegment); - + uint64_t base = (uint64_t)&s_tss; write_entry(s_tss_offset, (uint32_t)base, sizeof(TaskStateSegment), 0x89, 0x0); @@ -122,4 +122,4 @@ namespace Kernel::GDT flush_tss(); } -} \ No newline at end of file +} diff --git a/kernel/arch/x86_64/IDT.cpp b/kernel/arch/x86_64/IDT.cpp index aad574a5..198cc178 100644 --- a/kernel/arch/x86_64/IDT.cpp +++ b/kernel/arch/x86_64/IDT.cpp @@ -121,7 +121,7 @@ namespace Kernel::IDT uint32_t reserved2 : 16; }; }; - + }; static_assert(sizeof(PageFaultError) == 4); @@ -290,7 +290,7 @@ namespace Kernel::IDT break; case ISR::PageFault: signal = SIGSEGV; - break; + break; default: dwarnln("Unhandled exception"); signal = SIGABRT; @@ -305,7 +305,7 @@ namespace Kernel::IDT } ASSERT(Thread::current().state() != Thread::State::Terminated); - + done: return; } diff --git a/kernel/arch/x86_64/PageTable.cpp b/kernel/arch/x86_64/PageTable.cpp index 4913f212..f46c9078 100644 --- a/kernel/arch/x86_64/PageTable.cpp +++ b/kernel/arch/x86_64/PageTable.cpp @@ -138,7 +138,7 @@ namespace Kernel s_global_pml4e = V2P(allocate_zeroed_page_aligned_page()); m_highest_paging_struct = V2P(allocate_zeroed_page_aligned_page()); - + uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct); pml4[511] = s_global_pml4e; @@ -436,7 +436,7 @@ namespace Kernel ASSERT(vaddr % PAGE_SIZE == 0); size_t page_count = range_page_count(vaddr, size); - + LockGuard _(m_lock); for (size_t page = 0; page < page_count; page++) map_page_at(paddr + page * PAGE_SIZE, vaddr + page * PAGE_SIZE, flags); @@ -453,7 +453,7 @@ namespace Kernel uint64_t pdpte = (uc_vaddr >> 30) & 0x1FF; uint64_t pde = (uc_vaddr >> 21) & 0x1FF; uint64_t pte = (uc_vaddr >> 12) & 0x1FF; - + LockGuard _(m_lock); uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct); @@ -533,7 +533,7 @@ namespace Kernel const uint16_t e_pdpte = (uc_vaddr_end >> 30) & 0x1FF; const uint16_t e_pde = (uc_vaddr_end >> 21) & 0x1FF; const uint16_t e_pte = (uc_vaddr_end >> 12) & 0x1FF; - + LockGuard _(m_lock); // Try to find free page that can be mapped without @@ -714,7 +714,7 @@ namespace Kernel if (!(pt[pte] & Flags::Used)) continue; - + if (start == 0) { flags = parse_flags(pt[pte]); diff --git a/kernel/arch/x86_64/interrupts.S b/kernel/arch/x86_64/interrupts.S index 37bea4f8..45acaa6a 100644 --- a/kernel/arch/x86_64/interrupts.S +++ b/kernel/arch/x86_64/interrupts.S @@ -192,4 +192,4 @@ syscall_asm: addq $8, %rsp popaq_no_rax addq $8, %rsp - iretq \ No newline at end of file + iretq diff --git a/kernel/arch/x86_64/linker.ld b/kernel/arch/x86_64/linker.ld index e8c3d9d0..0f22dace 100644 --- a/kernel/arch/x86_64/linker.ld +++ b/kernel/arch/x86_64/linker.ld @@ -35,4 +35,4 @@ SECTIONS *(.bss) } g_kernel_end = .; -} \ No newline at end of file +} diff --git a/kernel/icxxabi.cpp b/kernel/icxxabi.cpp index 976c4d73..211b64a5 100644 --- a/kernel/icxxabi.cpp +++ b/kernel/icxxabi.cpp @@ -46,8 +46,8 @@ void __cxa_finalize(void *f) * TODO: * Note well, however, that deleting a function from here that contains a __dso_handle * means that one link to a shared object file has been terminated. In other words, - * We should monitor this list (optional, of course), since it tells us how many links to - * an object file exist at runtime in a particular application. This can be used to tell + * We should monitor this list (optional, of course), since it tells us how many links to + * an object file exist at runtime in a particular application. This can be used to tell * when a shared object is no longer in use. It is one of many methods, however. **/ //You may insert a prinf() here to tell you whether or not the function gets called. Testing @@ -59,7 +59,7 @@ void __cxa_finalize(void *f) /* ^^^ That if statement is a safeguard... * To make sure we don't call any entries that have already been called and unset at runtime. * Those will contain a value of 0, and calling a function with value 0 - * will cause undefined behaviour. Remember that linear address 0, + * will cause undefined behaviour. Remember that linear address 0, * in a non-virtual address space (physical) contains the IVT and BDA. * * In a virtual environment, the kernel will receive a page fault, and then probably @@ -92,7 +92,7 @@ void __cxa_finalize(void *f) **/ if (__atexit_funcs[i].destructor_func == f) { - /* + /* * Note that in the next line, not every destructor function is a class destructor. * It is perfectly legal to register a non class destructor function as a simple cleanup * function to be called on program termination, in which case, it would not NEED an @@ -113,7 +113,7 @@ void __cxa_finalize(void *f) }; }; -namespace __cxxabiv1 +namespace __cxxabiv1 { /* guard variables */ static Kernel::SpinLock s_spin_lock; diff --git a/kernel/include/kernel/ACPI.h b/kernel/include/kernel/ACPI.h index 69905c22..3a953f89 100644 --- a/kernel/include/kernel/ACPI.h +++ b/kernel/include/kernel/ACPI.h @@ -126,7 +126,7 @@ namespace Kernel SDTHeader* as_header() { return (SDTHeader*)vaddr; } }; - BAN::Vector m_mapped_headers; + BAN::Vector m_mapped_headers; }; } @@ -135,7 +135,7 @@ namespace BAN::Formatter { template void print_argument(F putc, const Kernel::ACPI::SDTHeader& header, const ValueFormat& format) - { + { putc(header.signature[0]); putc(header.signature[1]); putc(header.signature[2]); diff --git a/kernel/include/kernel/API/DirectoryEntry.h b/kernel/include/kernel/API/DirectoryEntry.h index 75cec80b..e51d17cb 100644 --- a/kernel/include/kernel/API/DirectoryEntry.h +++ b/kernel/include/kernel/API/DirectoryEntry.h @@ -18,4 +18,4 @@ namespace Kernel::API DirectoryEntry array[]; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/APIC.h b/kernel/include/kernel/APIC.h index d1a5f836..3553dbfc 100644 --- a/kernel/include/kernel/APIC.h +++ b/kernel/include/kernel/APIC.h @@ -55,7 +55,7 @@ namespace Kernel BAN::Vector m_processors; Kernel::paddr_t m_local_apic_paddr = 0; Kernel::vaddr_t m_local_apic_vaddr = 0; - BAN::Vector m_io_apics; + BAN::Vector m_io_apics; uint8_t m_irq_overrides[0x100] {}; uint8_t m_reserved_gsis[0x100 / 8] {}; }; diff --git a/kernel/include/kernel/CPUID.h b/kernel/include/kernel/CPUID.h index 2f119e33..4daea7aa 100644 --- a/kernel/include/kernel/CPUID.h +++ b/kernel/include/kernel/CPUID.h @@ -7,38 +7,38 @@ namespace CPUID enum Features : uint32_t { - ECX_SSE3 = (uint32_t)1 << 0, + ECX_SSE3 = (uint32_t)1 << 0, ECX_PCLMULQDQ = (uint32_t)1 << 1, ECX_DTES64 = (uint32_t)1 << 2, - ECX_MONITOR = (uint32_t)1 << 3, - ECX_DS_CPL = (uint32_t)1 << 4, - ECX_VMX = (uint32_t)1 << 5, - ECX_SMX = (uint32_t)1 << 6, - ECX_EST = (uint32_t)1 << 7, - ECX_TM2 = (uint32_t)1 << 8, - ECX_SSSE3 = (uint32_t)1 << 9, + ECX_MONITOR = (uint32_t)1 << 3, + ECX_DS_CPL = (uint32_t)1 << 4, + ECX_VMX = (uint32_t)1 << 5, + ECX_SMX = (uint32_t)1 << 6, + ECX_EST = (uint32_t)1 << 7, + ECX_TM2 = (uint32_t)1 << 8, + ECX_SSSE3 = (uint32_t)1 << 9, ECX_CNTX_ID = (uint32_t)1 << 10, ECX_SDBG = (uint32_t)1 << 11, ECX_FMA = (uint32_t)1 << 12, - ECX_CX16 = (uint32_t)1 << 13, - ECX_XTPR = (uint32_t)1 << 14, - ECX_PDCM = (uint32_t)1 << 15, - ECX_PCID = (uint32_t)1 << 17, - ECX_DCA = (uint32_t)1 << 18, - ECX_SSE4_1 = (uint32_t)1 << 19, - ECX_SSE4_2 = (uint32_t)1 << 20, - ECX_X2APIC = (uint32_t)1 << 21, - ECX_MOVBE = (uint32_t)1 << 22, - ECX_POPCNT = (uint32_t)1 << 23, - ECX_TSC_DEADLINE = (uint32_t)1 << 24, - ECX_AES = (uint32_t)1 << 25, - ECX_XSAVE = (uint32_t)1 << 26, - ECX_OSXSAVE = (uint32_t)1 << 27, + ECX_CX16 = (uint32_t)1 << 13, + ECX_XTPR = (uint32_t)1 << 14, + ECX_PDCM = (uint32_t)1 << 15, + ECX_PCID = (uint32_t)1 << 17, + ECX_DCA = (uint32_t)1 << 18, + ECX_SSE4_1 = (uint32_t)1 << 19, + ECX_SSE4_2 = (uint32_t)1 << 20, + ECX_X2APIC = (uint32_t)1 << 21, + ECX_MOVBE = (uint32_t)1 << 22, + ECX_POPCNT = (uint32_t)1 << 23, + ECX_TSC_DEADLINE = (uint32_t)1 << 24, + ECX_AES = (uint32_t)1 << 25, + ECX_XSAVE = (uint32_t)1 << 26, + ECX_OSXSAVE = (uint32_t)1 << 27, ECX_AVX = (uint32_t)1 << 28, ECX_F16C = (uint32_t)1 << 29, ECX_RDRND = (uint32_t)1 << 30, ECX_HYPERVISOR = (uint32_t)1 << 31, - + EDX_FPU = (uint32_t)1 << 0, EDX_VME = (uint32_t)1 << 1, EDX_DE = (uint32_t)1 << 2, @@ -79,4 +79,4 @@ namespace CPUID bool is_64_bit(); bool has_nxe(); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/CriticalScope.h b/kernel/include/kernel/CriticalScope.h index 62bcb468..33b7baf0 100644 --- a/kernel/include/kernel/CriticalScope.h +++ b/kernel/include/kernel/CriticalScope.h @@ -27,4 +27,4 @@ namespace Kernel size_t m_flags; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Debug.h b/kernel/include/kernel/Debug.h index 13721edd..4d8c5a9a 100644 --- a/kernel/include/kernel/Debug.h +++ b/kernel/include/kernel/Debug.h @@ -61,4 +61,4 @@ namespace Debug static void lock(); static void unlock(); }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Device/Device.h b/kernel/include/kernel/Device/Device.h index 0fa68681..53fbb37a 100644 --- a/kernel/include/kernel/Device/Device.h +++ b/kernel/include/kernel/Device/Device.h @@ -52,4 +52,4 @@ namespace Kernel } }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Device/FramebufferDevice.h b/kernel/include/kernel/Device/FramebufferDevice.h index a6c20eaf..ec5502fe 100644 --- a/kernel/include/kernel/Device/FramebufferDevice.h +++ b/kernel/include/kernel/Device/FramebufferDevice.h @@ -50,4 +50,4 @@ namespace Kernel friend class FramebufferMemoryRegion; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Device/NullDevice.h b/kernel/include/kernel/Device/NullDevice.h index ec748f92..57009b2e 100644 --- a/kernel/include/kernel/Device/NullDevice.h +++ b/kernel/include/kernel/Device/NullDevice.h @@ -27,4 +27,4 @@ namespace Kernel const dev_t m_rdev; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Device/ZeroDevice.h b/kernel/include/kernel/Device/ZeroDevice.h index 90aa3f8a..45183488 100644 --- a/kernel/include/kernel/Device/ZeroDevice.h +++ b/kernel/include/kernel/Device/ZeroDevice.h @@ -25,4 +25,4 @@ namespace Kernel const dev_t m_rdev; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Errors.h b/kernel/include/kernel/Errors.h index ae94a198..803e7658 100644 --- a/kernel/include/kernel/Errors.h +++ b/kernel/include/kernel/Errors.h @@ -33,4 +33,4 @@ namespace Kernel BAN::StringView error_string(ErrorCode); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/DevFS/FileSystem.h b/kernel/include/kernel/FS/DevFS/FileSystem.h index de0a4a97..a23ac63f 100644 --- a/kernel/include/kernel/FS/DevFS/FileSystem.h +++ b/kernel/include/kernel/FS/DevFS/FileSystem.h @@ -13,7 +13,7 @@ namespace Kernel public: static void initialize(); static DevFileSystem& get(); - + void initialize_device_updater(); void add_device(BAN::RefPtr); @@ -39,4 +39,4 @@ namespace Kernel volatile bool m_should_sync { false }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/Ext2/Definitions.h b/kernel/include/kernel/FS/Ext2/Definitions.h index 24bd476e..7c1c3f8a 100644 --- a/kernel/include/kernel/FS/Ext2/Definitions.h +++ b/kernel/include/kernel/FS/Ext2/Definitions.h @@ -259,4 +259,4 @@ namespace Kernel::Ext2 } -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/Ext2/FileSystem.h b/kernel/include/kernel/FS/Ext2/FileSystem.h index cb1dabb0..167410f6 100644 --- a/kernel/include/kernel/FS/Ext2/FileSystem.h +++ b/kernel/include/kernel/FS/Ext2/FileSystem.h @@ -27,7 +27,7 @@ namespace Kernel { m_used = false; } - + size_t size() const { return m_buffer.size(); } uint8_t* data() { return m_buffer.data(); } @@ -44,7 +44,7 @@ namespace Kernel bool& m_used; }; - public: + public: static BAN::ErrorOr create(BAN::RefPtr); virtual BAN::RefPtr root_inode() override { return m_root_inode; } @@ -120,4 +120,4 @@ namespace Kernel friend class Ext2Inode; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/Ext2/Inode.h b/kernel/include/kernel/FS/Ext2/Inode.h index 390b5a47..1160d70f 100644 --- a/kernel/include/kernel/FS/Ext2/Inode.h +++ b/kernel/include/kernel/FS/Ext2/Inode.h @@ -35,7 +35,7 @@ namespace Kernel virtual BAN::ErrorOr create_file_impl(BAN::StringView, mode_t, uid_t, gid_t) override; virtual BAN::ErrorOr create_directory_impl(BAN::StringView, mode_t, uid_t, gid_t) override; virtual BAN::ErrorOr unlink_impl(BAN::StringView) override; - + virtual BAN::ErrorOr link_target_impl() override; virtual BAN::ErrorOr read_impl(off_t, BAN::ByteSpan) override; @@ -81,4 +81,4 @@ namespace Kernel friend class BAN::RefPtr; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/FileSystem.h b/kernel/include/kernel/FS/FileSystem.h index 5b1cb96b..de7258ef 100644 --- a/kernel/include/kernel/FS/FileSystem.h +++ b/kernel/include/kernel/FS/FileSystem.h @@ -12,4 +12,4 @@ namespace Kernel virtual BAN::RefPtr root_inode() = 0; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index dbc6c394..5fbe8564 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -131,4 +131,4 @@ namespace Kernel friend class FileBackedRegion; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/Pipe.h b/kernel/include/kernel/FS/Pipe.h index 6d90c572..f5b11f00 100644 --- a/kernel/include/kernel/FS/Pipe.h +++ b/kernel/include/kernel/FS/Pipe.h @@ -50,4 +50,4 @@ namespace Kernel uint32_t m_writing_count { 1 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/ProcFS/FileSystem.h b/kernel/include/kernel/FS/ProcFS/FileSystem.h index 159cdfd3..3337269d 100644 --- a/kernel/include/kernel/FS/ProcFS/FileSystem.h +++ b/kernel/include/kernel/FS/ProcFS/FileSystem.h @@ -20,4 +20,4 @@ namespace Kernel ProcFileSystem(); }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/ProcFS/Inode.h b/kernel/include/kernel/FS/ProcFS/Inode.h index 93b74116..1323195e 100644 --- a/kernel/include/kernel/FS/ProcFS/Inode.h +++ b/kernel/include/kernel/FS/ProcFS/Inode.h @@ -47,7 +47,7 @@ namespace Kernel private: ProcROInode(Process&, size_t (Process::*)(off_t, BAN::ByteSpan) const, TmpFileSystem&, const TmpInodeInfo&); - + private: Process& m_process; size_t (Process::*m_callback)(off_t, BAN::ByteSpan) const; diff --git a/kernel/include/kernel/FS/TmpFS/FileSystem.h b/kernel/include/kernel/FS/TmpFS/FileSystem.h index 1cca2d65..2148aa74 100644 --- a/kernel/include/kernel/FS/TmpFS/FileSystem.h +++ b/kernel/include/kernel/FS/TmpFS/FileSystem.h @@ -177,4 +177,4 @@ namespace Kernel } } -} \ No newline at end of file +} diff --git a/kernel/include/kernel/FS/VirtualFileSystem.h b/kernel/include/kernel/FS/VirtualFileSystem.h index 94e83e05..0d3be37c 100644 --- a/kernel/include/kernel/FS/VirtualFileSystem.h +++ b/kernel/include/kernel/FS/VirtualFileSystem.h @@ -44,4 +44,4 @@ namespace Kernel BAN::Vector m_mount_points; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Font.h b/kernel/include/kernel/Font.h index 0daecf25..a534dfb6 100644 --- a/kernel/include/kernel/Font.h +++ b/kernel/include/kernel/Font.h @@ -32,4 +32,4 @@ namespace Kernel uint32_t m_pitch = 0; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/GDT.h b/kernel/include/kernel/GDT.h index 5f5d3093..a8245d5e 100644 --- a/kernel/include/kernel/GDT.h +++ b/kernel/include/kernel/GDT.h @@ -13,4 +13,4 @@ namespace Kernel::GDT void initialize(); void set_tss_stack(uintptr_t); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/IDT.h b/kernel/include/kernel/IDT.h index ccf7c97b..294de992 100644 --- a/kernel/include/kernel/IDT.h +++ b/kernel/include/kernel/IDT.h @@ -10,4 +10,4 @@ namespace Kernel::IDT void initialize(); [[noreturn]] void force_triple_fault(); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/IO.h b/kernel/include/kernel/IO.h index 81eafe12..bce283fc 100644 --- a/kernel/include/kernel/IO.h +++ b/kernel/include/kernel/IO.h @@ -62,4 +62,4 @@ namespace IO outb(0x80, 0); } -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Input/KeyEvent.h b/kernel/include/kernel/Input/KeyEvent.h index b854ae06..f6661373 100644 --- a/kernel/include/kernel/Input/KeyEvent.h +++ b/kernel/include/kernel/Input/KeyEvent.h @@ -95,4 +95,4 @@ namespace Kernel::Input Key key_event_to_key(KeyEvent); const char* key_to_utf8(Key key, uint16_t modifier); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Input/MouseEvent.h b/kernel/include/kernel/Input/MouseEvent.h index 41db5097..5567c4a7 100644 --- a/kernel/include/kernel/Input/MouseEvent.h +++ b/kernel/include/kernel/Input/MouseEvent.h @@ -42,7 +42,7 @@ namespace Kernel::Input MouseButtonEvent button_event; MouseMoveEvent move_event; MouseScrollEvent scroll_event; - }; + }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/InterruptController.h b/kernel/include/kernel/InterruptController.h index 8896d82a..448d09b6 100644 --- a/kernel/include/kernel/InterruptController.h +++ b/kernel/include/kernel/InterruptController.h @@ -53,4 +53,4 @@ namespace Kernel bool interrupts_enabled(); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/InterruptStack.h b/kernel/include/kernel/InterruptStack.h index 84416b5f..2ed66d2e 100644 --- a/kernel/include/kernel/InterruptStack.h +++ b/kernel/include/kernel/InterruptStack.h @@ -14,4 +14,4 @@ namespace Kernel uint64_t ss; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/LockGuard.h b/kernel/include/kernel/LockGuard.h index a1bd27e0..015ba71e 100644 --- a/kernel/include/kernel/LockGuard.h +++ b/kernel/include/kernel/LockGuard.h @@ -15,7 +15,7 @@ namespace Kernel LockGuard(Lock& lock) : m_lock(lock) { - m_lock.lock(); + m_lock.lock(); } ~LockGuard() @@ -27,4 +27,4 @@ namespace Kernel Lock& m_lock; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/MMIO.h b/kernel/include/kernel/MMIO.h index 9b9cd2d3..462b5bb9 100644 --- a/kernel/include/kernel/MMIO.h +++ b/kernel/include/kernel/MMIO.h @@ -46,4 +46,4 @@ namespace MMIO return *(volatile uint64_t*)addr; } -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/DMARegion.h b/kernel/include/kernel/Memory/DMARegion.h index 0f97c64d..7fa5cde0 100644 --- a/kernel/include/kernel/Memory/DMARegion.h +++ b/kernel/include/kernel/Memory/DMARegion.h @@ -4,7 +4,7 @@ namespace Kernel { - + class DMARegion { public: @@ -27,4 +27,4 @@ namespace Kernel const paddr_t m_paddr; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/FileBackedRegion.h b/kernel/include/kernel/Memory/FileBackedRegion.h index 45cf9f41..dcbf2e96 100644 --- a/kernel/include/kernel/Memory/FileBackedRegion.h +++ b/kernel/include/kernel/Memory/FileBackedRegion.h @@ -46,4 +46,4 @@ namespace Kernel BAN::RefPtr m_shared_data; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/MemoryBackedRegion.h b/kernel/include/kernel/Memory/MemoryBackedRegion.h index 087bdd73..627b3a08 100644 --- a/kernel/include/kernel/Memory/MemoryBackedRegion.h +++ b/kernel/include/kernel/Memory/MemoryBackedRegion.h @@ -9,7 +9,7 @@ namespace Kernel { BAN_NON_COPYABLE(MemoryBackedRegion); BAN_NON_MOVABLE(MemoryBackedRegion); - + public: static BAN::ErrorOr> create(PageTable&, size_t size, AddressRange, Type, PageTable::flags_t); ~MemoryBackedRegion(); @@ -29,4 +29,4 @@ namespace Kernel MemoryBackedRegion(PageTable&, size_t size, Type, PageTable::flags_t); }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/MemoryRegion.h b/kernel/include/kernel/Memory/MemoryRegion.h index 9bd4de7a..f6a7142c 100644 --- a/kernel/include/kernel/Memory/MemoryRegion.h +++ b/kernel/include/kernel/Memory/MemoryRegion.h @@ -48,7 +48,7 @@ namespace Kernel BAN::ErrorOr allocate_page_containing(vaddr_t address); virtual BAN::ErrorOr> clone(PageTable& new_page_table) = 0; - + protected: MemoryRegion(PageTable&, size_t size, Type type, PageTable::flags_t flags); BAN::ErrorOr initialize(AddressRange); @@ -64,4 +64,4 @@ namespace Kernel size_t m_physical_page_count { 0 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/PageTable.h b/kernel/include/kernel/Memory/PageTable.h index 96c527a9..ccd3d2ab 100644 --- a/kernel/include/kernel/Memory/PageTable.h +++ b/kernel/include/kernel/Memory/PageTable.h @@ -19,7 +19,7 @@ namespace Kernel { public: using flags_t = uint16_t; - enum Flags : flags_t + enum Flags : flags_t { Present = (1 << 0), ReadWrite = (1 << 1), @@ -107,7 +107,7 @@ namespace Kernel uint64_t get_page_data(vaddr_t) const; void initialize_kernel(); void map_kernel_memory(); - void prepare_fast_page(); + void prepare_fast_page(); static void invalidate(vaddr_t); private: diff --git a/kernel/include/kernel/Memory/PageTableScope.h b/kernel/include/kernel/Memory/PageTableScope.h index 62955801..90eb74c4 100644 --- a/kernel/include/kernel/Memory/PageTableScope.h +++ b/kernel/include/kernel/Memory/PageTableScope.h @@ -30,4 +30,4 @@ namespace Kernel PageTable& m_temp; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/PhysicalRange.h b/kernel/include/kernel/Memory/PhysicalRange.h index 7875a7e0..7883a26b 100644 --- a/kernel/include/kernel/Memory/PhysicalRange.h +++ b/kernel/include/kernel/Memory/PhysicalRange.h @@ -30,7 +30,7 @@ namespace Kernel private: unsigned long long* ull_bitmap_ptr() { return (unsigned long long*)m_vaddr; } const unsigned long long* ull_bitmap_ptr() const { return (const unsigned long long*)m_vaddr; } - + paddr_t paddr_for_bit(unsigned long long) const; unsigned long long bit_for_paddr(paddr_t paddr) const; @@ -47,4 +47,4 @@ namespace Kernel size_t m_free_pages { 0 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/Types.h b/kernel/include/kernel/Memory/Types.h index ad883dfc..beecfaa4 100644 --- a/kernel/include/kernel/Memory/Types.h +++ b/kernel/include/kernel/Memory/Types.h @@ -20,4 +20,4 @@ namespace Kernel using vaddr_t = uintptr_t; using paddr_t = uintptr_t; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Memory/VirtualRange.h b/kernel/include/kernel/Memory/VirtualRange.h index 849fcbb7..a5c578e6 100644 --- a/kernel/include/kernel/Memory/VirtualRange.h +++ b/kernel/include/kernel/Memory/VirtualRange.h @@ -48,4 +48,4 @@ namespace Kernel PageTable::flags_t m_flags { 0 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Networking/E1000.h b/kernel/include/kernel/Networking/E1000.h index a5246ce0..d74a1bdd 100644 --- a/kernel/include/kernel/Networking/E1000.h +++ b/kernel/include/kernel/Networking/E1000.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -10,7 +11,7 @@ namespace Kernel { - class E1000 final : public NetworkDriver + class E1000 final : public NetworkDriver, public Interruptable { public: static bool probe(PCI::Device&); @@ -23,9 +24,11 @@ namespace Kernel virtual bool link_up() override { return m_link_up; } virtual int link_speed() override; + virtual void handle_irq() override { ASSERT_NOT_REACHED(); } + private: - E1000() = default; - BAN::ErrorOr initialize(PCI::Device&); + E1000(PCI::Device& pci_device) : m_pci_device(pci_device) {} + BAN::ErrorOr initialize(); static void interrupt_handler(); @@ -40,11 +43,12 @@ namespace Kernel void initialize_tx(); void enable_link(); - void enable_interrupts(); - + BAN::ErrorOr enable_interrupts(); + void handle_receive(); private: + PCI::Device& m_pci_device; BAN::UniqPtr m_bar_region; bool m_has_eerprom { false }; uint8_t m_mac_address[6] {}; diff --git a/kernel/include/kernel/Networking/NetworkDriver.h b/kernel/include/kernel/Networking/NetworkDriver.h index 23a2c929..96c9b6fd 100644 --- a/kernel/include/kernel/Networking/NetworkDriver.h +++ b/kernel/include/kernel/Networking/NetworkDriver.h @@ -17,4 +17,4 @@ namespace Kernel virtual int link_speed() = 0; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/OpenFileDescriptorSet.h b/kernel/include/kernel/OpenFileDescriptorSet.h index 378b791b..df2290dd 100644 --- a/kernel/include/kernel/OpenFileDescriptorSet.h +++ b/kernel/include/kernel/OpenFileDescriptorSet.h @@ -78,4 +78,4 @@ namespace Kernel BAN::Array, OPEN_MAX> m_open_files; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/PCI.h b/kernel/include/kernel/PCI.h index 4c47aa96..e2838184 100644 --- a/kernel/include/kernel/PCI.h +++ b/kernel/include/kernel/PCI.h @@ -130,7 +130,7 @@ namespace Kernel::PCI public: static void initialize(); static PCIManager& get(); - + const BAN::Vector& devices() const { return m_devices; } static uint32_t read_config_dword(uint8_t bus, uint8_t dev, uint8_t func, uint8_t offset); @@ -153,4 +153,4 @@ namespace Kernel::PCI BAN::Vector m_devices; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Panic.h b/kernel/include/kernel/Panic.h index 4ef0f285..753aa4fe 100644 --- a/kernel/include/kernel/Panic.h +++ b/kernel/include/kernel/Panic.h @@ -26,4 +26,4 @@ namespace Kernel::detail __builtin_unreachable(); } -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index ae794da5..aa291498 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -225,4 +225,4 @@ namespace Kernel friend class Thread; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Scheduler.h b/kernel/include/kernel/Scheduler.h index 02b72b74..1f132a9d 100644 --- a/kernel/include/kernel/Scheduler.h +++ b/kernel/include/kernel/Scheduler.h @@ -76,4 +76,4 @@ namespace Kernel friend class Process; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Semaphore.h b/kernel/include/kernel/Semaphore.h index 0a1a151b..579732be 100644 --- a/kernel/include/kernel/Semaphore.h +++ b/kernel/include/kernel/Semaphore.h @@ -10,4 +10,4 @@ namespace Kernel void unblock(); }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/SpinLock.h b/kernel/include/kernel/SpinLock.h index 0c6388dd..82bd1138 100644 --- a/kernel/include/kernel/SpinLock.h +++ b/kernel/include/kernel/SpinLock.h @@ -43,7 +43,7 @@ namespace Kernel { BAN_NON_COPYABLE(RecursivePrioritySpinLock); BAN_NON_MOVABLE(RecursivePrioritySpinLock); - + public: RecursivePrioritySpinLock() = default; void lock(); diff --git a/kernel/include/kernel/Storage/ATA/AHCI/Definitions.h b/kernel/include/kernel/Storage/ATA/AHCI/Definitions.h index a2727bd4..1e63cbd8 100644 --- a/kernel/include/kernel/Storage/ATA/AHCI/Definitions.h +++ b/kernel/include/kernel/Storage/ATA/AHCI/Definitions.h @@ -37,68 +37,68 @@ namespace Kernel struct FISRegisterH2D { uint8_t fis_type; // FIS_TYPE_REGISTER_H2D - + uint8_t pm_port : 4; // Port multiplier uint8_t __reserved0 : 3; uint8_t c : 1; // 1: Command, 0: Control - + uint8_t command; uint8_t feature_lo; // Feature register, 7:0 - + uint8_t lba0; // LBA low register, 7:0 uint8_t lba1; // LBA mid register, 15:8 uint8_t lba2; // LBA high register, 23:16 uint8_t device; - + uint8_t lba3; // LBA register, 31:24 uint8_t lba4; // LBA register, 39:32 uint8_t lba5; // LBA register, 47:40 uint8_t feature_hi; // Feature register, 15:8 - + uint8_t count_lo; // Count register, 7:0 uint8_t count_hi; // Count register, 15:8 uint8_t icc; // Isochronous command completion uint8_t control; - + uint8_t __reserved1[4]; } __attribute__((packed)); struct FISRegisterD2H { uint8_t fis_type; // FIS_TYPE_REGISTER_D2H - + uint8_t pm_port : 4; // Port multiplier uint8_t __reserved0 : 2; uint8_t i : 1; // Interrupt bit uint8_t __reserved1 : 1; - + uint8_t status; uint8_t error; - + uint8_t lba0; // LBA low register, 7:0 uint8_t lba1; // LBA mid register, 15:8 uint8_t lba2; // LBA high register, 23:16 uint8_t device; - + uint8_t lba3; // LBA register, 31:24 uint8_t lba4; // LBA register, 39:32 uint8_t lba5; // LBA register, 47:40 uint8_t __reserved2; - + uint8_t count_lo; // Count register, 7:0 uint8_t count_hi; // Count register, 15:8 uint8_t __reserved3[2]; - + uint8_t __reserved4[4]; } __attribute__((packed)); struct FISDataBI { uint8_t fis_type; // FIS_TYPE_DATA - + uint8_t pm_port : 4; // Port multiplier uint8_t __reserved0 : 4; - + uint8_t __reserved1[2]; uint32_t data[0]; // Payload (1 - 2048 dwords) @@ -122,31 +122,31 @@ namespace Kernel struct PIOSetupD2H { uint8_t fis_type; // FIS_TYPE_PIO_SETUP - + uint8_t pm_port : 4; // Port multiplier uint8_t __reserved0 : 1; uint8_t d : 1; // Data transfer direction, 1 - device to host uint8_t i : 1; // Interrupt bit uint8_t __reserved1 : 1; - + uint8_t status; uint8_t error; - + uint8_t lba0; // LBA low register, 7:0 uint8_t lba1; // LBA mid register, 15:8 uint8_t lba2; // LBA high register, 23:16 uint8_t device; - + uint8_t lba3; // LBA register, 31:24 uint8_t lba4; // LBA register, 39:32 uint8_t lba5; // LBA register, 47:40 uint8_t __reserved2; - + uint8_t count_lo; // Count register, 7:0 uint8_t count_hi; // Count register, 15:8 uint8_t __reserved3; uint8_t e_status; // New value of status register - + uint16_t tc; // Transfer count uint8_t __reserved4[2]; } __attribute__((packed)); @@ -154,13 +154,13 @@ namespace Kernel struct DMASetupBI { uint8_t fis_type; // FIS_TYPE_DMA_SETUP - + uint8_t pm_port : 4; // Port multiplier uint8_t __reserved0 : 1; uint8_t d : 1; // Data transfer direction, 1 - device to host uint8_t i : 1; // Interrupt bit uint8_t a : 1; // Auto-activate. Specifies if DMA Activate FIS is needed - + uint8_t __reserved1[2]; uint64_t dma_buffer_id; // DMA Buffer Identifier. Used to Identify DMA buffer in host memory. @@ -211,11 +211,11 @@ namespace Kernel uint32_t em_ctl; // 0x20, Enclosure management control uint32_t cap2; // 0x24, Host capabilities extended uint32_t bohc; // 0x28, BIOS/OS handoff control and status - + uint8_t __reserved0[0xA0-0x2C]; - + uint8_t vendor[0x100-0xA0]; - + HBAPortMemorySpace ports[0]; // 1 - 32 ports } __attribute__((packed)); @@ -223,17 +223,17 @@ namespace Kernel { DMASetupBI dsfis; uint8_t pad0[4]; - + PIOSetupD2H psfis; uint8_t pad1[12]; - + FISRegisterD2H rfis; uint8_t pad2[4]; - + SetDeviceBitsD2H sdbfis; - + uint8_t ufis[64]; - + uint8_t __reserved[0x100-0xA0]; } __attribute__((packed)); @@ -243,20 +243,20 @@ namespace Kernel uint8_t a : 1; // ATAPI uint8_t w : 1; // Write, 1: H2D, 0: D2H uint8_t p : 1; // Prefetchable - + uint8_t r : 1; // Reset uint8_t b : 1; // BIST uint8_t c : 1; // Clear busy upon R_OK uint8_t __reserved0 : 1; uint8_t pmp : 4; // Port multiplier port - + uint16_t prdtl; // Physical region descriptor table length in entries - + volatile uint32_t prdbc; // Physical region descriptor byte count transferred - + uint32_t ctba; // Command table descriptor base address uint32_t ctbau; // Command table descriptor base address upper 32 bits - + uint32_t __reserved1[4]; } __attribute__((packed)); diff --git a/kernel/include/kernel/Storage/ATA/AHCI/Device.h b/kernel/include/kernel/Storage/ATA/AHCI/Device.h index 225c685b..bf6fe840 100644 --- a/kernel/include/kernel/Storage/ATA/AHCI/Device.h +++ b/kernel/include/kernel/Storage/ATA/AHCI/Device.h @@ -30,13 +30,13 @@ namespace Kernel BAN::Optional find_free_command_slot(); void handle_irq(); - + BAN::ErrorOr block_until_command_completed(uint32_t command_slot); private: BAN::RefPtr m_controller; volatile HBAPortMemorySpace* const m_port; - + BAN::UniqPtr m_dma_region; // Intermediate read/write buffer // TODO: can we read straight to user buffer? @@ -45,4 +45,4 @@ namespace Kernel friend class AHCIController; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/ATA/ATABus.h b/kernel/include/kernel/Storage/ATA/ATABus.h index 95bdda8e..f192613a 100644 --- a/kernel/include/kernel/Storage/ATA/ATABus.h +++ b/kernel/include/kernel/Storage/ATA/ATABus.h @@ -61,4 +61,4 @@ namespace Kernel friend class ATAController; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/ATA/ATAController.h b/kernel/include/kernel/Storage/ATA/ATAController.h index 82278287..49a5cc6a 100644 --- a/kernel/include/kernel/Storage/ATA/ATAController.h +++ b/kernel/include/kernel/Storage/ATA/ATAController.h @@ -24,4 +24,4 @@ namespace Kernel PCI::Device& m_pci_device; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/ATA/ATADefinitions.h b/kernel/include/kernel/Storage/ATA/ATADefinitions.h index 0ae0b5f5..3dc31bfd 100644 --- a/kernel/include/kernel/Storage/ATA/ATADefinitions.h +++ b/kernel/include/kernel/Storage/ATA/ATADefinitions.h @@ -56,4 +56,4 @@ #define ATA_COMMANDSET_LBA48_SUPPORTED (1 << 26) #define ATA_CAPABILITIES_LBA (1 << 9) -#define ATA_CAPABILITIES_DMA (1 << 8) \ No newline at end of file +#define ATA_CAPABILITIES_DMA (1 << 8) diff --git a/kernel/include/kernel/Storage/ATA/ATADevice.h b/kernel/include/kernel/Storage/ATA/ATADevice.h index b91e27b5..9446d40b 100644 --- a/kernel/include/kernel/Storage/ATA/ATADevice.h +++ b/kernel/include/kernel/Storage/ATA/ATADevice.h @@ -39,7 +39,7 @@ namespace Kernel ATABaseDevice(); BAN::ErrorOr initialize(BAN::Span identify_data); - protected: + protected: uint16_t m_signature; uint16_t m_capabilities; uint32_t m_command_set; @@ -62,7 +62,7 @@ namespace Kernel private: ATADevice(BAN::RefPtr, ATABus::DeviceType, bool is_secodary); - + virtual BAN::ErrorOr read_sectors_impl(uint64_t, uint64_t, BAN::ByteSpan) override; virtual BAN::ErrorOr write_sectors_impl(uint64_t, uint64_t, BAN::ConstByteSpan) override; diff --git a/kernel/include/kernel/Storage/DiskCache.h b/kernel/include/kernel/Storage/DiskCache.h index c0b082df..006a113f 100644 --- a/kernel/include/kernel/Storage/DiskCache.h +++ b/kernel/include/kernel/Storage/DiskCache.h @@ -40,4 +40,4 @@ namespace Kernel BAN::Array m_sync_cache; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/NVMe/Definitions.h b/kernel/include/kernel/Storage/NVMe/Definitions.h index 28151d6d..dd6d62d6 100644 --- a/kernel/include/kernel/Storage/NVMe/Definitions.h +++ b/kernel/include/kernel/Storage/NVMe/Definitions.h @@ -149,7 +149,7 @@ namespace Kernel::NVMe uint8_t cns; uint8_t __reserved1; uint16_t cntid; - // dword 11 + // dword 11 uint16_t cnsid; uint8_t __reserved2; uint8_t csi; @@ -292,4 +292,4 @@ namespace Kernel::NVMe } __attribute__((packed)); static_assert(sizeof(NamespaceIdentify) == 0x1000); -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/StorageController.h b/kernel/include/kernel/Storage/StorageController.h index 86eec0b6..2c1318b1 100644 --- a/kernel/include/kernel/Storage/StorageController.h +++ b/kernel/include/kernel/Storage/StorageController.h @@ -12,4 +12,4 @@ namespace Kernel virtual BAN::ErrorOr initialize() = 0; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Storage/StorageDevice.h b/kernel/include/kernel/Storage/StorageDevice.h index a2ec6ae1..194908ed 100644 --- a/kernel/include/kernel/Storage/StorageDevice.h +++ b/kernel/include/kernel/Storage/StorageDevice.h @@ -47,4 +47,4 @@ namespace Kernel friend class DiskCache; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Terminal/Serial.h b/kernel/include/kernel/Terminal/Serial.h index 4abea34e..d666bbf4 100644 --- a/kernel/include/kernel/Terminal/Serial.h +++ b/kernel/include/kernel/Terminal/Serial.h @@ -40,7 +40,7 @@ namespace Kernel { public: static BAN::ErrorOr> create(Serial); - + virtual uint32_t width() const override; virtual uint32_t height() const override; @@ -69,4 +69,4 @@ namespace Kernel const dev_t m_rdev; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Terminal/TTY.h b/kernel/include/kernel/Terminal/TTY.h index c5722dfc..8daa278d 100644 --- a/kernel/include/kernel/Terminal/TTY.h +++ b/kernel/include/kernel/Terminal/TTY.h @@ -15,7 +15,7 @@ namespace Kernel { public: void set_termios(const termios& termios) { m_termios = termios; } - termios get_termios() const { return m_termios; } + termios get_termios() const { return m_termios; } virtual void set_font(const Font&) {}; void set_foreground_pgrp(pid_t pgrp) { m_foreground_pgrp = pgrp; } diff --git a/kernel/include/kernel/Terminal/TerminalDriver.h b/kernel/include/kernel/Terminal/TerminalDriver.h index 18aa0958..e31133c0 100644 --- a/kernel/include/kernel/Terminal/TerminalDriver.h +++ b/kernel/include/kernel/Terminal/TerminalDriver.h @@ -58,4 +58,4 @@ namespace TerminalColor static constexpr TerminalDriver::Color BRIGHT_MAGENTA = 0xFF55FF; static constexpr TerminalDriver::Color BRIGHT_YELLOW = 0xFFFF55; static constexpr TerminalDriver::Color BRIGHT_WHITE = 0xFFFFFF; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Terminal/termios.h b/kernel/include/kernel/Terminal/termios.h index 4986c09d..82f80630 100644 --- a/kernel/include/kernel/Terminal/termios.h +++ b/kernel/include/kernel/Terminal/termios.h @@ -9,4 +9,4 @@ namespace Kernel bool echo { true }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Thread.h b/kernel/include/kernel/Thread.h index 7d1e78a6..08f8530b 100644 --- a/kernel/include/kernel/Thread.h +++ b/kernel/include/kernel/Thread.h @@ -17,7 +17,7 @@ namespace Kernel { BAN_NON_COPYABLE(Thread); BAN_NON_MOVABLE(Thread); - + public: using entry_t = void(*)(void*); @@ -95,7 +95,7 @@ namespace Kernel private: Thread(pid_t tid, Process*); void on_exit(); - + void validate_stack() const; private: @@ -125,4 +125,4 @@ namespace Kernel friend class Scheduler; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Timer/HPET.h b/kernel/include/kernel/Timer/HPET.h index 8ad149dd..0b7aa714 100644 --- a/kernel/include/kernel/Timer/HPET.h +++ b/kernel/include/kernel/Timer/HPET.h @@ -29,4 +29,4 @@ namespace Kernel vaddr_t m_mmio_base { 0 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Timer/PIT.h b/kernel/include/kernel/Timer/PIT.h index dc9c149f..4f023f6d 100644 --- a/kernel/include/kernel/Timer/PIT.h +++ b/kernel/include/kernel/Timer/PIT.h @@ -24,4 +24,4 @@ namespace Kernel volatile uint64_t m_system_time { 0 }; }; -} \ No newline at end of file +} diff --git a/kernel/include/kernel/Timer/Timer.h b/kernel/include/kernel/Timer/Timer.h index a2e0cd5a..1afe6461 100644 --- a/kernel/include/kernel/Timer/Timer.h +++ b/kernel/include/kernel/Timer/Timer.h @@ -28,7 +28,7 @@ namespace Kernel virtual uint64_t ms_since_boot() const override; virtual uint64_t ns_since_boot() const override; virtual timespec time_since_boot() const override; - + void sleep(uint64_t ms) const; timespec real_time() const; @@ -44,4 +44,4 @@ namespace Kernel BAN::UniqPtr m_timer; }; -} \ No newline at end of file +} diff --git a/kernel/kernel/ACPI.cpp b/kernel/kernel/ACPI.cpp index 3983eb8b..263256d4 100644 --- a/kernel/kernel/ACPI.cpp +++ b/kernel/kernel/ACPI.cpp @@ -171,7 +171,7 @@ namespace Kernel size_t needed_pages = range_page_count(header_paddr, header_length); vaddr_t page_vaddr = PageTable::kernel().reserve_free_contiguous_pages(needed_pages, KERNEL_OFFSET); ASSERT(page_vaddr); - + PageTable::kernel().map_range_at( header_paddr & PAGE_ADDR_MASK, page_vaddr, @@ -194,7 +194,7 @@ namespace Kernel paddr_t header_paddr = (m_entry_size == 4) ? ((uint32_t*)m_header_table_vaddr)[i] : ((uint64_t*)m_header_table_vaddr)[i]; - + vaddr_t header_vaddr = map_header(header_paddr); if (header_vaddr == 0) continue; @@ -252,4 +252,4 @@ namespace Kernel return nullptr; } -} \ No newline at end of file +} diff --git a/kernel/kernel/APIC.cpp b/kernel/kernel/APIC.cpp index 568b0b5f..6098f1e1 100644 --- a/kernel/kernel/APIC.cpp +++ b/kernel/kernel/APIC.cpp @@ -218,7 +218,7 @@ namespace Kernel void APIC::eoi(uint8_t) { - write_to_local_apic(LAPIC_EIO_REG, 0); + write_to_local_apic(LAPIC_EIO_REG, 0); } void APIC::enable_irq(uint8_t irq) @@ -305,7 +305,7 @@ namespace Kernel for (int irq = 0; irq <= 0xFF; irq++) { uint32_t gsi = m_irq_overrides[irq]; - + IOAPIC* ioapic = nullptr; for (IOAPIC& io : m_io_apics) { diff --git a/kernel/kernel/BootInfo.cpp b/kernel/kernel/BootInfo.cpp index 13fb0b07..5545ba66 100644 --- a/kernel/kernel/BootInfo.cpp +++ b/kernel/kernel/BootInfo.cpp @@ -36,7 +36,7 @@ namespace Kernel const auto& mmap_tag = *reinterpret_cast(tag); const size_t entry_count = (mmap_tag.size - sizeof(multiboot2_mmap_tag_t)) / mmap_tag.entry_size; - + MUST(g_boot_info.memory_map_entries.resize(entry_count)); for (size_t i = 0; i < entry_count; i++) @@ -105,7 +105,7 @@ namespace Kernel return true; if (magic == BANAN_BOOTLOADER_MAGIC) return true; - return false; + return false; } void parse_boot_info(uint32_t magic, uint32_t info) diff --git a/kernel/kernel/Credentials.cpp b/kernel/kernel/Credentials.cpp index 59ec1a4a..7e0e6d28 100644 --- a/kernel/kernel/Credentials.cpp +++ b/kernel/kernel/Credentials.cpp @@ -55,7 +55,7 @@ namespace Kernel TRY(result.append(parts[0])); return result; } - + line.clear(); } diff --git a/kernel/kernel/Debug.cpp b/kernel/kernel/Debug.cpp index cf3ad175..fd446579 100644 --- a/kernel/kernel/Debug.cpp +++ b/kernel/kernel/Debug.cpp @@ -101,7 +101,7 @@ namespace Debug if (row >= g_terminal_driver->height()) row = 0; - + if (row != row_copy) { for (uint32_t i = col; i < g_terminal_driver->width(); i++) @@ -134,4 +134,4 @@ namespace Debug s_debug_lock.unlock(); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Device/Device.cpp b/kernel/kernel/Device/Device.cpp index e9a1835e..592f177d 100644 --- a/kernel/kernel/Device/Device.cpp +++ b/kernel/kernel/Device/Device.cpp @@ -13,4 +13,4 @@ namespace Kernel ) { } -} \ No newline at end of file +} diff --git a/kernel/kernel/Device/FramebufferDevice.cpp b/kernel/kernel/Device/FramebufferDevice.cpp index af989c7a..ad7fe3f2 100644 --- a/kernel/kernel/Device/FramebufferDevice.cpp +++ b/kernel/kernel/Device/FramebufferDevice.cpp @@ -97,7 +97,7 @@ namespace Kernel if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8)) return 0; - + size_t bytes_to_copy = BAN::Math::min(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size()); memcpy(buffer.data(), reinterpret_cast(m_video_buffer->vaddr() + offset), bytes_to_copy); @@ -110,7 +110,7 @@ namespace Kernel return BAN::Error::from_errno(EINVAL); if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8)) return 0; - + size_t bytes_to_copy = BAN::Math::min(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size()); memcpy(reinterpret_cast(m_video_buffer->vaddr() + offset), buffer.data(), bytes_to_copy); @@ -252,7 +252,7 @@ namespace Kernel vaddr &= PAGE_ADDR_MASK; if (m_page_table.physical_address_of(vaddr)) return false; - + paddr_t paddr = PageTable::kernel().physical_address_of(m_framebuffer->m_video_buffer->vaddr() + (vaddr - m_vaddr)); m_page_table.map_page_at(paddr, vaddr, m_flags); diff --git a/kernel/kernel/Device/NullDevice.cpp b/kernel/kernel/Device/NullDevice.cpp index bcb19aa7..5201d75b 100644 --- a/kernel/kernel/Device/NullDevice.cpp +++ b/kernel/kernel/Device/NullDevice.cpp @@ -12,4 +12,4 @@ namespace Kernel return BAN::RefPtr::adopt(result); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Device/ZeroDevice.cpp b/kernel/kernel/Device/ZeroDevice.cpp index cf6d98fb..34c9ccf6 100644 --- a/kernel/kernel/Device/ZeroDevice.cpp +++ b/kernel/kernel/Device/ZeroDevice.cpp @@ -18,4 +18,4 @@ namespace Kernel return buffer.size(); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Errors.cpp b/kernel/kernel/Errors.cpp index 62eb0569..6f33ca6d 100644 --- a/kernel/kernel/Errors.cpp +++ b/kernel/kernel/Errors.cpp @@ -34,4 +34,4 @@ namespace Kernel return s_error_strings[(uint32_t)error]; } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/DevFS/FileSystem.cpp b/kernel/kernel/FS/DevFS/FileSystem.cpp index 20c3214d..177118ef 100644 --- a/kernel/kernel/FS/DevFS/FileSystem.cpp +++ b/kernel/kernel/FS/DevFS/FileSystem.cpp @@ -135,4 +135,4 @@ namespace Kernel return next_dev++; } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/Ext2/FileSystem.cpp b/kernel/kernel/FS/Ext2/FileSystem.cpp index 9c584035..88599076 100644 --- a/kernel/kernel/FS/Ext2/FileSystem.cpp +++ b/kernel/kernel/FS/Ext2/FileSystem.cpp @@ -503,4 +503,4 @@ namespace Kernel return {}; } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index c9104d0e..ac0baaad 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -807,4 +807,4 @@ needs_new_block: return BAN::Error::from_errno(ENOENT); } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/Inode.cpp b/kernel/kernel/FS/Inode.cpp index 9681d72b..a3815f4c 100644 --- a/kernel/kernel/FS/Inode.cpp +++ b/kernel/kernel/FS/Inode.cpp @@ -153,4 +153,4 @@ namespace Kernel return has_data_impl(); } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/Pipe.cpp b/kernel/kernel/FS/Pipe.cpp index 5893b7a9..f9ce2991 100644 --- a/kernel/kernel/FS/Pipe.cpp +++ b/kernel/kernel/FS/Pipe.cpp @@ -82,4 +82,4 @@ namespace Kernel return buffer.size(); } -} \ No newline at end of file +} diff --git a/kernel/kernel/FS/TmpFS/FileSystem.cpp b/kernel/kernel/FS/TmpFS/FileSystem.cpp index 1754dc4f..8bf2fd68 100644 --- a/kernel/kernel/FS/TmpFS/FileSystem.cpp +++ b/kernel/kernel/FS/TmpFS/FileSystem.cpp @@ -67,7 +67,7 @@ namespace Kernel PageTable::with_fast_page(inode_location.paddr, [&] { inode_info = PageTable::fast_page_as_sized(inode_location.index); }); - + auto inode = TRY(TmpInode::create_from_existing(*this, ino, inode_info)); TRY(m_inode_cache.insert(ino, inode)); return inode; @@ -85,7 +85,7 @@ namespace Kernel void TmpFileSystem::remove_from_cache(BAN::RefPtr inode) { LockGuard _(m_lock); - + ASSERT(m_inode_cache.contains(inode->ino())); m_inode_cache.remove(inode->ino()); } diff --git a/kernel/kernel/FS/TmpFS/Inode.cpp b/kernel/kernel/FS/TmpFS/Inode.cpp index 402dd4e4..611d7cae 100644 --- a/kernel/kernel/FS/TmpFS/Inode.cpp +++ b/kernel/kernel/FS/TmpFS/Inode.cpp @@ -392,7 +392,7 @@ namespace Kernel if (result == 0) return BAN::Error::from_errno(ENOENT); - + auto inode = TRY(m_fs.open_inode(result)); return BAN::RefPtr(inode); } @@ -406,13 +406,13 @@ namespace Kernel } auto block_index = this->block_index(data_block_index); - + list->entry_count = 0; // if we reach a non-allocated block, it marks the end if (!block_index.has_value()) return {}; - + auto* dirp = list->array; const size_t byte_count = BAN::Math::min(size() - data_block_index * blksize(), blksize()); diff --git a/kernel/kernel/FS/VirtualFileSystem.cpp b/kernel/kernel/FS/VirtualFileSystem.cpp index ed3ec82f..36ba3426 100644 --- a/kernel/kernel/FS/VirtualFileSystem.cpp +++ b/kernel/kernel/FS/VirtualFileSystem.cpp @@ -198,4 +198,4 @@ namespace Kernel return file; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Font.cpp b/kernel/kernel/Font.cpp index 1d7d3822..ccfc8d46 100644 --- a/kernel/kernel/Font.cpp +++ b/kernel/kernel/Font.cpp @@ -42,7 +42,7 @@ namespace Kernel BAN::Vector file_data; TRY(file_data.resize(inode->size())); - + TRY(inode->read(0, file_data.span())); if (file_data.size() < 4) @@ -69,7 +69,7 @@ namespace Kernel uint8_t char_size; }; const PSF1Header& header = *(const PSF1Header*)font_data.data(); - + uint32_t glyph_count = header.mode & PSF1_MODE512 ? 512 : 256; uint32_t glyph_size = header.char_size; uint32_t glyph_data_size = glyph_size * glyph_count; @@ -225,7 +225,7 @@ namespace Kernel else { for (uint32_t i = 0; i < header.glyph_count; i++) - TRY(glyph_offsets.insert(i, i * header.glyph_size)); + TRY(glyph_offsets.insert(i, i * header.glyph_size)); } if (invalid_utf) @@ -254,4 +254,4 @@ namespace Kernel return m_glyph_data.data() + m_glyph_offsets[codepoint]; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Input/KeyboardLayout.cpp b/kernel/kernel/Input/KeyboardLayout.cpp index fa58b24a..c8b6901d 100644 --- a/kernel/kernel/Input/KeyboardLayout.cpp +++ b/kernel/kernel/Input/KeyboardLayout.cpp @@ -137,7 +137,7 @@ namespace Kernel::Input { dprintln("Invalid modifier instruction in keymap '{}'", line); dprintln(" format: include \"PATH\""); - return BAN::Error::from_errno(EINVAL); + return BAN::Error::from_errno(EINVAL); } parts[1] = parts[1].substring(1, parts[1].size() - 2); diff --git a/kernel/kernel/Input/PS2/Controller.cpp b/kernel/kernel/Input/PS2/Controller.cpp index 86a19c4a..9f6fc1d5 100644 --- a/kernel/kernel/Input/PS2/Controller.cpp +++ b/kernel/kernel/Input/PS2/Controller.cpp @@ -260,7 +260,7 @@ namespace Kernel::Input // Flush The Output Buffer while (!read_byte().is_error()) continue; - + // Set the Controller Configuration Byte TRY(send_command(PS2::Command::READ_CONFIG)); uint8_t config = TRY(read_byte()); @@ -340,7 +340,7 @@ namespace Kernel::Input dwarnln("Could not reserve irq for PS/2 port 2"); m_devices[1].clear(); } - + if (!m_devices[0] && !m_devices[1]) return {}; diff --git a/kernel/kernel/Input/PS2/Keyboard.cpp b/kernel/kernel/Input/PS2/Keyboard.cpp index eee1e847..bdf4bf4a 100644 --- a/kernel/kernel/Input/PS2/Keyboard.cpp +++ b/kernel/kernel/Input/PS2/Keyboard.cpp @@ -126,6 +126,9 @@ namespace Kernel::Input auto key = KeyboardLayout::get().get_key_from_event(KeyEvent { .modifier = 0, .keycode = keycode.value() }); + if (key == Key::F1) + panic("OOF"); + uint16_t modifier_mask = 0; uint16_t toggle_mask = 0; switch (key) diff --git a/kernel/kernel/Input/PS2/Mouse.cpp b/kernel/kernel/Input/PS2/Mouse.cpp index 9044ad9f..adec3729 100644 --- a/kernel/kernel/Input/PS2/Mouse.cpp +++ b/kernel/kernel/Input/PS2/Mouse.cpp @@ -133,7 +133,7 @@ namespace Kernel::Input { if ((new_button_mask & (1 << i)) == (m_button_mask & (1 << i))) continue; - + auto& event = events[event_count++]; event.type = MouseEventType::MouseButtonEvent; event.button_event.button = button_index_to_button(i); diff --git a/kernel/kernel/Memory/DMARegion.cpp b/kernel/kernel/Memory/DMARegion.cpp index 2ffd978d..143ac9b7 100644 --- a/kernel/kernel/Memory/DMARegion.cpp +++ b/kernel/kernel/Memory/DMARegion.cpp @@ -22,7 +22,7 @@ namespace Kernel auto* region_ptr = new DMARegion(size, vaddr, paddr); if (region_ptr == nullptr) return BAN::Error::from_errno(ENOMEM); - + vaddr_guard.disable(); paddr_guard.disable(); diff --git a/kernel/kernel/Memory/FileBackedRegion.cpp b/kernel/kernel/Memory/FileBackedRegion.cpp index 6b6a001c..22e5d649 100644 --- a/kernel/kernel/Memory/FileBackedRegion.cpp +++ b/kernel/kernel/Memory/FileBackedRegion.cpp @@ -100,7 +100,7 @@ namespace Kernel return BAN::Error::from_errno(ENOTSUP); if (m_type != Type::SHARED) return {}; - + vaddr_t first_page = address & PAGE_ADDR_MASK; vaddr_t last_page = BAN::Math::div_round_up(address + size, PAGE_SIZE) * PAGE_SIZE; diff --git a/kernel/kernel/Memory/Heap.cpp b/kernel/kernel/Memory/Heap.cpp index 4f607204..bc5d51d6 100644 --- a/kernel/kernel/Memory/Heap.cpp +++ b/kernel/kernel/Memory/Heap.cpp @@ -39,7 +39,7 @@ namespace Kernel if (entry.type != 1) continue; - + paddr_t start = entry.address; if (start < V2P(g_kernel_end)) start = V2P(g_kernel_end); diff --git a/kernel/kernel/Memory/MemoryBackedRegion.cpp b/kernel/kernel/Memory/MemoryBackedRegion.cpp index cefb18ec..3b7066eb 100644 --- a/kernel/kernel/Memory/MemoryBackedRegion.cpp +++ b/kernel/kernel/Memory/MemoryBackedRegion.cpp @@ -49,7 +49,7 @@ namespace Kernel vaddr_t vaddr = address & PAGE_ADDR_MASK; if (m_page_table.physical_address_of(vaddr) != 0) return false; - + // Map new physcial page to address paddr_t paddr = Heap::get().take_free_page(); if (paddr == 0) @@ -83,7 +83,7 @@ namespace Kernel continue; TRY(result->copy_data_to_region(offset, (const uint8_t*)(m_vaddr + offset), PAGE_SIZE)); } - + return BAN::UniqPtr(BAN::move(result)); } @@ -116,4 +116,4 @@ namespace Kernel return {}; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Memory/MemoryRegion.cpp b/kernel/kernel/Memory/MemoryRegion.cpp index 2e2dab42..92f39061 100644 --- a/kernel/kernel/Memory/MemoryRegion.cpp +++ b/kernel/kernel/Memory/MemoryRegion.cpp @@ -10,7 +10,7 @@ namespace Kernel , m_flags(flags) { } - + MemoryRegion::~MemoryRegion() { if (m_vaddr) diff --git a/kernel/kernel/Memory/VirtualRange.cpp b/kernel/kernel/Memory/VirtualRange.cpp index 0d9031de..6aefe7db 100644 --- a/kernel/kernel/Memory/VirtualRange.cpp +++ b/kernel/kernel/Memory/VirtualRange.cpp @@ -132,7 +132,7 @@ namespace Kernel paddr_t paddr = Heap::get().take_free_page(); if (paddr == 0) return BAN::Error::from_errno(ENOMEM); - result->m_page_table.map_page_at(paddr, vaddr() + offset, m_flags); + result->m_page_table.map_page_at(paddr, vaddr() + offset, m_flags); } CriticalScope _; @@ -218,4 +218,4 @@ namespace Kernel } } -} \ No newline at end of file +} diff --git a/kernel/kernel/Memory/kmalloc.cpp b/kernel/kernel/Memory/kmalloc.cpp index 6244361b..0ad0f564 100644 --- a/kernel/kernel/Memory/kmalloc.cpp +++ b/kernel/kernel/Memory/kmalloc.cpp @@ -38,7 +38,7 @@ struct kmalloc_node { uintptr_t node_end = end(); set_end(data() + size); - + auto* next = after(); next->set_end(node_end); next->set_align(0); @@ -124,10 +124,10 @@ void kmalloc_initialize() node->next = i - 1; node->prev = i + 1; } - + info.node_at(0)->next = kmalloc_fixed_info::node::invalid; info.node_at(info.node_count - 1)->prev = kmalloc_fixed_info::node::invalid; - + info.free_list_head = info.node_at(0); info.used_list_head = nullptr; } @@ -371,7 +371,7 @@ void kfree(void* address) else if (s_kmalloc_info.base <= address_uint && address_uint < s_kmalloc_info.end) { auto& info = s_kmalloc_info; - + auto* node = info.from_address(address); ASSERT(node); ASSERT(node->data() == (uintptr_t)address); diff --git a/kernel/kernel/OpenFileDescriptorSet.cpp b/kernel/kernel/OpenFileDescriptorSet.cpp index 8693d6e7..083fe222 100644 --- a/kernel/kernel/OpenFileDescriptorSet.cpp +++ b/kernel/kernel/OpenFileDescriptorSet.cpp @@ -33,7 +33,7 @@ namespace Kernel { if (other.validate_fd(fd).is_error()) continue; - + auto& open_file = other.m_open_files[fd]; auto result = BAN::RefPtr::create(open_file->inode, open_file->path, open_file->offset, open_file->flags); @@ -93,7 +93,7 @@ namespace Kernel int result = TRY(get_free_fd()); m_open_files[result] = m_open_files[fildes]; - + if (m_open_files[result]->flags & O_WRONLY && m_open_files[result]->inode->is_pipe()) ((Pipe*)m_open_files[result]->inode.ptr())->clone_writing(); @@ -110,7 +110,7 @@ namespace Kernel return fildes; (void)close(fildes2); - + m_open_files[fildes2] = m_open_files[fildes]; m_open_files[fildes2]->flags &= ~O_CLOEXEC; @@ -142,7 +142,7 @@ namespace Kernel default: break; } - + return BAN::Error::from_errno(ENOTSUP); } @@ -241,7 +241,7 @@ namespace Kernel if (m_open_files[fd]->flags & O_WRONLY && m_open_files[fd]->inode->is_pipe()) ((Pipe*)m_open_files[fd]->inode.ptr())->close_writing(); - + m_open_files[fd].clear(); return {}; @@ -345,4 +345,4 @@ namespace Kernel return BAN::Error::from_errno(EMFILE); } -} \ No newline at end of file +} diff --git a/kernel/kernel/PCI.cpp b/kernel/kernel/PCI.cpp index 899a37d4..4a0c3b59 100644 --- a/kernel/kernel/PCI.cpp +++ b/kernel/kernel/PCI.cpp @@ -128,7 +128,7 @@ namespace Kernel::PCI { if (get_vendor_id(bus, dev, 0) == INVALID_VENDOR) return; - + check_function(bus, dev, 0); if (get_header_type(bus, dev, 0) & MULTI_FUNCTION) for (uint8_t func = 1; func < 8; func++) @@ -288,7 +288,7 @@ namespace Kernel::PCI { if (m_type == BarType::MEM && m_vaddr) PageTable::kernel().unmap_range(m_vaddr, m_size); - m_vaddr = 0; + m_vaddr = 0; } BAN::ErrorOr BarRegion::initialize() @@ -628,4 +628,4 @@ namespace Kernel::PCI set_command_bits(PCI_CMD_INTERRUPT_DISABLE); } -} \ No newline at end of file +} diff --git a/kernel/kernel/PIC.cpp b/kernel/kernel/PIC.cpp index 8e079b72..c3ee85a8 100644 --- a/kernel/kernel/PIC.cpp +++ b/kernel/kernel/PIC.cpp @@ -119,7 +119,7 @@ namespace Kernel m_reserved_irqs |= 1 << irq; return irq; } - + return {}; } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 63e02f95..23613d49 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -351,7 +351,7 @@ namespace Kernel if (!m_controlling_terminal) return BAN::Error::from_errno(ENOTTY); - + Kernel::termios ktermios = m_controlling_terminal->get_termios(); termios->c_lflag = 0; if (ktermios.canonical) @@ -370,11 +370,11 @@ namespace Kernel if (!m_controlling_terminal) return BAN::Error::from_errno(ENOTTY); - + Kernel::termios ktermios; ktermios.echo = termios->c_lflag & ECHO; ktermios.canonical = termios->c_lflag & ICANON; - + m_controlling_terminal->set_termios(ktermios); return 0; } @@ -530,7 +530,7 @@ namespace Kernel auto envp_region = MUST(create_region(str_envp.span())); m_userspace_info.envp = (char**)envp_region->vaddr(); MUST(m_mapped_regions.push_back(BAN::move(envp_region))); - + m_userspace_info.argc = str_argv.size(); m_cmdline = BAN::move(str_argv); @@ -803,7 +803,7 @@ namespace Kernel { LockGuard _(m_lock); TRY(validate_string_access(path)); - + auto absolute_path = TRY(absolute_path_of(path)); size_t index = absolute_path.size(); @@ -822,7 +822,7 @@ namespace Kernel BAN::ErrorOr Process::readlink_impl(BAN::StringView absolute_path, char* buffer, size_t bufsize) { auto inode = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_NOFOLLOW | O_RDONLY)).inode; - + // FIXME: no allocation needed auto link_target = TRY(inode->link_target()); @@ -996,7 +996,7 @@ namespace Kernel // FIXME: gracefully kill all processes DevFileSystem::get().initiate_sync(true); - + lai_api_error_t error; switch (command) { @@ -1009,7 +1009,7 @@ namespace Kernel default: ASSERT_NOT_REACHED(); } - + // If we reach here, there was an error dprintln("{}", lai_api_error_to_string(error)); return BAN::Error::from_errno(EUNKNOWN); @@ -1051,7 +1051,7 @@ namespace Kernel if (size < m_working_directory.size() + 1) return BAN::Error::from_errno(ERANGE); - + memcpy(buffer, m_working_directory.data(), m_working_directory.size()); buffer[m_working_directory.size()] = '\0'; @@ -1123,7 +1123,7 @@ namespace Kernel BAN::UniqPtr memory_region; if (inode->mode().ifreg()) - { + { memory_region = TRY(FileBackedRegion::create( inode, page_table(), @@ -1141,7 +1141,7 @@ namespace Kernel region_type, page_flags )); } - + if (!memory_region) return BAN::Error::from_errno(ENODEV); @@ -1175,7 +1175,7 @@ namespace Kernel vaddr_t vaddr = (vaddr_t)addr; if (vaddr % PAGE_SIZE != 0) - return BAN::Error::from_errno(EINVAL); + return BAN::Error::from_errno(EINVAL); LockGuard _(m_lock); @@ -1193,7 +1193,7 @@ namespace Kernel auto inode = TRY(m_open_file_descriptors.inode_of(fildes)); if (!inode->is_tty()) return BAN::Error::from_errno(ENOTTY); - + TRY(((TTY*)inode.ptr())->tty_ctrl(command, flags)); return 0; @@ -1476,7 +1476,7 @@ namespace Kernel // real user ID, then the saved set-user-ID of the current process shall be set equal to the new effective user ID. if (ruid != -1 || euid != m_credentials.ruid()) m_credentials.set_suid(euid); - + if (ruid != -1) m_credentials.set_ruid(ruid); if (euid != -1) @@ -1498,7 +1498,7 @@ namespace Kernel return BAN::Error::from_errno(EINVAL); // The setregid() function shall set the real and effective group IDs of the calling process. - + // If rgid is -1, the real group ID shall not be changed; if egid is -1, the effective group ID shall not be changed. // The real and effective group IDs may be set to different values in the same call. @@ -1522,7 +1522,7 @@ namespace Kernel // real group ID, then the saved set-group-ID of the current process shall be set equal to the new effective group ID. if (rgid != -1 || egid != m_credentials.rgid()) m_credentials.set_sgid(egid); - + if (rgid != -1) m_credentials.set_rgid(rgid); if (egid != -1) @@ -1646,7 +1646,7 @@ namespace Kernel TRY(absolute_path.push_back('/')); TRY(absolute_path.append(path)); - + return absolute_path; } @@ -1694,4 +1694,4 @@ unauthorized_access: return BAN::Error::from_errno(EINTR); } -} \ No newline at end of file +} diff --git a/kernel/kernel/SSP.cpp b/kernel/kernel/SSP.cpp index 0eaf9360..2d44ecd4 100644 --- a/kernel/kernel/SSP.cpp +++ b/kernel/kernel/SSP.cpp @@ -20,4 +20,4 @@ void __stack_chk_fail(void) abort(); } -__END_DECLS \ No newline at end of file +__END_DECLS diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index fefce504..c1dffbed 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -101,7 +101,7 @@ namespace Kernel if (m_active_threads.empty() || ¤t_thread() != m_idle_thread) return; - + if (save_current_thread()) return; m_current_thread = m_active_threads.begin(); @@ -199,7 +199,7 @@ namespace Kernel ASSERT(thread->has_process()); delete &thread->process(); - + remove_and_advance_current_thread(); delete thread; @@ -247,7 +247,7 @@ namespace Kernel Thread* thread = m_current_thread->thread; if (thread->has_process()) thread->process().on_thread_exit(*thread); - + remove_and_advance_current_thread(); delete thread; diff --git a/kernel/kernel/Semaphore.cpp b/kernel/kernel/Semaphore.cpp index 7d7b2321..f8cde5af 100644 --- a/kernel/kernel/Semaphore.cpp +++ b/kernel/kernel/Semaphore.cpp @@ -14,4 +14,4 @@ namespace Kernel Scheduler::get().unblock_threads(this); } -} \ No newline at end of file +} diff --git a/kernel/kernel/SpinLock.cpp b/kernel/kernel/SpinLock.cpp index 7f9964ab..905fa021 100644 --- a/kernel/kernel/SpinLock.cpp +++ b/kernel/kernel/SpinLock.cpp @@ -63,7 +63,7 @@ namespace Kernel void RecursiveSpinLock::unlock() { m_lock.lock(); - + ASSERT(m_lock_depth > 0); ASSERT(m_locker == Scheduler::current_tid()); @@ -71,7 +71,7 @@ namespace Kernel if (m_lock_depth == 0) m_locker = -1; - + m_lock.unlock(); } @@ -116,7 +116,7 @@ namespace Kernel void RecursivePrioritySpinLock::unlock() { m_lock.lock(); - + ASSERT(m_lock_depth > 0); ASSERT(m_locker == Scheduler::current_tid()); @@ -128,7 +128,7 @@ namespace Kernel if (m_lock_depth == 0) m_locker = -1; - + m_lock.unlock(); } @@ -137,4 +137,4 @@ namespace Kernel return m_locker != -1; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Storage/ATA/AHCI/Controller.cpp b/kernel/kernel/Storage/ATA/AHCI/Controller.cpp index 9280ebca..de02323f 100644 --- a/kernel/kernel/Storage/ATA/AHCI/Controller.cpp +++ b/kernel/kernel/Storage/ATA/AHCI/Controller.cpp @@ -41,7 +41,7 @@ namespace Kernel if (!(pi & 1)) continue; - + auto type = check_port_type(abar_mem.ports[i]); if (!type.has_value()) continue; diff --git a/kernel/kernel/Storage/ATA/AHCI/Device.cpp b/kernel/kernel/Storage/ATA/AHCI/Device.cpp index 3d3d7991..52f6b706 100644 --- a/kernel/kernel/Storage/ATA/AHCI/Device.cpp +++ b/kernel/kernel/Storage/ATA/AHCI/Device.cpp @@ -15,9 +15,9 @@ namespace Kernel while (port->cmd & HBA_PxCMD_CR) continue; port->cmd = port->cmd | HBA_PxCMD_FRE; - port->cmd = port->cmd | HBA_PxCMD_ST; + port->cmd = port->cmd | HBA_PxCMD_ST; } - + static void stop_cmd(volatile HBAPortMemorySpace* port) { port->cmd = port->cmd & ~HBA_PxCMD_ST; @@ -58,7 +58,7 @@ namespace Kernel m_data_dma_region = TRY(DMARegion::create(PAGE_SIZE)); memset((void*)m_data_dma_region->vaddr(), 0x00, m_data_dma_region->size()); - + return {}; } @@ -211,14 +211,14 @@ namespace Kernel ASSERT(m_dma_region); ASSERT(m_data_dma_region); ASSERT(0 < sector_count && sector_count <= 0xFFFF + 1); - + ASSERT(sector_count * sector_size() <= m_data_dma_region->size()); m_port->is = ~(uint32_t)0; auto slot = find_free_command_slot(); ASSERT(slot.has_value()); - + volatile auto& command_header = reinterpret_cast(m_dma_region->paddr_to_vaddr(m_port->clb))[slot.value()]; command_header.cfl = sizeof(FISRegisterH2D) / sizeof(uint32_t); command_header.prdtl = 1; @@ -265,11 +265,11 @@ namespace Kernel fis_command.lba1 = (lba >> 8) & 0xFF; fis_command.lba2 = (lba >> 16) & 0xFF; fis_command.device = 1 << 6; // LBA mode - + fis_command.lba3 = (lba >> 24) & 0xFF; fis_command.lba4 = (lba >> 32) & 0xFF; fis_command.lba5 = (lba >> 40) & 0xFF; - + fis_command.count_lo = (sector_count >> 0) & 0xFF; fis_command.count_hi = (sector_count >> 8) & 0xFF; diff --git a/kernel/kernel/Storage/ATA/ATABus.cpp b/kernel/kernel/Storage/ATA/ATABus.cpp index d006ad70..157ca480 100644 --- a/kernel/kernel/Storage/ATA/ATABus.cpp +++ b/kernel/kernel/Storage/ATA/ATABus.cpp @@ -250,7 +250,7 @@ namespace Kernel return BAN::Error::from_error_code(ErrorCode::ATA_UNC); if (err & ATA_ERROR_BBK) return BAN::Error::from_error_code(ErrorCode::ATA_BBK); - + return BAN::Error::from_error_code(ErrorCode::None); } @@ -331,4 +331,4 @@ namespace Kernel return {}; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Storage/ATA/ATAController.cpp b/kernel/kernel/Storage/ATA/ATAController.cpp index 0b18c0fb..c755c9f1 100644 --- a/kernel/kernel/Storage/ATA/ATAController.cpp +++ b/kernel/kernel/Storage/ATA/ATAController.cpp @@ -96,4 +96,4 @@ namespace Kernel return {}; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Storage/ATA/ATADevice.cpp b/kernel/kernel/Storage/ATA/ATADevice.cpp index 84ca7134..0f22373b 100644 --- a/kernel/kernel/Storage/ATA/ATADevice.cpp +++ b/kernel/kernel/Storage/ATA/ATADevice.cpp @@ -41,7 +41,7 @@ namespace Kernel if (!(m_capabilities & ATA_CAPABILITIES_LBA)) return BAN::Error::from_error_code(ErrorCode::ATA_NoLBA); - + if ((identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 15)) == 0 && (identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 14)) != 0 && (identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 12)) != 0) @@ -132,4 +132,4 @@ namespace Kernel return {}; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Storage/DiskCache.cpp b/kernel/kernel/Storage/DiskCache.cpp index 4f6e3d52..3e682b74 100644 --- a/kernel/kernel/Storage/DiskCache.cpp +++ b/kernel/kernel/Storage/DiskCache.cpp @@ -79,7 +79,7 @@ namespace Kernel continue; if (cache.first_sector > page_cache_start) break; - + { CriticalScope _; PageTable::map_fast_page(cache.paddr); @@ -205,4 +205,4 @@ namespace Kernel release_pages(m_cache.size()); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Storage/NVMe/Controller.cpp b/kernel/kernel/Storage/NVMe/Controller.cpp index de995bed..4216ca6f 100644 --- a/kernel/kernel/Storage/NVMe/Controller.cpp +++ b/kernel/kernel/Storage/NVMe/Controller.cpp @@ -58,7 +58,7 @@ namespace Kernel if (m_bar0->size() < 0x1000) { dwarnln("NVMe controller BAR0 is too small {} bytes", m_bar0->size()); - return BAN::Error::from_errno(EINVAL); + return BAN::Error::from_errno(EINVAL); } m_controller_registers = reinterpret_cast(m_bar0->vaddr()); @@ -171,7 +171,7 @@ namespace Kernel BAN::ErrorOr NVMeController::identify_namespaces() { auto dma_page = TRY(DMARegion::create(PAGE_SIZE)); - + BAN::Vector namespace_ids; TRY(namespace_ids.resize(PAGE_SIZE / sizeof(uint32_t))); diff --git a/kernel/kernel/Storage/NVMe/Queue.cpp b/kernel/kernel/Storage/NVMe/Queue.cpp index 995f3485..c43ae53e 100644 --- a/kernel/kernel/Storage/NVMe/Queue.cpp +++ b/kernel/kernel/Storage/NVMe/Queue.cpp @@ -64,7 +64,7 @@ namespace Kernel m_done = false; return m_status; } - + while (SystemTimer::get().ms_since_boot() < start_time + s_nvme_command_timeout_ms) { if (!m_done) diff --git a/kernel/kernel/Storage/Partition.cpp b/kernel/kernel/Storage/Partition.cpp index 4f2a0b0f..caf21595 100644 --- a/kernel/kernel/Storage/Partition.cpp +++ b/kernel/kernel/Storage/Partition.cpp @@ -11,7 +11,7 @@ namespace Kernel if (partition_ptr == nullptr) return BAN::Error::from_errno(ENOMEM); return BAN::RefPtr::adopt(partition_ptr); - } + } Partition::Partition(BAN::RefPtr device, const BAN::GUID& type, const BAN::GUID& guid, uint64_t first_block, uint64_t last_block, uint64_t attr, const char* label, uint32_t index, BAN::StringView name_prefix) : BlockDevice(0660, 0, 0) diff --git a/kernel/kernel/Storage/StorageDevice.cpp b/kernel/kernel/Storage/StorageDevice.cpp index 16c3a6f0..746403dc 100644 --- a/kernel/kernel/Storage/StorageDevice.cpp +++ b/kernel/kernel/Storage/StorageDevice.cpp @@ -182,7 +182,7 @@ namespace Kernel BAN::UTF8::from_codepoints(entry.partition_name, 36, utf8_name); auto partition = TRY(Partition::create( - this, + this, entry.partition_type_guid, entry.unique_partition_guid, entry.starting_lba, @@ -239,7 +239,7 @@ namespace Kernel TRY(read_sectors_impl(lba + offset, 1, sector_buffer)); (void)m_disk_cache->write_to_cache(lba + offset, sector_buffer, false); } - + return {}; } diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index e44fbc45..b61802f6 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -237,4 +237,4 @@ namespace Kernel return ret.value(); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Terminal/Serial.cpp b/kernel/kernel/Terminal/Serial.cpp index b4b97e18..a624d283 100644 --- a/kernel/kernel/Terminal/Serial.cpp +++ b/kernel/kernel/Terminal/Serial.cpp @@ -113,7 +113,7 @@ namespace Kernel const char* ptr = query; while (*ptr) putchar(*ptr++); - + if (getchar() != '\033') return false; if (getchar() != '[') @@ -272,4 +272,4 @@ namespace Kernel m_serial.putchar(ch); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Terminal/VirtualTTY.cpp b/kernel/kernel/Terminal/VirtualTTY.cpp index 9bed8de3..fc64b9fb 100644 --- a/kernel/kernel/Terminal/VirtualTTY.cpp +++ b/kernel/kernel/Terminal/VirtualTTY.cpp @@ -86,7 +86,7 @@ namespace Kernel m_width = new_width; m_height = new_height; } - + for (uint32_t y = 0; y < m_height; y++) for (uint32_t x = 0; x < m_width; x++) render_from_buffer(x, y); @@ -230,7 +230,7 @@ namespace Kernel { dprintln("Unsupported ANSI CSI character J"); } - + if (m_ansi_state.nums[0] == 3) { // FIXME: Clear scroll backbuffer if/when added @@ -307,7 +307,7 @@ namespace Kernel void VirtualTTY::putchar_impl(uint8_t ch) { ASSERT(m_lock.is_locked()); - + uint32_t codepoint = ch; switch (m_state) @@ -425,4 +425,4 @@ namespace Kernel set_cursor_position(m_column, m_row); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Thread.cpp b/kernel/kernel/Thread.cpp index 6474f630..2946bee9 100644 --- a/kernel/kernel/Thread.cpp +++ b/kernel/kernel/Thread.cpp @@ -81,7 +81,7 @@ namespace Kernel PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present, true )); - + thread->m_interrupt_stack = TRY(VirtualRange::create_to_vaddr_range( process->page_table(), 0x300000, KERNEL_OFFSET, @@ -190,7 +190,7 @@ namespace Kernel { ((Process*)process)->cleanup_function(); Scheduler::get().delete_current_process_and_thread(); - ASSERT_NOT_REACHED(); + ASSERT_NOT_REACHED(); } ); m_rsp = stack_base() + stack_size(); @@ -392,4 +392,4 @@ namespace Kernel } #endif -} \ No newline at end of file +} diff --git a/kernel/kernel/Timer/HPET.cpp b/kernel/kernel/Timer/HPET.cpp index 454ffddb..cc6d501e 100644 --- a/kernel/kernel/Timer/HPET.cpp +++ b/kernel/kernel/Timer/HPET.cpp @@ -72,7 +72,7 @@ namespace Kernel return BAN::Error::from_errno(EINVAL); uint64_t ticks_per_ms = FS_PER_MS / m_counter_tick_period_fs; - + { const char* units[] = { "fs", "ps", "ns" }; int index = 0; @@ -174,4 +174,4 @@ namespace Kernel return MMIO::read64(m_mmio_base + reg); } -} \ No newline at end of file +} diff --git a/kernel/kernel/Timer/RTC.cpp b/kernel/kernel/Timer/RTC.cpp index d0d7a80e..506a163c 100644 --- a/kernel/kernel/Timer/RTC.cpp +++ b/kernel/kernel/Timer/RTC.cpp @@ -60,7 +60,7 @@ namespace Kernel last_time = time; get_time(time); } - + uint8_t regB = read_register8(0x0B); // Convert BCD to binary values if necessary @@ -87,4 +87,4 @@ namespace Kernel return time; } -} \ No newline at end of file +} diff --git a/kernel/kernel/Timer/Timer.cpp b/kernel/kernel/Timer/Timer.cpp index ff29d0f6..62234f94 100644 --- a/kernel/kernel/Timer/Timer.cpp +++ b/kernel/kernel/Timer/Timer.cpp @@ -86,4 +86,4 @@ namespace Kernel return result; } -} \ No newline at end of file +} diff --git a/kernel/ubsan.cpp b/kernel/ubsan.cpp index 4ee1dbfe..6b737d31 100644 --- a/kernel/ubsan.cpp +++ b/kernel/ubsan.cpp @@ -127,4 +127,4 @@ extern "C" derrorln("{} address {} with insufficient space for an object of type {}", kind, (void*)pointer, data->type.name); } -} \ No newline at end of file +} diff --git a/libc/fcntl.cpp b/libc/fcntl.cpp index 4c6e7fd7..288fa0aa 100644 --- a/libc/fcntl.cpp +++ b/libc/fcntl.cpp @@ -37,4 +37,4 @@ int fcntl(int fildes, int cmd, ...) va_end(args); return syscall(SYS_FCNTL, fildes, cmd, extra); -} \ No newline at end of file +} diff --git a/libc/grp.cpp b/libc/grp.cpp index b7547ee0..4e19220f 100644 --- a/libc/grp.cpp +++ b/libc/grp.cpp @@ -67,7 +67,7 @@ struct group* fill_group(const BAN::Vector& parts) s_group.gr_mem = nullptr; } - auto groups_or_error = parts[3].split(','); + auto groups_or_error = parts[3].split(','); if (groups_or_error.is_error()) return nullptr; auto groups = groups_or_error.release_value(); @@ -79,7 +79,7 @@ struct group* fill_group(const BAN::Vector& parts) s_group.gr_name = (char*)malloc(parts[0].size() + 1); if (s_group.gr_name == nullptr) return nullptr; - memcpy(s_group.gr_name, parts[0].data(), parts[0].size()); + memcpy(s_group.gr_name, parts[0].data(), parts[0].size()); s_group.gr_name[parts[0].size()] = '\0'; s_group.gr_mem = (char**)malloc((groups.size() + 1) * sizeof(char*)); @@ -99,7 +99,7 @@ struct group* fill_group(const BAN::Vector& parts) } memcpy(s_group.gr_mem[i], groups[i].data(), groups[i].size()); s_group.gr_mem[i][groups[i].size()] = '\0'; - } + } s_group.gr_mem[groups.size()] = nullptr; return &s_group; @@ -110,7 +110,7 @@ struct group* getgrnam(const char* name) if (s_group_mmap == nullptr || s_group_mmap == MAP_FAILED) if (!open_group_file()) return nullptr; - + off_t start = 0; off_t end = 0; while (start < s_group_st.st_size) @@ -138,7 +138,7 @@ struct group* getgrgid(gid_t gid) if (s_group_mmap == nullptr || s_group_mmap == MAP_FAILED) if (!open_group_file()) return nullptr; - + off_t start = 0; off_t end = 0; while (start < s_group_st.st_size) diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index de7eee18..e765be5b 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -11,4 +11,4 @@ #define __END_DECLS #endif -#endif \ No newline at end of file +#endif diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h index 8d980a4a..88b23e3d 100644 --- a/libc/include/sys/resource.h +++ b/libc/include/sys/resource.h @@ -34,7 +34,7 @@ struct rlimit struct rusage { struct timeval ru_utime; /* User time used. */ - struct timeval ru_stime; /* System time used. */ + struct timeval ru_stime; /* System time used. */ }; #define RLIMIT_CORE 0 diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h index ae55e86f..d5901680 100644 --- a/libc/include/sys/select.h +++ b/libc/include/sys/select.h @@ -24,7 +24,7 @@ typedef struct { } fd_set; #define FD_CLR(fd, setp) \ - do { \ + do { \ __fd_mask off = (fd) / __FD_MASK_SIZE; \ __fd_mask bit = (fd) % __FD_MASK_SIZE; \ (setp)->__bits[off] &= ~((__fd_mask)1 << bit); \ @@ -38,7 +38,7 @@ typedef struct { }) #define FD_SET(fd, setp) \ - do { \ + do { \ __fd_mask off = (fd) / __FD_MASK_SIZE; \ __fd_mask bit = (fd) % __FD_MASK_SIZE; \ (setp)->__bits[off] |= ((__fd_mask)1 << bit); \ diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index c3c3dc99..7682e47c 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -16,7 +16,7 @@ __BEGIN_DECLS #define __need_uid_t #define __need_gid_t #define __need_off_t -#define __need_time_t +#define __need_time_t #include #include diff --git a/libc/include/sys/sysmacros.h b/libc/include/sys/sysmacros.h index e27047a2..d72bd843 100644 --- a/libc/include/sys/sysmacros.h +++ b/libc/include/sys/sysmacros.h @@ -15,4 +15,4 @@ __BEGIN_DECLS __END_DECLS -#endif \ No newline at end of file +#endif diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 374033f8..0961cabb 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -41,7 +41,7 @@ __BEGIN_DECLS #define _POSIX_SPIN_LOCKS -1 #define _POSIX_SPORADIC_SERVER -1 #define _POSIX_SYNCHRONIZED_IO xx -#define _POSIX_THREAD_ATTR_STACKADDR -1 +#define _POSIX_THREAD_ATTR_STACKADDR -1 #define _POSIX_THREAD_ATTR_STACKSIZE -1 #define _POSIX_THREAD_CPUTIME -1 #define _POSIX_THREAD_PRIO_INHERIT -1 diff --git a/libc/malloc.cpp b/libc/malloc.cpp index aef0fccd..81bdd2d5 100644 --- a/libc/malloc.cpp +++ b/libc/malloc.cpp @@ -209,7 +209,7 @@ void* realloc(void* ptr, size_t size) { if (ptr == nullptr) return malloc(size); - + // align size to s_malloc_default_align boundary if (size_t ret = size % s_malloc_default_align) size += s_malloc_default_align - ret; @@ -226,7 +226,7 @@ void* realloc(void* ptr, size_t size) void* new_ptr = malloc(size); if (new_ptr == nullptr) return nullptr; - + // move data to the new pointer size_t bytes_to_copy = oldsize < size ? oldsize : size; memcpy(new_ptr, ptr, bytes_to_copy); diff --git a/libc/math.S b/libc/math.S index 6ef1b16d..2e6f8fdc 100644 --- a/libc/math.S +++ b/libc/math.S @@ -23,4 +23,4 @@ floorl: fldenv -28(%rsp) /* restore original environment */ - ret \ No newline at end of file + ret diff --git a/libc/printf_impl.cpp b/libc/printf_impl.cpp index 6d8ebcbe..040b786d 100644 --- a/libc/printf_impl.cpp +++ b/libc/printf_impl.cpp @@ -322,7 +322,7 @@ extern "C" int printf_impl(const char* format, va_list arguments, int (*putc_fun percision = -1; options.percision = percision; } - + // PARSE LENGTH if (*format == 'h') { diff --git a/libc/pwd.cpp b/libc/pwd.cpp index 4cf53fa1..10f4d402 100644 --- a/libc/pwd.cpp +++ b/libc/pwd.cpp @@ -19,7 +19,7 @@ static bool open_pwent() if (s_pwent_fp) return true; s_pwent_fp = fopen("/etc/passwd", "r"); - return s_pwent_fp; + return s_pwent_fp; } static void clear_pwent(passwd& passwd) @@ -125,4 +125,4 @@ void setpwent(void) if (!s_pwent_fp) return; fseek(s_pwent_fp, 0, SEEK_SET); -} \ No newline at end of file +} diff --git a/libc/scanf_impl.cpp b/libc/scanf_impl.cpp index 9d262710..6a50e211 100644 --- a/libc/scanf_impl.cpp +++ b/libc/scanf_impl.cpp @@ -30,7 +30,7 @@ struct Conversion int field_width = -1; bool allocate = false; LengthModifier length = LengthModifier::none; - char conversion = '\0'; + char conversion = '\0'; }; Conversion parse_conversion_specifier(const char*& format) @@ -380,7 +380,7 @@ int scanf_impl(const char* format, va_list arguments, int (*__getc_fun)(void*), return ConversionResult::SUCCESS; } - + if (tolower(in) == 'n') { get_input(true); diff --git a/libc/signal.cpp b/libc/signal.cpp index 0285e3fc..397822cb 100644 --- a/libc/signal.cpp +++ b/libc/signal.cpp @@ -17,4 +17,4 @@ void (*signal(int sig, void (*func)(int)))(int) { long ret = syscall(SYS_SIGNAL, sig, func); return (void (*)(int))ret; -} \ No newline at end of file +} diff --git a/libc/stdio.cpp b/libc/stdio.cpp index 73a81a54..d2fdf2e2 100644 --- a/libc/stdio.cpp +++ b/libc/stdio.cpp @@ -495,7 +495,7 @@ int ungetc(int, FILE*); int vfprintf(FILE* file, const char* format, va_list arguments) { - return printf_impl(format, arguments, [](int c, void* file) { return fputc(c, (FILE*)file); }, file); + return printf_impl(format, arguments, [](int c, void* file) { return fputc(c, static_cast(file)); }, file); } int vfscanf(FILE* file, const char* format, va_list arguments) diff --git a/libc/stdlib.cpp b/libc/stdlib.cpp index 72133d9a..baced20a 100644 --- a/libc/stdlib.cpp +++ b/libc/stdlib.cpp @@ -235,4 +235,4 @@ void srand(unsigned int seed) { s_rand_state = seed + s_rand_increment; (void)rand(); -} \ No newline at end of file +} diff --git a/libc/sys/wait.cpp b/libc/sys/wait.cpp index 7e85bd50..95b403d4 100644 --- a/libc/sys/wait.cpp +++ b/libc/sys/wait.cpp @@ -10,4 +10,4 @@ pid_t wait(int* stat_loc) pid_t waitpid(pid_t pid, int* stat_loc, int options) { return (pid_t)syscall(SYS_WAIT, pid, stat_loc, options); -} \ No newline at end of file +} diff --git a/libc/time.cpp b/libc/time.cpp index 83122fbf..6210303c 100644 --- a/libc/time.cpp +++ b/libc/time.cpp @@ -20,4 +20,4 @@ time_t time(time_t* tloc) if (tloc) *tloc = tp.tv_sec; return tp.tv_sec; -} \ No newline at end of file +} diff --git a/libc/unistd.cpp b/libc/unistd.cpp index af4e85d4..ec01c51c 100644 --- a/libc/unistd.cpp +++ b/libc/unistd.cpp @@ -22,7 +22,7 @@ extern "C" void _init_libc(char** _environ) size_t env_count = 0; while (_environ[env_count]) env_count++; - + environ = (char**)malloc(sizeof(char*) * env_count + 1); for (size_t i = 0; i < env_count; i++) { @@ -136,7 +136,7 @@ int execl(const char* pathname, const char* arg0, ...) } int execle(const char* pathname, const char* arg0, ...) -{ +{ va_list ap; int argc = 0; diff --git a/script/build.sh b/script/build.sh index d9e71bad..2e2133d9 100755 --- a/script/build.sh +++ b/script/build.sh @@ -42,7 +42,7 @@ build_toolchain () { exit 0 fi fi - + $BANAN_TOOLCHAIN_DIR/build.sh } diff --git a/script/image.sh b/script/image.sh index 8a4c8789..2c7f67ca 100755 --- a/script/image.sh +++ b/script/image.sh @@ -25,7 +25,7 @@ sudo partprobe $LOOP_DEV ROOT_PARTITION="${LOOP_DEV}p2" MOUNT_DIR="${MOUNT_DIR:-$BANAN_BUILD_DIR/bananmnt}" -sudo mkdir -p $MOUNT_DIR || { echo "Failed to create mount point dir."; exit 1; } +sudo mkdir -p $MOUNT_DIR || { echo "Failed to create mount point dir."; exit 1; } sudo mount $ROOT_PARTITION $MOUNT_DIR diff --git a/script/install-bootloader.sh b/script/install-bootloader.sh index bfc82cf9..204190c4 100755 --- a/script/install-bootloader.sh +++ b/script/install-bootloader.sh @@ -20,7 +20,7 @@ fi if [[ -z $CMAKE_COMMAND ]]; then echo "You must set the CMAKE_COMMAND environment variable" >&2 exit 1 -fi +fi ROOT_PARTITION_INDEX=2 ROOT_PARTITION_INFO=$(fdisk -x $BANAN_DISK_IMAGE_PATH | grep "^$BANAN_DISK_IMAGE_PATH" | head -$ROOT_PARTITION_INDEX | tail -1) diff --git a/script/shell-completion/zsh/_bos b/script/shell-completion/zsh/_bos index d695cafc..19653b62 100644 --- a/script/shell-completion/zsh/_bos +++ b/script/shell-completion/zsh/_bos @@ -15,4 +15,3 @@ __targets() { } _arguments '*::targets:__targets' - diff --git a/toolchain/binutils-2.39.patch b/toolchain/binutils-2.39.patch index befb128c..1374a05a 100644 --- a/toolchain/binutils-2.39.patch +++ b/toolchain/binutils-2.39.patch @@ -58,7 +58,7 @@ index 62f806bdfe..e05db38382 100644 @@ -221,6 +221,7 @@ case ${generic_target} in h8300-*-elf) fmt=elf ;; h8300-*-linux*) fmt=elf em=linux ;; - + + i386-*-banan_os*) fmt=elf em=gnu ;; i386-*-beospe*) fmt=coff em=pe ;; i386-*-beos*) fmt=elf ;; diff --git a/toolchain/build.sh b/toolchain/build.sh index 78869973..1aabf751 100755 --- a/toolchain/build.sh +++ b/toolchain/build.sh @@ -136,7 +136,7 @@ build_grub () { --prefix="$BANAN_TOOLCHAIN_PREFIX" \ --with-platform="efi" \ --disable-werror - + make $MAKE_JOBS make install } diff --git a/userspace/Shell/main.cpp b/userspace/Shell/main.cpp index 1433070d..0ee1f4ff 100644 --- a/userspace/Shell/main.cpp +++ b/userspace/Shell/main.cpp @@ -26,7 +26,7 @@ static BAN::String hostname; static void clean_exit() { tcsetattr(0, TCSANOW, &old_termios); - exit(0); + exit(0); } BAN::Vector> parse_command(BAN::StringView); @@ -42,7 +42,7 @@ BAN::Optional parse_dollar(BAN::StringView command, size_t& i) { i++; return BAN::String::formatted("{}", last_return); - } + } if (isalnum(command[i])) { size_t len = 1; @@ -436,7 +436,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in if (clock_gettime(CLOCK_MONOTONIC, &end) == -1) ERROR_RETURN("clock_gettime", 1); - + uint64_t total_ns = 0; total_ns += (end.tv_sec - start.tv_sec) * 1'000'000'000; total_ns += end.tv_nsec - start.tv_nsec; @@ -683,9 +683,9 @@ int source_script(const BAN::String& path) MUST(command.append(temp_buffer)); if (command.back() != '\n') continue; - + command.pop_back(); - + if (!command.empty()) if (int temp = parse_and_execute_command(command)) ret = temp; @@ -769,7 +769,7 @@ BAN::String get_prompt() char buffer[256]; if (getcwd(buffer, sizeof(buffer)) == nullptr) strcpy(buffer, strerrorname_np(errno)); - + const char* home = getenv("HOME"); size_t home_len = home ? strlen(home) : 0; if (home && strncmp(buffer, home, home_len) == 0) @@ -817,7 +817,7 @@ BAN::String get_prompt() { MUST(prompt.push_back(ch)); } - } + } return prompt; } @@ -883,7 +883,7 @@ int main(int argc, char** argv) if (argc >= 1) setenv("SHELL", argv[0], true); - + source_shellrc(); new_termios = old_termios; @@ -940,7 +940,7 @@ int main(int argc, char** argv) waiting_utf8 = 3; else ASSERT_NOT_REACHED(); - + fputc(ch, stdout); MUST(buffers[index].insert(ch, col++)); continue; diff --git a/userspace/aoc2023/day10/main.cpp b/userspace/aoc2023/day10/main.cpp index 7c3350d8..a955dd11 100644 --- a/userspace/aoc2023/day10/main.cpp +++ b/userspace/aoc2023/day10/main.cpp @@ -111,7 +111,7 @@ i64 puzzle1(FILE* fp) { if (positions[0].x == positions[1].x && positions[0].y == positions[1].y) return distance; - + for (auto& position : positions) { Direction direction = tile_exit_direction(grid[position.y][position.x], position.from); @@ -140,7 +140,7 @@ i64 puzzle2(FILE* fp) auto position = find_grid_first_moves(grid)[0]; while ((grid[position.y][position.x] & ~Flag::Mask) != 'S') - { + { Direction direction = tile_exit_direction(grid[position.y][position.x] & ~Flag::Mask, position.from); switch (grid[position.y][position.x] & ~Flag::Mask) @@ -196,7 +196,7 @@ i64 puzzle2(FILE* fp) // Mark start tile as part of the path grid[position.y][position.x] |= Flag::Path; - + // Clean up flags for (auto& row : grid) { diff --git a/userspace/aoc2023/day11/main.cpp b/userspace/aoc2023/day11/main.cpp index 65ee433e..8f1af00d 100644 --- a/userspace/aoc2023/day11/main.cpp +++ b/userspace/aoc2023/day11/main.cpp @@ -84,7 +84,7 @@ i64 solution(FILE* fp, u64 expansion) const u64 x2 = j % map[0].size(); if (map[y2][x2] != '#') continue; - + result += distance_with_expansion(map, x1, y1, x2, y2, expansion); } } diff --git a/userspace/aoc2023/day12/main.cpp b/userspace/aoc2023/day12/main.cpp index 3632f905..7c688629 100644 --- a/userspace/aoc2023/day12/main.cpp +++ b/userspace/aoc2023/day12/main.cpp @@ -53,7 +53,7 @@ i64 count_possibilities(BAN::StringView record, BAN::Span groups) for (size_t i = 0; i + groups[0] <= record.size(); i++) { bool valid = true; - + if (record.substring(i, groups[0]).contains('.')) valid = false; @@ -91,7 +91,7 @@ i64 puzzle1(FILE* fp) line = line.substring(0, line.size() - 1); if (line.size() < 3) continue; - + auto parts = MUST(line.split(' ')); auto record = parts[0]; @@ -119,7 +119,7 @@ i64 puzzle2(FILE* fp) line = line.substring(0, line.size() - 1); if (line.size() < 3) continue; - + auto parts = MUST(line.split(' ')); BAN::String record; diff --git a/userspace/aoc2023/day14/main.cpp b/userspace/aoc2023/day14/main.cpp index d26c2df8..bae7b0ee 100644 --- a/userspace/aoc2023/day14/main.cpp +++ b/userspace/aoc2023/day14/main.cpp @@ -191,7 +191,7 @@ i64 puzzle2(FILE* fp) tilt_platform(platform, Direction::North); tilt_platform(platform, Direction::West); tilt_platform(platform, Direction::South); - tilt_platform(platform, Direction::East); + tilt_platform(platform, Direction::East); } i64 result = 0; diff --git a/userspace/aoc2023/day16/main.cpp b/userspace/aoc2023/day16/main.cpp index a2a01ecc..03c52561 100644 --- a/userspace/aoc2023/day16/main.cpp +++ b/userspace/aoc2023/day16/main.cpp @@ -69,7 +69,7 @@ Grid parse_grid(FILE* fp) line = line.substring(0, line.size() - 1); if (line.empty()) break; - + MUST(grid.emplace_back(line.size())); for (size_t i = 0; i < line.size(); i++) grid.back()[i] = char_to_tile(line[i]); diff --git a/userspace/aoc2023/day17/main.cpp b/userspace/aoc2023/day17/main.cpp index 462162c4..f5f83f47 100644 --- a/userspace/aoc2023/day17/main.cpp +++ b/userspace/aoc2023/day17/main.cpp @@ -52,7 +52,7 @@ BAN::Vector> parse_grid(FILE* fp) line = line.substring(0, line.size() - 1); if (line.empty()) break; - + MUST(grid.emplace_back(line.size())); for (size_t i = 0; i < line.size(); i++) grid.back()[i] = line[i] - '0'; @@ -95,7 +95,7 @@ i64 solve_general(FILE* fp) BAN::HashSet visited; BAN::HashSet pending; MUST(pending.insert({ 0, 0 })); - + while (!pending.empty()) { auto position = *pending.begin(); @@ -175,7 +175,7 @@ i64 puzzle1(FILE* fp) i64 puzzle2(FILE* fp) { - return solve_general<4, 10>(fp); + return solve_general<4, 10>(fp); } int main(int argc, char** argv) diff --git a/userspace/aoc2023/day18/main.cpp b/userspace/aoc2023/day18/main.cpp index 627950fe..006e779f 100644 --- a/userspace/aoc2023/day18/main.cpp +++ b/userspace/aoc2023/day18/main.cpp @@ -153,7 +153,7 @@ i64 solve_general(FILE* fp, auto parse_dir, auto parse_count) i32 rmin_x = INT32_MAX; find_min_and_remove_duplicates(rpath, lpath, rmin_x); - + ASSERT(lmin_x != rmin_x); auto& expand = (lmin_x < rmin_x) ? rpath : lpath; @@ -177,7 +177,7 @@ i64 solve_general(FILE* fp, auto parse_dir, auto parse_count) MUST(visited.insert(next)); } } - + return path.size() + inner_area.size(); } diff --git a/userspace/aoc2023/day19/main.cpp b/userspace/aoc2023/day19/main.cpp index 5cb96956..c6e70f8c 100644 --- a/userspace/aoc2023/day19/main.cpp +++ b/userspace/aoc2023/day19/main.cpp @@ -140,7 +140,7 @@ BAN::Vector parse_items(FILE* fp) item.values[1] = parse_i64(values[1].substring(2)); item.values[2] = parse_i64(values[2].substring(2)); item.values[3] = parse_i64(values[3].substring(2)); - + MUST(items.push_back(item)); } @@ -245,15 +245,15 @@ i64 puzzle2(FILE* fp) }}; if (!is_accepted(item, "in"sv, workflows)) continue; - + i64 x_count = values_sorted[0][xi + 1] - values_sorted[0][xi]; i64 m_count = values_sorted[1][mi + 1] - values_sorted[1][mi]; i64 a_count = values_sorted[2][ai + 1] - values_sorted[2][ai]; i64 s_count = values_sorted[3][si + 1] - values_sorted[3][si]; result += x_count * m_count * a_count * s_count; - } - } + } + } } timespec time_stop; diff --git a/userspace/aoc2023/day2/main.cpp b/userspace/aoc2023/day2/main.cpp index 6ea627d0..56bffe26 100644 --- a/userspace/aoc2023/day2/main.cpp +++ b/userspace/aoc2023/day2/main.cpp @@ -24,7 +24,7 @@ int puzzle1(FILE* fp) if (strncmp("Game ", ptr, 5)) continue; ptr += 5; - + int id = parse_int_and_advance(ptr); ptr += 2; @@ -63,7 +63,7 @@ int puzzle2(FILE* fp) if (strncmp("Game ", ptr, 5)) continue; ptr += 5; - + parse_int_and_advance(ptr); ptr += 2; diff --git a/userspace/aoc2023/day20/main.cpp b/userspace/aoc2023/day20/main.cpp index a40f5b31..ec41f7ad 100644 --- a/userspace/aoc2023/day20/main.cpp +++ b/userspace/aoc2023/day20/main.cpp @@ -131,7 +131,7 @@ i64 puzzle1(FILE* fp) auto modules = parse_modules(fp); BAN::Queue signal_queue; - + i64 sent_hi = 0; i64 sent_lo = 0; diff --git a/userspace/aoc2023/day21/main.cpp b/userspace/aoc2023/day21/main.cpp index a037cf1a..2a055551 100644 --- a/userspace/aoc2023/day21/main.cpp +++ b/userspace/aoc2023/day21/main.cpp @@ -104,7 +104,7 @@ i64 puzzle1(FILE* fp) MUST(visited.insert(position)); if (i % 2 == 0) MUST(reachable.insert(position)); - + Position offsets[4] { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } }; for (i32 j = 0; j < 4; j++) { diff --git a/userspace/aoc2023/day23/main.cpp b/userspace/aoc2023/day23/main.cpp index 60521ae2..24d5e3af 100644 --- a/userspace/aoc2023/day23/main.cpp +++ b/userspace/aoc2023/day23/main.cpp @@ -29,7 +29,7 @@ BAN::Vector> parse_grid(FILE* fp) line = line.substring(0, line.size() - 1); if (line.empty()) break; - + MUST(grid.emplace_back(line.size(), '\0')); for (size_t i = 0; i < line.size(); i++) grid.back()[i] = line[i]; @@ -86,7 +86,7 @@ i64 recurse_grid(BAN::Vector& path, const BAN::Vector parse_hailstones(FILE* fp) line = line.substring(0, line.size() - 1); if (line.empty()) break; - + auto position_velocity_strs = MUST(line.split('@')); ASSERT(position_velocity_strs.size() == 2); @@ -73,7 +73,7 @@ BAN::Vector parse_hailstones(FILE* fp) i64 puzzle1(FILE* fp) { auto hailstones = parse_hailstones(fp); - + i64 result = 0; for (size_t i = 0; i < hailstones.size(); i++) diff --git a/userspace/aoc2023/day25/main.cpp b/userspace/aoc2023/day25/main.cpp index 23bebc05..e4f313e1 100644 --- a/userspace/aoc2023/day25/main.cpp +++ b/userspace/aoc2023/day25/main.cpp @@ -37,7 +37,7 @@ BAN::HashMap parse_components(FILE* fp) line = line.substring(0, line.size() - 1); if (line.empty()) break; - + auto parts = MUST(line.split(' ')); ASSERT(parts.size() >= 2); @@ -46,7 +46,7 @@ BAN::HashMap parse_components(FILE* fp) if (!components.contains(parts.front())) MUST(components.emplace(parts.front(), parts.front())); - + for (size_t i = 1; i < parts.size(); i++) { MUST(components[parts.front()].connections.emplace_back(parts[i])); @@ -96,7 +96,7 @@ size_t graph_size(const BAN::HashMap& graph, const BAN:: const auto& targets = graph[current].connections; for (const auto& target : targets) { - if (removed.contains(connection_key(current, target))) + if (removed.contains(connection_key(current, target))) continue; if (visited.contains(target)) continue; diff --git a/userspace/aoc2023/day3/main.cpp b/userspace/aoc2023/day3/main.cpp index 15cc49d5..53a303c1 100644 --- a/userspace/aoc2023/day3/main.cpp +++ b/userspace/aoc2023/day3/main.cpp @@ -17,14 +17,14 @@ int puzzle1(FILE* fp) { buffer[strlen(buffer) - 1] = '\0'; MUST(lines.emplace_back(buffer)); - } + } int result = 0; for (size_t y = 0; y < lines.size(); y++) { for (size_t x = 0; x < lines[y].size(); x++) - { + { if (!isdigit(lines[y][x])) continue; @@ -52,7 +52,7 @@ int puzzle1(FILE* fp) should_add = true; break; } - } + } if (should_add) break; @@ -88,7 +88,7 @@ int puzzle2(FILE* fp) { buffer[strlen(buffer) - 1] = '\0'; MUST(lines.emplace_back(buffer)); - } + } // Didn't want to think about O(1) space, this is much simpler. // Map numbers next to '*' to asterisk's coordinates. diff --git a/userspace/aoc2023/day5/main.cpp b/userspace/aoc2023/day5/main.cpp index 8e33608c..690d2e35 100644 --- a/userspace/aoc2023/day5/main.cpp +++ b/userspace/aoc2023/day5/main.cpp @@ -26,7 +26,7 @@ i64 puzzle1(FILE* fp) char buffer[256]; if (!fgets(buffer, sizeof(buffer), fp)) return -1; - + { BAN::StringView line(buffer); line = line.substring(0, line.size() - 1); @@ -88,7 +88,7 @@ i64 puzzle2(FILE* fp) char buffer[256]; if (!fgets(buffer, sizeof(buffer), fp)) return -1; - + { BAN::StringView line(buffer); line = line.substring(0, line.size() - 1); diff --git a/userspace/image/Netbpm.cpp b/userspace/image/Netbpm.cpp index 93cd69bf..485f2958 100644 --- a/userspace/image/Netbpm.cpp +++ b/userspace/image/Netbpm.cpp @@ -39,7 +39,7 @@ BAN::ErrorOr> load_netbpm(const void* mmap_addr, size_t size } const uint8_t* u8_ptr = reinterpret_cast(mmap_addr); - + if (u8_ptr[0] != 'P') { fprintf(stderr, "not Netbpm image\n"); diff --git a/userspace/image/main.cpp b/userspace/image/main.cpp index a82d8715..9be2586d 100644 --- a/userspace/image/main.cpp +++ b/userspace/image/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { if (argc != 2) return usage(argv[0], 1); - + auto image = Image::load_from_file(argv[1]); if (!image) return 1; diff --git a/userspace/init/main.cpp b/userspace/init/main.cpp index bd48cd86..b74cd2e5 100644 --- a/userspace/init/main.cpp +++ b/userspace/init/main.cpp @@ -106,9 +106,9 @@ int main() exit(1); } - + endpwent(); - + if (pid == -1) { perror("fork"); diff --git a/userspace/loadkeys/main.cpp b/userspace/loadkeys/main.cpp index 6aa3dbdd..dc52813c 100644 --- a/userspace/loadkeys/main.cpp +++ b/userspace/loadkeys/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char** argv) struct stat st; if (stat(argv[1], &st) == 0) return try_load_keymap(argv[1]); - + char buffer[128]; strcpy(buffer, "/usr/share/keymaps/"); strcat(buffer, argv[1]); diff --git a/userspace/meminfo/main.cpp b/userspace/meminfo/main.cpp index 0c7001cb..a4b3fb79 100644 --- a/userspace/meminfo/main.cpp +++ b/userspace/meminfo/main.cpp @@ -73,7 +73,7 @@ int main() { strcpy(path_buffer, proc_ent->d_name); strcat(path_buffer, "/meminfo"); - + int fd = openat(dirfd(proc), path_buffer, O_RDONLY); if (fd == -1) { diff --git a/userspace/rm/main.cpp b/userspace/rm/main.cpp index 359967db..8ce474ee 100644 --- a/userspace/rm/main.cpp +++ b/userspace/rm/main.cpp @@ -112,7 +112,7 @@ int main(int argc, char** argv) ret = 1; continue; } - + if (S_ISDIR(st.st_mode)) { fprintf(stderr, "%s: %s\n", argv[i], strerror(EISDIR)); diff --git a/userspace/sleep/main.cpp b/userspace/sleep/main.cpp index 6593bce0..b5b11f00 100644 --- a/userspace/sleep/main.cpp +++ b/userspace/sleep/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { if (argc != 2) return usage(argv[0], 1); - + if (strlen(argv[1]) > 9) { fprintf(stderr, "SECONDS argument too large\n"); diff --git a/userspace/sudo/main.cpp b/userspace/sudo/main.cpp index 10ba5952..a3f50e41 100644 --- a/userspace/sudo/main.cpp +++ b/userspace/sudo/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char** argv) { if (argc < 2) return usage(argv[0], 1); - + if (setuid(0) == -1) { perror("setuid"); diff --git a/userspace/tee/main.cpp b/userspace/tee/main.cpp index bf533e18..7f7a394a 100644 --- a/userspace/tee/main.cpp +++ b/userspace/tee/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) perror(argv[i]); else file_count++; - + if (file_count >= MAX_FILES) { fprintf(stderr, "only up to %d files are supported\n", MAX_FILES); @@ -54,7 +54,7 @@ int main(int argc, char** argv) } free(buffer); - if (ferror(stdin)) + if (ferror(stdin)) perror("stdin"); for (size_t i = 0; i < file_count; i++) diff --git a/userspace/test-mouse/main.cpp b/userspace/test-mouse/main.cpp index a046fcef..46ecc0d5 100644 --- a/userspace/test-mouse/main.cpp +++ b/userspace/test-mouse/main.cpp @@ -124,13 +124,13 @@ int main(int argc, char** argv) perror("tcsetattr"); return 1; } - + uint32_t color = 0xFF0000; int mouse_x = fb_info.width / 2; int mouse_y = fb_info.height / 2; int radius = 10; - // clear screen and render + // clear screen and render memset(fb_mmap, 0x00, fb_bytes); draw_circle(mouse_x, mouse_y, radius, color); msync(fb_mmap, fb_bytes, MS_SYNC); @@ -138,7 +138,7 @@ int main(int argc, char** argv) while (true) { using namespace Kernel::Input; - + MouseEvent event; if (read(mouse_fd, &event, sizeof(event)) == -1) {