diff --git a/src/Makefile b/src/Makefile index 0fcf769..3b491c3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ CCPREFIX = /home/kotovalexarian/repos/global/tailix/cross/root/bin/i386-elf- LIBKERNAUX_PREFIX = /opt/libkernaux/i386 +DRIVERS_PREFIX = /opt/drivers/i386 AS = $(CCPREFIX)as CC = $(CCPREFIX)gcc @@ -16,7 +17,8 @@ CFLAGS = \ -ffreestanding \ -fno-builtin \ -fno-stack-protector \ - -I$(LIBKERNAUX_PREFIX)/include + -I$(LIBKERNAUX_PREFIX)/include \ + -I$(DRIVERS_PREFIX)/include CPPFLAGS = \ -DKERNAUX_ENABLE_ASSERT \ @@ -47,7 +49,7 @@ clean: rm -f $(KERNEL) $(OBJS) $(KERNEL): $(OBJS) - $(CC) -T linker.ld -o $@ $^ -ffreestanding -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_PREFIX)/lib + $(CC) -T linker.ld -o $@ $^ -ffreestanding -nostdlib -ldrivers -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_PREFIX)/lib -Wl,-L$(DRIVERS_PREFIX)/lib grub-file --is-x86-multiboot2 $@ %.c.o: %.c diff --git a/src/info.c b/src/info.c index fbd328f..94afe49 100644 --- a/src/info.c +++ b/src/info.c @@ -1,8 +1,8 @@ #include "info.h" #include "panic.h" +#include #include -#include #include @@ -156,21 +156,21 @@ void kernel_info_print(const struct Kernel_Info *const kinfo) { KERNAUX_ASSERT(kinfo); - kernaux_drivers_console_printf("Kernel info\n"); - kernaux_drivers_console_printf(" cmdline: %s\n", kinfo->cmdline); - kernaux_drivers_console_printf(" modules: %lu\n", kinfo->modules_count); - kernaux_drivers_console_printf(" areas: %lu\n", kinfo->areas_count); - kernaux_drivers_console_printf("\n"); - kernaux_drivers_console_printf(" offset: %lu\n", kinfo->kernel_offset); - kernaux_drivers_console_printf(" size: %lu\n", kinfo->kernel_size); - kernaux_drivers_console_printf(" phys base: %lu\n", kinfo->kernel_phys_base); - kernaux_drivers_console_printf(" virt base: %lu\n", kinfo->kernel_virt_base); - kernaux_drivers_console_printf("\n"); - kernaux_drivers_console_printf(" modules size: %lu\n", kinfo->modules_total_size); - kernaux_drivers_console_printf(" kernel & modules size: %lu\n", kinfo->kernel_and_modules_total_size); - kernaux_drivers_console_printf("\n"); - kernaux_drivers_console_printf(" stack start: %lu\n", kinfo->kernel_stack_start); - kernaux_drivers_console_printf(" stack size: %lu\n", kinfo->kernel_stack_size); + drivers_console_printf("Kernel info\n"); + drivers_console_printf(" cmdline: %s\n", kinfo->cmdline); + drivers_console_printf(" modules: %lu\n", kinfo->modules_count); + drivers_console_printf(" areas: %lu\n", kinfo->areas_count); + drivers_console_printf("\n"); + drivers_console_printf(" offset: %lu\n", kinfo->kernel_offset); + drivers_console_printf(" size: %lu\n", kinfo->kernel_size); + drivers_console_printf(" phys base: %lu\n", kinfo->kernel_phys_base); + drivers_console_printf(" virt base: %lu\n", kinfo->kernel_virt_base); + drivers_console_printf("\n"); + drivers_console_printf(" modules size: %lu\n", kinfo->modules_total_size); + drivers_console_printf(" kernel & modules size: %lu\n", kinfo->kernel_and_modules_total_size); + drivers_console_printf("\n"); + drivers_console_printf(" stack start: %lu\n", kinfo->kernel_stack_start); + drivers_console_printf(" stack size: %lu\n", kinfo->kernel_stack_size); } bool kernel_info_is_valid(const struct Kernel_Info *const kinfo) diff --git a/src/interrupts/exception.c b/src/interrupts/exception.c index 4a150b1..a476a4d 100644 --- a/src/interrupts/exception.c +++ b/src/interrupts/exception.c @@ -1,7 +1,7 @@ #include "main.h" #include "../panic.h" -#include +#include static const char *const messages[] = { "0 #DE - Divide Error Exception", @@ -42,7 +42,7 @@ void exception_handler(struct IsrRegisters regs) { if (regs.int_no > INT_EXCEPTION_LAST) return; - kernaux_drivers_console_printf( + drivers_console_printf( "[FAIL] exception: Unhandled protected-mode exception: %s\n", messages[regs.int_no] ); diff --git a/src/interrupts/hwint.c b/src/interrupts/hwint.c index 83c5353..71a0dc4 100644 --- a/src/interrupts/hwint.c +++ b/src/interrupts/hwint.c @@ -1,7 +1,7 @@ #include "main.h" -#include -#include +#include +#include static hwint_handler_t handlers[INT_HWINT_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -14,12 +14,12 @@ void hwint_handler(struct IsrRegisters regs) const hwint_handler_t handler = handlers[hwint_no]; if (!handler) { - kernaux_drivers_console_printf("[WARN] hwint: Unhandled hardware interrupt: %u\n", hwint_no); + drivers_console_printf("[WARN] hwint: Unhandled hardware interrupt: %u\n", hwint_no); return; } handler(); - kernaux_drivers_intel_8259_pic_eoi(regs.int_no); + drivers_intel_8259_pic_eoi(regs.int_no); } void hwint_register_handler(unsigned int int_no, hwint_handler_t handler) @@ -29,7 +29,7 @@ void hwint_register_handler(unsigned int int_no, hwint_handler_t handler) } handlers[int_no] = handler; - kernaux_drivers_intel_8259_pic_enable(int_no); + drivers_intel_8259_pic_enable(int_no); } void hwint_unregister_handler(unsigned int int_no) @@ -38,6 +38,6 @@ void hwint_unregister_handler(unsigned int int_no) return; } - kernaux_drivers_intel_8259_pic_disable(int_no); + drivers_intel_8259_pic_disable(int_no); handlers[int_no] = 0; } diff --git a/src/interrupts/syscall.c b/src/interrupts/syscall.c index 31680f1..0bf654d 100644 --- a/src/interrupts/syscall.c +++ b/src/interrupts/syscall.c @@ -1,6 +1,6 @@ #include "main.h" -#include +#include static void syscall_do_exit(struct IsrRegisters regs); @@ -8,7 +8,7 @@ void syscall_handler(const struct IsrRegisters regs) { const unsigned int id = regs.eax << 16 >> 16; - kernaux_drivers_console_printf("[INFO] syscall: number %u\n", id); + drivers_console_printf("[INFO] syscall: number %u\n", id); switch (id) { case KERNEL_SYSCALL_EXIT: syscall_do_exit(regs); break; @@ -19,5 +19,5 @@ void syscall_do_exit(const struct IsrRegisters regs) { const unsigned int exit_code = regs.ebx << 16 >> 16; - kernaux_drivers_console_printf("[WARN] syscall: process try to exit with error code %u, haha\n", exit_code); + drivers_console_printf("[WARN] syscall: process try to exit with error code %u, haha\n", exit_code); } diff --git a/src/main.c b/src/main.c index 8b190e0..95cebfe 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,7 @@ #include "panic.h" #include "protected.h" -#include +#include #include #include @@ -33,8 +33,7 @@ void main( panic("Multiboot 2 info magic number is invalid."); } - KernAux_Multiboot2_Info_print(multiboot2_info, - kernaux_drivers_console_printf); + KernAux_Multiboot2_Info_print(multiboot2_info, drivers_console_printf); if (!KernAux_Multiboot2_Info_is_valid(multiboot2_info)) { panic("Multiboot 2 info is invalid."); @@ -68,5 +67,5 @@ void main( protected_initialize(&kinfo); - kernaux_drivers_console_puts("[INFO] main: Finished."); + drivers_console_puts("[INFO] main: Finished."); } diff --git a/src/panic.c b/src/panic.c index 6303d0a..b065d02 100644 --- a/src/panic.c +++ b/src/panic.c @@ -1,14 +1,13 @@ #include "panic.h" +#include +#include #include -#include -#include -#include void panic(const char *const s) { - kernaux_drivers_console_printf("[FAIL] panic: %s\n", s); - kernaux_drivers_shutdown_poweroff(); + drivers_console_printf("[FAIL] panic: %s\n", s); + drivers_shutdown_poweroff(); } void halt() @@ -21,7 +20,7 @@ void kernaux_assert_fn( const int line, const char *const str ) { - kernaux_drivers_console_printf("[FAIL] assertion failed: %s:%u: \"%s\"\n", - file, line, str); - kernaux_drivers_shutdown_poweroff(); + drivers_console_printf("[FAIL] assertion failed: %s:%u: \"%s\"\n", + file, line, str); + drivers_shutdown_poweroff(); } diff --git a/src/protected.c b/src/protected.c index a5c89af..84a6bc8 100644 --- a/src/protected.c +++ b/src/protected.c @@ -4,10 +4,10 @@ #include "info.h" #include "interrupts/main.h" +#include +#include #include #include -#include -#include #include #include @@ -27,21 +27,21 @@ static void idt_set_gate(uint8_t num, uint32_t base, uint16_t sel, uint8_t flags void protected_initialize(const struct Kernel_Info *const kinfo) { - kernaux_drivers_intel_8259_pic_remap(32, 40); - kernaux_drivers_intel_8259_pic_disable_all(); + drivers_intel_8259_pic_remap(32, 40); + drivers_intel_8259_pic_disable_all(); - kernaux_drivers_console_puts("[INFO] protected: Setup GDT."); + drivers_console_puts("[INFO] protected: Setup GDT."); gdt_set_gates(); - kernaux_drivers_console_puts("[INFO] protected: Setup IDT."); + drivers_console_puts("[INFO] protected: Setup IDT."); idt_set_gates(); - kernaux_drivers_console_puts("[INFO] protected: Setup TSS."); + drivers_console_puts("[INFO] protected: Setup TSS."); memset(&tss, 0, sizeof(tss)); tss.ss0 = GDT_KERNEL_DS_SELECTOR; tss.esp0 = kinfo->kernel_stack_start + kinfo->kernel_stack_size; - kernaux_drivers_console_puts("[INFO] protected: Load GDT."); + drivers_console_puts("[INFO] protected: Load GDT."); gdt_pointer.size = sizeof(struct KernAux_Arch_I386_DTE) * GDT_SIZE - 1; gdt_pointer.offset = (uint32_t)&gdt_entries; kernaux_asm_i386_flush_gdt( @@ -50,18 +50,18 @@ void protected_initialize(const struct Kernel_Info *const kinfo) GDT_KERNEL_CS_SELECTOR ); - kernaux_drivers_console_puts("[INFO] protected: Load IDT."); + drivers_console_puts("[INFO] protected: Load IDT."); idt_pointer.size = sizeof(struct KernAux_Arch_I386_IDTE) * IDT_SIZE - 1; idt_pointer.offset = (uint32_t)&idt_entries; kernaux_asm_i386_flush_idt((uint32_t)&idt_pointer); - // kernaux_drivers_console_puts("[INFO] protected: Load TSS."); + // drivers_console_puts("[INFO] protected: Load TSS."); // kernaux_asm_i386_flush_tss(GDT_TSS_SELECTOR); - kernaux_drivers_console_puts("[INFO] protected: Enable interrupts."); + drivers_console_puts("[INFO] protected: Enable interrupts."); asm volatile ("sti"); - kernaux_drivers_console_puts("[INFO] protected: Finished."); + drivers_console_puts("[INFO] protected: Finished."); } void gdt_set_gates() diff --git a/src/timer.c b/src/timer.c index ad18c49..fe23e39 100644 --- a/src/timer.c +++ b/src/timer.c @@ -1,13 +1,13 @@ #include "timer.h" +#include +#include #include -#include -#include void timer_initialize(unsigned int frequency) { - kernaux_drivers_console_puts("[INFO] timer: Initialize timer."); - kernaux_drivers_intel_8253_pit_initialize(frequency); + drivers_console_puts("[INFO] timer: Initialize timer."); + drivers_intel_8253_pit_initialize(frequency); } void timer_register_handler(timer_handler_t handler)