From fb9d73ff32de7c83552707622512be0ef1db241c Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 22 Feb 2021 09:59:58 +0200 Subject: Enable interrupts --- libk/makefile | 3 ++- libk/stdlib/abort.cc | 15 +++++++++++++++ libk/stdlib/console.cc | 12 ------------ 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 libk/stdlib/abort.cc (limited to 'libk') diff --git a/libk/makefile b/libk/makefile index 0f75e5a..966caae 100644 --- a/libk/makefile +++ b/libk/makefile @@ -1,3 +1,4 @@ -CXX_OBJ += libk/string/string.o libk/string/integerview.o libk/stdlib/console.o +CXX_OBJ += libk/string/string.o libk/string/integerview.o \ + libk/stdlib/abort.o libk/stdlib/console.o CXX_TEST_OBJ += libk/types/test.o libk/string/test.o diff --git a/libk/stdlib/abort.cc b/libk/stdlib/abort.cc new file mode 100644 index 0000000..56ca7ee --- /dev/null +++ b/libk/stdlib/abort.cc @@ -0,0 +1,15 @@ +#include "stdlib.h" + +void abort() { + /* + * On gcc, a 'while(true) {}' will infinitely loop + * but clang will optimize it away on -O2 if it's empty + * therefore, add no-op + */ + + asm volatile("cli"); + while (true) { + asm volatile("hlt"); + } + __builtin_unreachable(); +} diff --git a/libk/stdlib/console.cc b/libk/stdlib/console.cc index a234e6b..c076297 100644 --- a/libk/stdlib/console.cc +++ b/libk/stdlib/console.cc @@ -13,15 +13,3 @@ void Console::set(Console* ptr) { Iterator Console::begin() { return Iterator(global_console, last_console); } - -void abort() { - /* - * On gcc, a 'while(true) {}' will infinitely loop - * but clang will optimize it away on -O2 if it's empty - * therefore, add no-op - */ - while (true) { - asm volatile("nop"); - } - __builtin_unreachable(); -} -- cgit v1.2.1