compile with wall,extra,error,pedantic

main
Clyne 3 months ago
parent abfdd6eb3e
commit 85c8fd05f1
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

@ -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 \

@ -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");

@ -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 = {

@ -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;

@ -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;
}

@ -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)) {

@ -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)
{
}

@ -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),

@ -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;

Loading…
Cancel
Save