aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--boot.cpp23
-rw-r--r--gdt.cpp2
-rw-r--r--idt.cpp4
-rw-r--r--kernel.cpp2
-rw-r--r--keyboard.cpp6
-rw-r--r--memory.cpp15
-rw-r--r--multiboot.cpp15
-rw-r--r--tasking.cpp8
9 files changed, 44 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 284f931..728ead6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-CXXFLAGS := -m32 -ggdb -g3 -O0 -fno-pic -fno-rtti -fno-exceptions -std=c++23
+CXXFLAGS := -m32 -ggdb -g3 -O1 -fno-pic -fno-rtti -fno-exceptions -std=c++23 \
+ -Wall -Wextra -pedantic -Werror
LDFLAGS := $(CXXFLAGS) -T link.ld -static -nostdlib -fno-use-cxa-atexit
CXXFILES := acpi.cpp \
diff --git a/boot.cpp b/boot.cpp
index 1c46b63..6b1da6a 100644
--- a/boot.cpp
+++ b/boot.cpp
@@ -1,10 +1,20 @@
#include <array>
#include <cstdint>
+#include <span>
+extern void (*__init_array_start)();
+extern void (*__init_array_end)();
extern void kernel_main();
alignas(16)
-std::array<std::uint8_t, 16384> stack;
+static std::array<std::uint8_t, 16384> stack;
+
+static void init_array()
+{
+ std::span initArray (&__init_array_start, &__init_array_end);
+ for (auto& fn : initArray)
+ fn();
+}
extern "C"
__attribute__((naked))
@@ -16,16 +26,7 @@ void _start()
mov %0, %%esp
)" :: "i" (stack.data() + stack.size()));
- extern std::uint32_t __init_array_start;
- extern std::uint32_t __init_array_end;
-
- auto it = &__init_array_start;
- while (it < &__init_array_end) {
- auto fn = reinterpret_cast<void (*)()>(*it);
- fn();
- ++it;
- }
-
+ init_array();
kernel_main();
asm volatile("cli");
diff --git a/gdt.cpp b/gdt.cpp
index 383d1a4..24d974b 100644
--- a/gdt.cpp
+++ b/gdt.cpp
@@ -24,7 +24,7 @@ struct TSSEntry
std::uint32_t prevTSS;
std::uint32_t esp0;
std::uint32_t ss0;
- std::uint32_t unused[23];
+ std::uint32_t unused[23] = {};
} __attribute__((packed));
static TSSEntry tss = {
diff --git a/idt.cpp b/idt.cpp
index 8c4a796..5380c9e 100644
--- a/idt.cpp
+++ b/idt.cpp
@@ -19,9 +19,9 @@ static constexpr std::uint8_t TrapGate32 = 0xF;
struct idt_entry_bits {
std::uint32_t offset_low : 16;
std::uint32_t segment_selector : 16;
- std::uint32_t rsvd : 8;
+ std::uint32_t rsvd : 8 = 0;
std::uint32_t gate_type : 4;
- std::uint32_t rsvd2 : 1;
+ std::uint32_t rsvd2 : 1 = 0;
std::uint32_t dpl : 2;
std::uint32_t present : 1;
std::uint32_t offset_high : 16;
diff --git a/kernel.cpp b/kernel.cpp
index 350a11e..ae3f153 100644
--- a/kernel.cpp
+++ b/kernel.cpp
@@ -95,7 +95,7 @@ void abort()
}
extern "C"
-int __cxa_atexit(void (*func)(void *), void *arg, void *dso_handle)
+int __cxa_atexit(void (*)(void *), void *, void *)
{
return 0;
}
diff --git a/keyboard.cpp b/keyboard.cpp
index db7743c..48dad02 100644
--- a/keyboard.cpp
+++ b/keyboard.cpp
@@ -26,11 +26,11 @@ static const std::array<char, 0x59> ScanCodeSet1 {{
K_F11, K_F12
}};
-static constexpr bool isReleased(auto ch) {
+static inline bool isReleased(auto ch) {
return ch & 0x80;
}
-static constexpr auto keycode(auto ch) {
+static inline auto keycode(auto ch) {
return ch & 0x7F;
}
@@ -38,7 +38,7 @@ void keyboard_initialize()
{
keyboardBuffer = CircularBuffer<char>(128);
- idt_register_callback(33, [](auto& regs) {
+ idt_register_callback(33, [](auto&) {
const std::uint8_t kc = keyboardPort;
if (!isReleased(kc)) {
diff --git a/memory.cpp b/memory.cpp
index 710701d..108c240 100644
--- a/memory.cpp
+++ b/memory.cpp
@@ -85,12 +85,23 @@ void *operator new[](std::size_t size)
return memory_alloc(size);
}
-void operator delete(void *ptr)
+void operator delete(void *)
{
}
-void operator delete[](void *ptr)
+void operator delete[](void *)
{
}
+
+void operator delete(void *, std::size_t)
+{
+
+}
+
+void operator delete[](void *, std::size_t)
+{
+
+}
+
diff --git a/multiboot.cpp b/multiboot.cpp
index 719bb5c..46c505b 100644
--- a/multiboot.cpp
+++ b/multiboot.cpp
@@ -13,6 +13,7 @@ struct multiboot2_tag
std::uint32_t data[1];
} __attribute__((packed));
+template<int N>
struct multiboot2
{
static constexpr std::uint32_t MAGIC = 0xE85250D6;
@@ -21,20 +22,16 @@ struct multiboot2
static constexpr std::uint32_t CHECKSUM = -(MAGIC + FLAGS + LENGTH);
alignas(8)
- std::uint32_t magic;
- std::uint32_t flags;
- std::uint32_t length;
- std::uint32_t checksum;
+ std::uint32_t magic = MAGIC;
+ std::uint32_t flags = FLAGS;
+ std::uint32_t length = LENGTH;
+ std::uint32_t checksum = CHECKSUM;
- multiboot2_tag tags[];
+ multiboot2_tag tags[N];
} __attribute__((packed));
__attribute__((section(".multiboot2")))
multiboot2 multibootHeader = {
- .magic = multiboot2::MAGIC,
- .flags = multiboot2::FLAGS,
- .length = multiboot2::LENGTH,
- .checksum = multiboot2::CHECKSUM,
.tags = {
{
1, 0, sizeof(multiboot2_tag) + sizeof(std::uint32_t),
diff --git a/tasking.cpp b/tasking.cpp
index 97dd51a..1b78011 100644
--- a/tasking.cpp
+++ b/tasking.cpp
@@ -21,7 +21,7 @@ struct Task
static std::array<Task, 4> tasks;
static int current = -1;
-void schedule(const Registers& regs)
+void schedule(const Registers&)
{
if (current < 0)
return;
@@ -32,7 +32,7 @@ void schedule(const Registers& regs)
)" : "=m" (tasks[current].esp), "=m" (tasks[current].ebp));
do {
- if (++current >= tasks.size())
+ if (++current >= static_cast<int>(tasks.size()))
current = 0;
} while (tasks[current].state == Task::Invalid || tasks[current].state == Task::Staging);
@@ -61,13 +61,13 @@ void tasking_initialize()
bool tasking_spawn(void (*entry)(), unsigned ssize)
{
- int i = -1;
+ unsigned i;
for (i = 0; i < tasks.size(); ++i) {
if (tasks[i].state == Task::Invalid)
break;
}
- if (i < 0)
+ if (i >= tasks.size())
return false;
tasks[i].state = Task::Staging;