[Zion] Compile kernel with -Wall -Werror.

This commit is contained in:
Drew Galbraith 2023-11-26 22:07:52 -08:00
parent 4e25a7e3b9
commit 6d108f6965
5 changed files with 7 additions and 26 deletions

View File

@ -69,7 +69,7 @@ target_link_libraries(zion
# -mno-red-zone -- Don't put data below the stack pointer (clobbered by interrupts).
# -mcmodel=kernel -- Assume the kernel code is running in the higher half.
# -mgeneral-regs-only -- Prevent GCC from using a whole host of nonsense registers (that we have to enable).
set(_Z_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -c -ffreestanding -fno-rtti -fno-exceptions -fno-use-cxa-atexit -nostdlib -mabi=sysv -mno-red-zone -mcmodel=kernel -mgeneral-regs-only")
set(_Z_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -c -ffreestanding -fno-rtti -fno-exceptions -fno-use-cxa-atexit -nostdlib -mabi=sysv -mno-red-zone -mcmodel=kernel -mgeneral-regs-only -Wall -Werror")
set(_Z_LINK_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")

View File

@ -96,6 +96,7 @@ bool checksum(uint8_t* addr, uint8_t num_bytes) {
return check_cnt == 0;
}
#if K_ACPI_DEBUG
void dbgsz(const char* c, uint8_t cnt) {
char cl[cnt + 1];
@ -105,6 +106,7 @@ void dbgsz(const char* c, uint8_t cnt) {
cl[cnt] = '\0';
dbgln(cl);
}
#endif
uint8_t* SdtDataStart(SdtHeader* sdt) {
return reinterpret_cast<uint8_t*>(sdt) + sizeof(SdtHeader);
@ -157,8 +159,8 @@ void ParseMadt(SdtHeader* rsdt) {
while (reinterpret_cast<uint64_t>(entry) < max_addr) {
switch (entry->type) {
case 0: {
MadtLocalApic* local = reinterpret_cast<MadtLocalApic*>(entry);
#if K_ACPI_DEBUG
MadtLocalApic* local = reinterpret_cast<MadtLocalApic*>(entry);
dbgln("Local APIC (Proc id, id, flags): {x}, {x}, {x}",
local->processor_id, local->apic_id, +local->flags);
#endif
@ -177,9 +179,9 @@ void ParseMadt(SdtHeader* rsdt) {
break;
}
case 2: {
#if K_ACPI_DEBUG
MadtIoApicInterruptSource* src =
reinterpret_cast<MadtIoApicInterruptSource*>(entry);
#if K_ACPI_DEBUG
dbgln("IO Source (Bus, IRQ, GSI, flags): {x}, {x}, {x}, {x}",
src->bus_source, src->irq_source, +src->global_system_interrupt,
+src->flags);
@ -187,9 +189,9 @@ void ParseMadt(SdtHeader* rsdt) {
break;
}
case 4: {
#if K_ACPI_DEBUG
MadtLocalApicNonMaskable* lnmi =
reinterpret_cast<MadtLocalApicNonMaskable*>(entry);
#if K_ACPI_DEBUG
dbgln("Local NMI (proc id, flags, lint#): {x}, {x}, {x}",
lnmi->apic_processor_id, +lnmi->flags, lnmi->lint_num);
#endif

View File

@ -41,7 +41,6 @@ static TaskStateSegment gTaskStateSegment;
extern "C" void ReloadSegments();
uint64_t CreateSegment(uint64_t access, uint64_t flags) {
uint64_t base = 0;
access &= 0xFF;
flags &= 0xF0;
flags |= 0xF; // For the highest 4 bits of the limit.

View File

@ -15,12 +15,6 @@ void dbgputchar(char c) {
outb(COM1, c);
}
void dbgcstr(const char* str) {
for (; *str != '\0'; str++) {
dbgputchar(*str);
}
}
void dbg(const glcr::StringView& str) {
for (uint64_t i = 0; i < str.size(); i++) {
dbgputchar(str[i]);

View File

@ -84,20 +84,6 @@ uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t offset) {
return header->entry;
}
bool streq(const char* a, const char* b) {
while (true) {
if (*a == '\0' && *b == '\0') return true;
if (*a == '\0' || *b == '\0') {
return false;
}
if (*a != *b) {
return false;
}
a++;
b++;
}
}
void DumpModules() {
#if K_INIT_DEBUG
const limine_module_response& resp = boot::GetModules();
@ -188,7 +174,7 @@ void LoadInitProgram() {
}
// Start process.
const limine_file& init_prog = GetInitProgram("/sys/yellowstone");
limine_file init_prog = GetInitProgram("/sys/yellowstone");
uint64_t entry = LoadElfProgram(
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
proc->CreateThread()->Start(entry, port_cap, 0);