Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Generated from CLion Inspection settings
---
Checks: '-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bad-signal-to-kill-thread,
bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-no-escape,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-reserved-identifier,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-include,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-suspicious-memory-comparison,
bugprone-suspicious-realloc-usage,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-self-assignment,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cert-dcl21-cpp,
cert-dcl58-cpp,
cert-err34-c,
cert-err52-cpp,
cert-err60-cpp,
cert-flp30-c,
cert-msc50-cpp,
cert-msc51-cpp,
cert-str34-c,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-slicing,
google-default-arguments,
google-explicit-constructor,
google-runtime-operator,
hicpp-exception-baseclass,
hicpp-multiway-paths-covered,
misc-misplaced-const,
misc-new-delete-overloads,
misc-no-recursion,
misc-non-copyable-objects,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-return-braced-init-list,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nodiscard,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
mpi-buffer-deref,
mpi-type-mismatch,
openmp-use-default-none,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-noexcept-move-constructor,
performance-trivially-destructible,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
portability-simd-intrinsics,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-delete-null-pointer,
readability-deleted-default,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
readability-use-anyofallof'
42 changes: 21 additions & 21 deletions Kernel/Core/Panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

void __attribute__((noreturn)) KernelPanicHandler() {
PrintKernelError("\nKernelPanicHandler() processing...\n\n");
// No busy-wait, just halt
PrintKernelError("KernelPanicHandler() has encountered a fatal problem that it could not handled.");
while (1) {
asm volatile("hlt");
int ForceReboot() {
PrintKernelError("[SYSTEM] Loading hardware reset modules...\n");
asm volatile("lidt %0" :: "m"(*(short*)0));
PrintKernelWarning("[SYSTEM] Rebooting now...");
asm volatile("int $0x3");
}


void KernelPanicHandler() {
PrintKernelError("\n[SYSTEM] KernelPanicHandler() processing...\n");
PrintKernelError("[SYSTEM] Found 1 solution(s)...\n");
PrintKernelError("[SYSTEM] Forcing reboot, calling ForceReboot()\n");
if (!ForceReboot()) {
PrintKernelError("[SYSTEM] KernelPanicHandler() has encountered a fatal problem that it could not handled.");
while (1) {
asm volatile("hlt");
}
}
}

void __attribute__((noreturn)) Panic(const char* message) {
asm volatile("cli");
// ClearScreen();
// CurrentLine = 0;
// CurrentColumn = 0;
// No busy-wait, just halt
PrintKernelError("\n[FATAL] - [----KERNEL PANIC----]\n\n");
PrintKernelError("\n[SYSTEM] - [FATAL] - [----KERNEL PANIC----]\n");
PrintKernelError(message);
PrintKernelError("\nCalling KernelPanicHandler()...\n");
PrintKernelError("\n[SYSTEM] Calling KernelPanicHandler()...\n");
KernelPanicHandler();
}

void __attribute__((noreturn)) PanicWithCode(const char* message, uint64_t error_code) {
asm volatile("cli");
// ClearScreen();
// CurrentLine = 0;
// CurrentColumn = 0;
// No busy-wait, just halt
PrintKernelError("\n[FATAL] - [----KERNEL PANIC----]\n");
PrintKernelError("\np[SYSTEM] - [FATAL] - [----KERNEL PANIC----]\n");
PrintKernelError(message);
PrintKernelError("\nError Code: ");
PrintKernelError("\n[SYSTEM] Error Code: ");
PrintKernelHex(error_code);
PrintKernelError(" -- Not handled");
KernelPanicHandler();
while(1) {
asm volatile("hlt");
}
}
15 changes: 10 additions & 5 deletions Kernel/Process/Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ uint64_t GetSystemTicks(void) {

static void AddToTerminationQueue(uint32_t slot) {
if (term_queue_count >= MAX_PROCESSES) return;

if (term_queue_count >= MAX_PROCESSES) {
PrintKernelError("[KERNEL] Termination queue full! Cannot add slot ");
PrintKernelInt(slot);
PrintKernelError("\n");
Panic("Termination queue overflow");
}
termination_queue[term_queue_tail] = slot;
term_queue_tail = (term_queue_tail + 1) % MAX_PROCESSES;
term_queue_count++;
Expand Down Expand Up @@ -63,7 +68,7 @@ void TerminateProcess(uint32_t pid, TerminationReason reason, uint32_t exit_code
uint32_t slot = proc - processes;
if (slot >= MAX_PROCESSES) return;

PrintKernel("[KERNEL] Terminating process PID: ");
PrintKernel("[SYSTEM] Terminating process PID: ");
PrintKernelInt(pid);
PrintKernel(" Reason: ");
PrintKernelInt(reason);
Expand Down Expand Up @@ -545,7 +550,7 @@ uint32_t CreateProcess(void (*entry_point)(void)) {
void ProcessExitStub() {
Process* current = GetCurrentProcess();

PrintKernelWarning("[KERNEL] Process PID ");
PrintKernelWarning("[SYSTEM] Process PID ");
PrintKernelInt(current->pid);
PrintKernelWarning(" exited normally\n");

Expand Down Expand Up @@ -657,7 +662,7 @@ void CleanupTerminatedProcesses(void) {
continue;
}

PrintKernel("[KERNEL] Cleaning up process PID: ");
PrintKernel("[SYSTEM] Cleaning up process PID: ");
PrintKernelInt(proc->pid);
PrintKernel("\n");

Expand All @@ -681,7 +686,7 @@ void CleanupTerminatedProcesses(void) {
process_count--;
cleanup_count++;

PrintKernel("[KERNEL] Process PID ");
PrintKernel("[SYSTEM] Process PID ");
PrintKernelInt(pid_backup);
PrintKernel(" cleaned up successfully (state now PROC_TERMINATED=0)\n");
}
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ iso = custom_target('VoidFrame.iso',

# Run target
run_target('run',
command : ['qemu-system-x86_64', '-cdrom', 'VoidFrame.iso', '-debugcon', 'stdio' , '-m', '1G']
command : ['qemu-system-x86_64', '-cdrom', 'VoidFrame.iso', '-debugcon', 'stdio' , '-no-reboot','-no-shutdown','-m', '1G']
)