From 7eaa96e984ac8daa36935d840636bc9db5f66418 Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Mon, 12 Apr 2021 09:13:29 +0200 Subject: [PATCH] arch: Merged Arch.h and VirtualMemory.h. --- kernel/archs/{VirtualMemory.h => Arch.h} | 33 ++++++++++++++++++++++-- kernel/archs/Architectures.h | 33 ------------------------ kernel/archs/x86/x86.h | 2 +- kernel/archs/x86_32/Power.cpp | 3 +-- kernel/archs/x86_32/VirtualMemory.cpp | 2 +- kernel/archs/x86_32/x86_32.cpp | 2 +- kernel/archs/x86_64/VirtualMemory.cpp | 3 +-- kernel/kernel/graphics/Framebuffer.cpp | 2 +- kernel/kernel/interrupts/Interupts.cpp | 2 +- kernel/kernel/memory/MMIO.cpp | 2 +- kernel/kernel/memory/Memory.cpp | 2 +- kernel/kernel/modules/Ramdisk.cpp | 2 +- kernel/kernel/plugs.cpp | 3 +-- kernel/kernel/scheduling/Scheduler.cpp | 3 +-- kernel/kernel/system/Panic.cpp | 4 +-- kernel/kernel/system/System.cpp | 2 +- kernel/kernel/tasking/Syscalls.cpp | 2 +- kernel/kernel/tasking/Task-Memory.cpp | 2 +- kernel/kernel/tasking/Task.cpp | 3 +-- userspace/libraries/libio/Format.h | 6 +++++ 20 files changed, 55 insertions(+), 58 deletions(-) rename kernel/archs/{VirtualMemory.h => Arch.h} (62%) delete mode 100644 kernel/archs/Architectures.h diff --git a/kernel/archs/VirtualMemory.h b/kernel/archs/Arch.h similarity index 62% rename from kernel/archs/VirtualMemory.h rename to kernel/archs/Arch.h index 7e5d55a806..e3236b7439 100644 --- a/kernel/archs/VirtualMemory.h +++ b/kernel/archs/Arch.h @@ -1,11 +1,41 @@ #pragma once #include - #include +#include #include "kernel/memory/MemoryRange.h" +struct Task; + +void arch_disable_interrupts(); + +void arch_enable_interrupts(); + +void arch_halt(); + +void arch_yield(); + +void arch_save_context(Task *task); + +void arch_load_context(Task *task); + +void arch_task_go(Task *task); + +size_t arch_debug_write(const void *buffer, size_t size); + +TimeStamp arch_get_time(); + +NO_RETURN void arch_reboot(); + +NO_RETURN void arch_shutdown(); + +void arch_panic_dump(); + +void arch_dump_stack_frame(void *stackframe); + +void arch_backtrace(); + void *arch_kernel_address_space(); void arch_virtual_initialize(); @@ -27,4 +57,3 @@ void *arch_address_space_create(); void arch_address_space_destroy(void *address_space); void arch_address_space_switch(void *address_space); - diff --git a/kernel/archs/Architectures.h b/kernel/archs/Architectures.h deleted file mode 100644 index 79cfa3fd60..0000000000 --- a/kernel/archs/Architectures.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -struct Task; - -void arch_disable_interrupts(); - -void arch_enable_interrupts(); - -void arch_halt(); - -void arch_yield(); - -void arch_save_context(Task *task); - -void arch_load_context(Task *task); - -void arch_task_go(Task *task); - -size_t arch_debug_write(const void *buffer, size_t size); - -TimeStamp arch_get_time(); - -NO_RETURN void arch_reboot(); - -NO_RETURN void arch_shutdown(); - -void arch_panic_dump(); - -void arch_dump_stack_frame(void *stackframe); - -void arch_backtrace(); diff --git a/kernel/archs/x86/x86.h b/kernel/archs/x86/x86.h index a26891b6f1..2baec414a2 100644 --- a/kernel/archs/x86/x86.h +++ b/kernel/archs/x86/x86.h @@ -1,6 +1,6 @@ #pragma once -#include "archs/Architectures.h" +#include "archs/Arch.h" #ifdef __x86_64__ using CRRegister = uint64_t; diff --git a/kernel/archs/x86_32/Power.cpp b/kernel/archs/x86_32/Power.cpp index 297eb835c9..991ea44fac 100644 --- a/kernel/archs/x86_32/Power.cpp +++ b/kernel/archs/x86_32/Power.cpp @@ -1,7 +1,6 @@ #include -#include "archs/Architectures.h" -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "archs/x86/IOPort.h" #include "archs/x86/x86.h" diff --git a/kernel/archs/x86_32/VirtualMemory.cpp b/kernel/archs/x86_32/VirtualMemory.cpp index 09729a0b6f..bf468787c2 100644 --- a/kernel/archs/x86_32/VirtualMemory.cpp +++ b/kernel/archs/x86_32/VirtualMemory.cpp @@ -3,7 +3,7 @@ #include #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "archs/x86_32/Paging.h" #include "kernel/interrupts/Interupts.h" diff --git a/kernel/archs/x86_32/x86_32.cpp b/kernel/archs/x86_32/x86_32.cpp index c05996ba26..cb69649b11 100644 --- a/kernel/archs/x86_32/x86_32.cpp +++ b/kernel/archs/x86_32/x86_32.cpp @@ -1,7 +1,7 @@ #include #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "archs/x86/COM.h" #include "archs/x86/CPUID.h" #include "archs/x86/FPU.h" diff --git a/kernel/archs/x86_64/VirtualMemory.cpp b/kernel/archs/x86_64/VirtualMemory.cpp index eb74d4d1fc..a5e46cdcd9 100644 --- a/kernel/archs/x86_64/VirtualMemory.cpp +++ b/kernel/archs/x86_64/VirtualMemory.cpp @@ -5,8 +5,7 @@ #include "kernel/memory/Memory.h" #include "kernel/system/System.h" -#include "archs/VirtualMemory.h" - +#include "archs/Arch.h" #include "archs/x86_64/Paging.h" #include "archs/x86_64/x86_64.h" diff --git a/kernel/kernel/graphics/Framebuffer.cpp b/kernel/kernel/graphics/Framebuffer.cpp index 307876496f..ed7c477255 100644 --- a/kernel/kernel/graphics/Framebuffer.cpp +++ b/kernel/kernel/graphics/Framebuffer.cpp @@ -3,7 +3,7 @@ #include #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/graphics/Graphics.h" #include "kernel/interrupts/Interupts.h" diff --git a/kernel/kernel/interrupts/Interupts.cpp b/kernel/kernel/interrupts/Interupts.cpp index 921d73b9be..9d37749d2f 100644 --- a/kernel/kernel/interrupts/Interupts.cpp +++ b/kernel/kernel/interrupts/Interupts.cpp @@ -1,6 +1,6 @@ #include -#include "archs/Architectures.h" +#include "archs/Arch.h" #include "kernel/interrupts/Dispatcher.h" #include "kernel/interrupts/Interupts.h" diff --git a/kernel/kernel/memory/MMIO.cpp b/kernel/kernel/memory/MMIO.cpp index 3e961ef225..647a1f7b06 100644 --- a/kernel/kernel/memory/MMIO.cpp +++ b/kernel/kernel/memory/MMIO.cpp @@ -1,6 +1,6 @@ #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/interrupts/Interupts.h" #include "kernel/memory/MMIO.h" diff --git a/kernel/kernel/memory/Memory.cpp b/kernel/kernel/memory/Memory.cpp index bccac6718d..f533fcedc1 100644 --- a/kernel/kernel/memory/Memory.cpp +++ b/kernel/kernel/memory/Memory.cpp @@ -4,7 +4,7 @@ #include #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/graphics/Graphics.h" #include "kernel/interrupts/Interupts.h" diff --git a/kernel/kernel/modules/Ramdisk.cpp b/kernel/kernel/modules/Ramdisk.cpp index 524925ac5e..682b431ead 100644 --- a/kernel/kernel/modules/Ramdisk.cpp +++ b/kernel/kernel/modules/Ramdisk.cpp @@ -3,7 +3,7 @@ #include #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/memory/Memory.h" #include "kernel/modules/Modules.h" diff --git a/kernel/kernel/plugs.cpp b/kernel/kernel/plugs.cpp index a66330c43f..58d4d47741 100644 --- a/kernel/kernel/plugs.cpp +++ b/kernel/kernel/plugs.cpp @@ -8,8 +8,7 @@ #include #include -#include "archs/Architectures.h" -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/graphics/EarlyConsole.h" #include "kernel/interrupts/Interupts.h" diff --git a/kernel/kernel/scheduling/Scheduler.cpp b/kernel/kernel/scheduling/Scheduler.cpp index b9eea16055..effae6df19 100644 --- a/kernel/kernel/scheduling/Scheduler.cpp +++ b/kernel/kernel/scheduling/Scheduler.cpp @@ -1,6 +1,5 @@ -#include "archs/Architectures.h" -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/interrupts/Interupts.h" #include "kernel/scheduling/Scheduler.h" diff --git a/kernel/kernel/system/Panic.cpp b/kernel/kernel/system/Panic.cpp index 37f6c2e3fd..7abfee4970 100644 --- a/kernel/kernel/system/Panic.cpp +++ b/kernel/kernel/system/Panic.cpp @@ -1,4 +1,4 @@ -#include "archs/Architectures.h" +#include "archs/Arch.h" #include "kernel/graphics/EarlyConsole.h" #include "kernel/graphics/Font.h" @@ -89,7 +89,7 @@ void system_panic_internal(Utils::SourceLocation location, void *stackframe, con stream_format(out_stream, " PANIC\n\t// %s\n\n\t\e[0;31m", YO_DAWG); } - font_set_fg(0xffDC2626); + font_set_fg(0xffDC2626); stream_vprintf(out_stream, message, va); font_set_fg(0xff404040); stream_format(out_stream, "\e[0m\n\tthrow by %s %s() ln%d", location.file(), location.function(), location.line()); diff --git a/kernel/kernel/system/System.cpp b/kernel/kernel/system/System.cpp index 699533be95..e754108fab 100644 --- a/kernel/kernel/system/System.cpp +++ b/kernel/kernel/system/System.cpp @@ -1,7 +1,7 @@ #include #include -#include "archs/Architectures.h" +#include "archs/Arch.h" #include "kernel/scheduling/Scheduler.h" #include "kernel/system/System.h" diff --git a/kernel/kernel/tasking/Syscalls.cpp b/kernel/kernel/tasking/Syscalls.cpp index 98d21d209c..28161db92c 100644 --- a/kernel/kernel/tasking/Syscalls.cpp +++ b/kernel/kernel/tasking/Syscalls.cpp @@ -5,7 +5,7 @@ #include #include -#include "archs/Architectures.h" +#include "archs/Arch.h" #include "kernel/interrupts/Interupts.h" #include "kernel/scheduling/Scheduler.h" diff --git a/kernel/kernel/tasking/Task-Memory.cpp b/kernel/kernel/tasking/Task-Memory.cpp index ad55dfe97a..9d0e9eb29f 100644 --- a/kernel/kernel/tasking/Task-Memory.cpp +++ b/kernel/kernel/tasking/Task-Memory.cpp @@ -1,6 +1,6 @@ #include -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/interrupts/Interupts.h" #include "kernel/tasking/Task-Memory.h" diff --git a/kernel/kernel/tasking/Task.cpp b/kernel/kernel/tasking/Task.cpp index 63612888d2..3535d0f189 100644 --- a/kernel/kernel/tasking/Task.cpp +++ b/kernel/kernel/tasking/Task.cpp @@ -1,8 +1,7 @@ #include #include -#include "archs/Architectures.h" -#include "archs/VirtualMemory.h" +#include "archs/Arch.h" #include "kernel/interrupts/Interupts.h" #include "kernel/scheduling/Scheduler.h" diff --git a/userspace/libraries/libio/Format.h b/userspace/libraries/libio/Format.h index 21d430d2a6..99917d213f 100644 --- a/userspace/libraries/libio/Format.h +++ b/userspace/libraries/libio/Format.h @@ -126,6 +126,12 @@ ResultOr format(IO::Writer &, const Formating &, double); ResultOr format(IO::Writer &, const Formating &, const char *); +template +ResultOr format(IO::Writer &writer, const Formating &format, const T *ptr) +{ + return IO::format(writer, format, reinterpret_cast(ptr)); +} + ResultOr format(IO::Writer &, const Formating &, const String); ResultOr format(IO::Writer &, const Formating &, const Path);