diff options
author | Anton Kling <anton@kling.gg> | 2024-02-21 00:14:29 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-02-21 00:14:29 +0100 |
commit | 8ff63b062d724826d8017504063df9b92f8e6703 (patch) | |
tree | 03bf0b5a278a4908da8912f956e5651bea9412f1 /kernel/cpu | |
parent | a85eacdd2406fede4d6ff5cb130b1758978cabb3 (diff) |
New clang-format options
Diffstat (limited to 'kernel/cpu')
-rw-r--r-- | kernel/cpu/idt.c | 26 | ||||
-rw-r--r-- | kernel/cpu/syscall.c | 24 |
2 files changed, 32 insertions, 18 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index 32186c5..3d866e5 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -40,8 +40,9 @@ void format_descriptor(u32 offset, u16 code_segment, u8 type_attribute, } __attribute__((no_caller_saved_registers)) void EOI(u8 irq) { - if (irq > 7) + if (irq > 7) { outb(SLAVE_PIC_COMMAND_PORT, 0x20); + } outb(MASTER_PIC_COMMAND_PORT, 0x20); } @@ -83,23 +84,27 @@ void page_fault(reg_t *regs) { kprintf("Error Code: %x\n", regs->error_code); kprintf("Instruction Pointer: %x\n", regs->eip); - if (regs->error_code & (1 << 0)) + if (regs->error_code & (1 << 0)) { kprintf("page-protection violation\n"); - else + } else { kprintf("non-present page\n"); + } - if (regs->error_code & (1 << 1)) + if (regs->error_code & (1 << 1)) { kprintf("write access\n"); - else + } else { kprintf("read access\n"); + } - if (regs->error_code & (1 << 2)) + if (regs->error_code & (1 << 2)) { kprintf("CPL = 3\n"); + } - if (regs->error_code & (1 << 4)) + if (regs->error_code & (1 << 4)) { kprintf("Attempted instruction fetch\n"); + } - dump_backtrace(5); + dump_backtrace(12); asm("hlt"); for (;;) ; @@ -161,8 +166,9 @@ void IRQ_set_mask(unsigned char IRQline) { u16 port; u8 value; port = (IRQline < 8) ? MASTER_PIC_DATA_PORT : SLAVE_PIC_DATA_PORT; - if (IRQline >= 8) + if (IRQline >= 8) { IRQline -= 8; + } value = inb(port) | (1 << IRQline); outb(port, value); } @@ -217,7 +223,7 @@ typedef int (*interrupt_handler)(reg_t *); interrupt_handler list_of_handlers[256]; void int_handler(reg_t *r) { - interrupt_handler handler = list_of_handlers[r->int_no]; + const interrupt_handler handler = list_of_handlers[r->int_no]; if (NULL == handler) { kprintf("[NOTE] Interrupt(0x%x) called but has no interrupt handler", r->int_no); diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index 1ed5f41..e2ea7e3 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -24,15 +24,17 @@ int syscall_exec(SYS_EXEC_PARAMS *args) { } char **new_argv = kallocarray(argc + 1, sizeof(char *)); - for (int i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { new_argv[i] = copy_and_allocate_user_string(args->argv[i]); + } new_argv[argc] = NULL; exec(filename, new_argv); kfree((void *)filename); - for (int i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { kfree(new_argv[i]); + } kfree(new_argv); return -1; } @@ -52,8 +54,9 @@ int syscall_pread(SYS_PREAD_PARAMS *args) { int syscall_read(SYS_READ_PARAMS *args) { vfs_fd_t *fd = get_vfs_fd(args->fd); - if (!fd) + if (!fd) { return -EBADF; + } int rc = vfs_pread(args->fd, args->buf, args->count, fd->offset); fd->offset += rc; return rc; @@ -71,19 +74,22 @@ void syscall_exit(int status) { void syscall_wait(int *status) { disable_interrupts(); if (!get_current_task()->child) { - if (status) + if (status) { *status = -1; + } return; } if (get_current_task()->child->dead) { - if (status) + if (status) { *status = get_current_task()->child_rc; + } return; } get_current_task()->halts[WAIT_CHILD_HALT] = 1; switch_task(); - if (status) + if (status) { *status = get_current_task()->child_rc; + } } int syscall_fork(void) { @@ -98,8 +104,9 @@ void *align_page(void *a); int syscall_brk(void *addr) { void *end = get_current_task()->data_segment_end; - if (!mmu_allocate_region(end, addr - end, MMU_FLAG_RW, NULL)) + if (!mmu_allocate_region(end, addr - end, MMU_FLAG_RW, NULL)) { return -ENOMEM; + } get_current_task()->data_segment_end = align_page(addr); return 0; } @@ -110,8 +117,9 @@ void *syscall_sbrk(uintptr_t increment) { void *n = (void *)((uintptr_t)(get_current_task()->data_segment_end) + increment); int rc2; - if (0 > (rc2 = syscall_brk(n))) + if (0 > (rc2 = syscall_brk(n))) { return (void *)rc2; + } return rc; } |