Skip to content

Commit

Permalink
arch: Merged Arch.h and VirtualMemory.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Apr 12, 2021
1 parent 92457f9 commit 7eaa96e
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 58 deletions.
33 changes: 31 additions & 2 deletions kernel/archs/VirtualMemory.h → kernel/archs/Arch.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
#pragma once

#include <abi/Memory.h>

#include <libsystem/Result.h>
#include <skift/Time.h>

#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();
Expand All @@ -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);

33 changes: 0 additions & 33 deletions kernel/archs/Architectures.h

This file was deleted.

2 changes: 1 addition & 1 deletion kernel/archs/x86/x86.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "archs/Architectures.h"
#include "archs/Arch.h"

#ifdef __x86_64__
using CRRegister = uint64_t;
Expand Down
3 changes: 1 addition & 2 deletions kernel/archs/x86_32/Power.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <libsystem/Logger.h>

#include "archs/Architectures.h"
#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "archs/x86/IOPort.h"
#include "archs/x86/x86.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/archs/x86_32/VirtualMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <libsystem/Logger.h>
#include <libutils/ResultOr.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"
#include "archs/x86_32/Paging.h"

#include "kernel/interrupts/Interupts.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/archs/x86_32/x86_32.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <assert.h>
#include <libsystem/core/Plugs.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"
#include "archs/x86/COM.h"
#include "archs/x86/CPUID.h"
#include "archs/x86/FPU.h"
Expand Down
3 changes: 1 addition & 2 deletions kernel/archs/x86_64/VirtualMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/graphics/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <libmath/MinMax.h>
#include <libsystem/Logger.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/graphics/Graphics.h"
#include "kernel/interrupts/Interupts.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/interrupts/Interupts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <libsystem/Logger.h>

#include "archs/Architectures.h"
#include "archs/Arch.h"

#include "kernel/interrupts/Dispatcher.h"
#include "kernel/interrupts/Interupts.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/memory/MMIO.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <libsystem/Logger.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/interrupts/Interupts.h"
#include "kernel/memory/MMIO.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/memory/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <libsystem/io/Stream.h>
#include <string.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/graphics/Graphics.h"
#include "kernel/interrupts/Interupts.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/modules/Ramdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <libsystem/Logger.h>
#include <libsystem/Result.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/memory/Memory.h"
#include "kernel/modules/Modules.h"
Expand Down
3 changes: 1 addition & 2 deletions kernel/kernel/plugs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <libsystem/io/Stream_internal.h>
#include <libsystem/system/System.h>

#include "archs/Architectures.h"
#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/graphics/EarlyConsole.h"
#include "kernel/interrupts/Interupts.h"
Expand Down
3 changes: 1 addition & 2 deletions kernel/kernel/scheduling/Scheduler.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions kernel/kernel/system/Panic.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "archs/Architectures.h"
#include "archs/Arch.h"

#include "kernel/graphics/EarlyConsole.h"
#include "kernel/graphics/Font.h"
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/system/System.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <libsystem/BuildInfo.h>
#include <libsystem/Logger.h>

#include "archs/Architectures.h"
#include "archs/Arch.h"
#include "kernel/scheduling/Scheduler.h"
#include "kernel/system/System.h"

Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/tasking/Syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <libsystem/Logger.h>
#include <libsystem/Result.h>

#include "archs/Architectures.h"
#include "archs/Arch.h"

#include "kernel/interrupts/Interupts.h"
#include "kernel/scheduling/Scheduler.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/tasking/Task-Memory.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string.h>

#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/interrupts/Interupts.h"
#include "kernel/tasking/Task-Memory.h"
Expand Down
3 changes: 1 addition & 2 deletions kernel/kernel/tasking/Task.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <assert.h>
#include <string.h>

#include "archs/Architectures.h"
#include "archs/VirtualMemory.h"
#include "archs/Arch.h"

#include "kernel/interrupts/Interupts.h"
#include "kernel/scheduling/Scheduler.h"
Expand Down
6 changes: 6 additions & 0 deletions userspace/libraries/libio/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ ResultOr<size_t> format(IO::Writer &, const Formating &, double);

ResultOr<size_t> format(IO::Writer &, const Formating &, const char *);

template <typename T>
ResultOr<size_t> format(IO::Writer &writer, const Formating &format, const T *ptr)
{
return IO::format(writer, format, reinterpret_cast<uintptr_t>(ptr));
}

ResultOr<size_t> format(IO::Writer &, const Formating &, const String);

ResultOr<size_t> format(IO::Writer &, const Formating &, const Path);
Expand Down

0 comments on commit 7eaa96e

Please sign in to comment.