diff options
-rw-r--r-- | kernel/Makefile | 8 | ||||
-rw-r--r-- | kernel/arch/i386/mmu.c | 4 | ||||
-rw-r--r-- | kernel/cpu/idt.c | 14 | ||||
-rw-r--r-- | kernel/cpu/idt.h | 5 | ||||
-rw-r--r-- | kernel/drivers/mouse.c | 9 | ||||
-rw-r--r-- | kernel/drivers/rtl8139.c | 2 | ||||
-rw-r--r-- | kernel/elf.c | 4 | ||||
-rw-r--r-- | kernel/hashmap/hashmap.c | 2 | ||||
-rw-r--r-- | kernel/kmalloc.c | 2 | ||||
-rw-r--r-- | kernel/sched/scheduler.c | 6 | ||||
-rw-r--r-- | kernel/sched/scheduler.h | 4 |
11 files changed, 31 insertions, 29 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 8701f13..2e9e301 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,13 +1,7 @@ CC="i686-sb-gcc" AS="i686-sb-as" OBJ = arch/i386/boot.o init/kernel.o cpu/gdt.o cpu/reload_gdt.o cpu/idt.o cpu/io.o libc/stdio/print.o drivers/keyboard.o log.o drivers/pit.o libc/string/memcpy.o libc/string/strlen.o libc/string/memcmp.o drivers/ata.o libc/string/memset.o cpu/syscall.o read_eip.o libc/exit/assert.o process.o libc/string/strcpy.o arch/i386/mmu.o kmalloc.o fs/ext2.o fs/vfs.o fs/devfs.o cpu/spinlock.o random.o libc/string/strcmp.o crypto/ChaCha20/chacha20.o crypto/SHA1/sha1.o fs/tmpfs.o libc/string/isequal.o drivers/pst.o syscalls/ppoll.o syscalls/ftruncate.o kubsan.o syscalls/mmap.o drivers/serial.o syscalls/accept.o syscalls/bind.o syscalls/socket.o socket.o poll.o fs/fifo.o hashmap/hashmap.o fs/shm.o syscalls/shm.o elf.o ksbrk.o sched/scheduler.o syscalls/fstat.o libc/string/copy.o drivers/mouse.o libc/string/strlcpy.o libc/string/strcat.o drivers/vbe.o syscalls/msleep.o syscalls/uptime.o syscalls/mkdir.o drivers/pci.o drivers/rtl8139.o network/ethernet.o network/arp.o network/bytes.o network/ipv4.o network/udp.o syscalls/recvfrom.o math.o syscalls/sendto.o signal.o syscalls/kill.o syscalls/sigaction.o network/tcp.o drivers/ahci.o crypto/xoshiro256plusplus/xoshiro256plusplus.o syscalls/chdir.o syscalls/getcwd.o syscalls/isatty.o syscalls/randomfill.o syscalls/open.o syscalls/write.o syscalls/pwrite.o syscalls/port.o syscalls/map_frames.o syscalls/virtual_to_physical.o syscalls/install_irq.o arch/i386/interrupts.o cpu/isr.o lib/stack.o lib/buffered_write.o lib/list.o cpu/arch_inst.o cpu/int_syscall.o queue.o syscalls/queue.o syscalls/munmap.o syscalls/open_process.o -CFLAGS = -std=c99 -O0 -fsanitize=vla-bound,shift-exponent,pointer-overflow,shift,signed-integer-overflow,bounds -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#CFLAGS = -std=c99 -Ofast -flto -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#CFLAGS = -std=c99 -O0 -fsanitize=vla-bound,shift-exponent,pointer-overflow,shift,signed-integer-overflow,bounds -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#CFLAGS = -std=c99 -Ofast -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#CFLAGS = -Ofast -fsanitize=vla-bound,shift-exponent,pointer-overflow,shift,signed-integer-overflow,bounds -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#CFLAGS = -O0 -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL -#LDFLAGS=-flto -Ofast +CFLAGS = -std=c99 -O0 -fsanitize=vla-bound,shift-exponent,pointer-overflow,shift,signed-integer-overflow,bounds -ggdb -ffreestanding -Wall -Wextra -Wno-int-conversion -Wno-unused-parameter -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL LDFLAGS= INCLUDE=-I./includes/ -I../include/ -I./libc/include/ diff --git a/kernel/arch/i386/mmu.c b/kernel/arch/i386/mmu.c index 3e8570d..6fd00b6 100644 --- a/kernel/arch/i386/mmu.c +++ b/kernel/arch/i386/mmu.c @@ -649,7 +649,7 @@ void paging_init(u64 memsize, multiboot_info_t *mb) { { multiboot_memory_map_t *map = (multiboot_memory_map_t *)(mb->mmap_addr + 0xc0000000); - for (int length = 0; length < mb->mmap_length;) { + for (size_t length = 0; length < mb->mmap_length;) { if (MULTIBOOT_MEMORY_AVAILABLE == map->type) { num_of_frames = max(num_of_frames, map->addr + map->len); for (size_t i = 0; i < map->len; i += 0x20000) { @@ -720,7 +720,7 @@ void paging_init(u64 memsize, multiboot_info_t *mb) { { multiboot_memory_map_t *map = (multiboot_memory_map_t *)(mb->mmap_addr + 0xc0000000); - for (int length = 0; length < mb->mmap_length;) { + for (size_t length = 0; length < mb->mmap_length;) { if (MULTIBOOT_MEMORY_AVAILABLE == map->type) { for (size_t i = 0; i < map->len - 0x1000; i += 0x20000) { u32 frame = (map->addr + i) / 0x1000; diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index ce21d08..9508f8c 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -217,8 +217,6 @@ void *isr_list[] = { isr252, isr253, isr254, isr255, }; -typedef int (*interrupt_handler)(reg_t *); - interrupt_handler list_of_handlers[256]; void int_handler(reg_t *r) { @@ -246,7 +244,8 @@ void int_handler(reg_t *r) { } } -void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry) { +void install_handler(interrupt_handler handler_function, u16 type_attribute, + u8 entry) { format_descriptor((u32)isr_list[entry], KERNEL_CODE_SEGMENT_OFFSET, type_attribute, &IDT_Entry[entry]); list_of_handlers[entry] = (interrupt_handler)handler_function; @@ -255,9 +254,12 @@ void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry) { void idt_init(void) { memset(list_of_handlers, 0, sizeof(void *) * 256); - install_handler(page_fault, INT_32_INTERRUPT_GATE(0x0), 0xE); - install_handler(double_fault, INT_32_INTERRUPT_GATE(0x0), 0x8); - install_handler(general_protection_fault, INT_32_INTERRUPT_GATE(0x0), 0xD); + install_handler((interrupt_handler)page_fault, INT_32_INTERRUPT_GATE(0x0), + 0xE); + install_handler((interrupt_handler)double_fault, INT_32_INTERRUPT_GATE(0x0), + 0x8); + install_handler((interrupt_handler)general_protection_fault, + INT_32_INTERRUPT_GATE(0x0), 0xD); PIC_remap(0x20); IRQ_clear_mask(0xb); diff --git a/kernel/cpu/idt.h b/kernel/cpu/idt.h index 9cb6e4d..d866659 100644 --- a/kernel/cpu/idt.h +++ b/kernel/cpu/idt.h @@ -322,5 +322,8 @@ typedef struct reg { void idt_init(void); __attribute__((no_caller_saved_registers)) void EOI(unsigned char irq); -void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry); + +typedef void (*interrupt_handler)(reg_t *); +void install_handler(interrupt_handler handler_function, u16 type_attribute, + u8 entry); #endif diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c index 87a4955..4b0696a 100644 --- a/kernel/drivers/mouse.c +++ b/kernel/drivers/mouse.c @@ -140,7 +140,10 @@ void install_mouse(void) { mouse_write(0xF4); mouse_read(); // Acknowledge - install_handler(int_mouse, INT_32_INTERRUPT_GATE(0x3), 12 + 0x20); - install_handler(what, INT_32_INTERRUPT_GATE(0x3), 0xe + 0x20); - install_handler(what, INT_32_INTERRUPT_GATE(0x3), 0xf + 0x20); + install_handler((interrupt_handler)int_mouse, INT_32_INTERRUPT_GATE(0x3), + 12 + 0x20); + install_handler((interrupt_handler)what, INT_32_INTERRUPT_GATE(0x3), + 0xe + 0x20); + install_handler((interrupt_handler)what, INT_32_INTERRUPT_GATE(0x3), + 0xf + 0x20); } diff --git a/kernel/drivers/rtl8139.c b/kernel/drivers/rtl8139.c index 592397f..78e6570 100644 --- a/kernel/drivers/rtl8139.c +++ b/kernel/drivers/rtl8139.c @@ -194,7 +194,7 @@ void rtl8139_init(void) { outl(base_address + 0x44, 0xf); // 0xf is AB+AM+APM+AAP - install_handler(rtl8139_handler, INT_32_INTERRUPT_GATE(0x3), + install_handler((interrupt_handler)rtl8139_handler, INT_32_INTERRUPT_GATE(0x3), 0x20 + interrupt_line); // ksbrk() seems to have the magical ability of disabling interrupts? diff --git a/kernel/elf.c b/kernel/elf.c index 01f1e53..f8cc6a2 100644 --- a/kernel/elf.c +++ b/kernel/elf.c @@ -45,8 +45,8 @@ void *load_elf_file(const char *f, u32 *ds) { pages_to_allocate -= p_vaddr - (p_vaddr % 0x1000); pages_to_allocate /= 0x1000; - if(!mmu_allocate_region((void *)p_vaddr, pages_to_allocate * 0x1000, - MMU_FLAG_RW, NULL)) { + if (!mmu_allocate_region((void *)p_vaddr, pages_to_allocate * 0x1000, + MMU_FLAG_RW, NULL)) { return NULL; } diff --git a/kernel/hashmap/hashmap.c b/kernel/hashmap/hashmap.c index 833ed70..32511d0 100644 --- a/kernel/hashmap/hashmap.c +++ b/kernel/hashmap/hashmap.c @@ -192,7 +192,7 @@ int hashmap_delete_entry(HashMap *m, const char *key) { } void hashmap_free(HashMap *m) { - for (int i = 0; i < m->size; i++) { + for (size_t i = 0; i < m->size; i++) { if (!m->entries[i]) { continue; } diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c index 124e5a5..087609e 100644 --- a/kernel/kmalloc.c +++ b/kernel/kmalloc.c @@ -16,7 +16,7 @@ void *kmalloc_align(size_t s, void **physical) { } void kmalloc_align_free(void *p, size_t s) { - for (int i = 0; i < s; i += 0x1000) { + for (size_t i = 0; i < s; i += 0x1000) { Page *page = get_page((char *)p + i, NULL, PAGE_NO_ALLOCATE, 0); if (!page) { continue; diff --git a/kernel/sched/scheduler.c b/kernel/sched/scheduler.c index 0eff530..423c1b6 100644 --- a/kernel/sched/scheduler.c +++ b/kernel/sched/scheduler.c @@ -77,14 +77,14 @@ const signal_t *process_pop_signal(process_t *p) { return stack_pop(&p->signal_stack); } -bool get_task_from_pid(u32 pid, process_t **out) { +int get_task_from_pid(pid_t pid, process_t **out) { for (process_t *tmp = ready_queue; tmp; tmp = tmp->next) { if (tmp->pid == pid) { *out = tmp; - return true; + return 1; } } - return false; + return 0; } void set_signal_handler(int sig, void (*handler)(int)) { diff --git a/kernel/sched/scheduler.h b/kernel/sched/scheduler.h index 04259c2..b197117 100644 --- a/kernel/sched/scheduler.h +++ b/kernel/sched/scheduler.h @@ -54,7 +54,7 @@ void process_push_signal(process_t *p, signal_t s); const signal_t *process_pop_signal(process_t *p); struct Process { - u32 pid; + pid_t pid; char program_name[100]; char current_working_directory[MAX_PATH]; void *signal_handlers[32]; @@ -95,7 +95,7 @@ struct Process { int dead; }; -bool get_task_from_pid(u32 pid, process_t **out); +int get_task_from_pid(pid_t pid, process_t **out); void free_process(process_t *p); void *get_free_virtual_memory(size_t length); #endif |