diff options
author | Anton Kling <anton@kling.gg> | 2023-11-28 20:11:05 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-11-28 20:12:20 +0100 |
commit | d07fa25e04a19ccb9aa25bb6e2156d23d213db77 (patch) | |
tree | 25f2e4a6301f3ad7c5b158e74966a394862fdf39 /kernel/cpu | |
parent | 636858dbbd48ed9f5073793b46740302aa202f43 (diff) |
Meta: Apply new clang-format rules to kernel
Diffstat (limited to 'kernel/cpu')
-rw-r--r-- | kernel/cpu/gdt.h | 106 | ||||
-rw-r--r-- | kernel/cpu/idt.c | 11 | ||||
-rw-r--r-- | kernel/cpu/idt.h | 5 | ||||
-rw-r--r-- | kernel/cpu/syscall.c | 12 |
4 files changed, 69 insertions, 65 deletions
diff --git a/kernel/cpu/gdt.h b/kernel/cpu/gdt.h index 7cb2dc9..de8ea09 100644 --- a/kernel/cpu/gdt.h +++ b/kernel/cpu/gdt.h @@ -1,7 +1,7 @@ #ifndef GDT_H #define GDT_H -#include <typedefs.h> #include <string.h> +#include <typedefs.h> #define GDT_ENTRY_SIZE 0x8 #define GDT_NULL_SEGMENT 0x0 @@ -11,61 +11,59 @@ #define GDT_USERMODE_DATA_SEGMENT 0x4 #define GDT_TSS_SEGMENT 0x5 -struct GDT_Entry -{ - u16 limit_low; - u32 base_low : 24; - u32 accessed : 1; - u32 read_write : 1; // readable for code, writable for data - u32 conforming_expand_down : 1; // conforming for code, expand down for data - u32 code : 1; // 1 for code, 0 for data - u32 code_data_segment : 1; // should be 1 for everything but TSS and LDT - u32 DPL : 2; // privilege level - u32 present : 1; - u32 limit_high : 4; - u32 available : 1; // only used in software; has no effect on hardware - u32 long_mode : 1; - u32 big : 1; // 32-bit opcodes for code, u32 stack for data - u32 gran : 1; // 1 to use 4k page addressing, 0 for byte addressing - u8 base_high; -}__attribute__((packed)); +struct GDT_Entry { + u16 limit_low; + u32 base_low : 24; + u32 accessed : 1; + u32 read_write : 1; // readable for code, writable for data + u32 conforming_expand_down : 1; // conforming for code, expand down for data + u32 code : 1; // 1 for code, 0 for data + u32 code_data_segment : 1; // should be 1 for everything but TSS and LDT + u32 DPL : 2; // privilege level + u32 present : 1; + u32 limit_high : 4; + u32 available : 1; // only used in software; has no effect on hardware + u32 long_mode : 1; + u32 big : 1; // 32-bit opcodes for code, u32 stack for data + u32 gran : 1; // 1 to use 4k page addressing, 0 for byte addressing + u8 base_high; +} __attribute__((packed)); -typedef struct GDT_Pointer -{ - u16 size; - u32 offset; -}__attribute__((packed)) GDT_Pointer; +typedef struct GDT_Pointer { + u16 size; + u32 offset; +} __attribute__((packed)) GDT_Pointer; -struct tss_entry_struct -{ - u32 prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list. - u32 esp0; // The stack pointer to load when changing to kernel mode. - u32 ss0; // The stack segment to load when changing to kernel mode. - // Everything below here is unused. - u32 esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. - u32 ss1; - u32 esp2; - u32 ss2; - u32 cr3; - u32 eip; - u32 eflags; - u32 eax; - u32 ecx; - u32 edx; - u32 ebx; - u32 esp; - u32 ebp; - u32 esi; - u32 edi; - u32 es; - u32 cs; - u32 ss; - u32 ds; - u32 fs; - u32 gs; - u32 ldt; - u16 trap; - u16 iomap_base; +struct tss_entry_struct { + u32 prev_tss; // The previous TSS - with hardware task switching these form a + // kind of backward linked list. + u32 esp0; // The stack pointer to load when changing to kernel mode. + u32 ss0; // The stack segment to load when changing to kernel mode. + // Everything below here is unused. + u32 esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. + u32 ss1; + u32 esp2; + u32 ss2; + u32 cr3; + u32 eip; + u32 eflags; + u32 eax; + u32 ecx; + u32 edx; + u32 ebx; + u32 esp; + u32 ebp; + u32 esi; + u32 edi; + u32 es; + u32 cs; + u32 ss; + u32 ds; + u32 fs; + u32 gs; + u32 ldt; + u16 trap; + u16 iomap_base; } __attribute__((packed)); void gdt_init(); diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index 0a5cc77..46782b5 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -30,8 +30,8 @@ struct IDT_Pointer idtr; extern void load_idtr(void *idtr); -void format_descriptor(u32 offset, u16 code_segment, - u8 type_attribute, struct IDT_Descriptor *descriptor) { +void format_descriptor(u32 offset, u16 code_segment, u8 type_attribute, + struct IDT_Descriptor *descriptor) { descriptor->low_offset = offset & 0xFFFF; descriptor->high_offset = offset >> 16; descriptor->type_attribute = type_attribute; @@ -39,8 +39,7 @@ void format_descriptor(u32 offset, u16 code_segment, descriptor->zero = 0; } -void install_handler(void (*handler_function)(), u16 type_attribute, - u8 entry) { +void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry) { format_descriptor((u32)handler_function, KERNEL_CODE_SEGMENT_OFFSET, type_attribute, &IDT_Entry[entry]); } @@ -110,7 +109,9 @@ __attribute__((interrupt)) void page_fault(registers_t *regs) { ; } -static inline void io_wait(void) { outb(0x80, 0); } +static inline void io_wait(void) { + outb(0x80, 0); +} #define ICW1_ICW4 0x01 /* ICW4 (not) needed */ #define ICW1_SINGLE 0x02 /* Single (cascade) mode */ diff --git a/kernel/cpu/idt.h b/kernel/cpu/idt.h index c68ce81..9341887 100644 --- a/kernel/cpu/idt.h +++ b/kernel/cpu/idt.h @@ -5,8 +5,8 @@ typedef struct registers registers_t; #include <cpu/gdt.h> #include <cpu/io.h> #include <log.h> -#include <typedefs.h> #include <stdio.h> +#include <typedefs.h> /* * the type_attribute in the IDT_Entry struct @@ -65,6 +65,5 @@ struct registers { 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); +void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry); #endif diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index 5fd6828..3a2b1ca 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -80,9 +80,13 @@ void syscall_wait(int *status) { *status = get_current_task()->child_rc; } -int syscall_fork(void) { return fork(); } +int syscall_fork(void) { + return fork(); +} -int syscall_getpid(void) { return get_current_task()->pid; } +int syscall_getpid(void) { + return get_current_task()->pid; +} void *align_page(void *a); @@ -105,7 +109,9 @@ void *syscall_sbrk(uintptr_t increment) { return rc; } -int syscall_close(int fd) { return vfs_close(fd); } +int syscall_close(int fd) { + return vfs_close(fd); +} int syscall_openpty(SYS_OPENPTY_PARAMS *args) { assert(is_valid_userpointer(args, sizeof(SYS_OPENPTY_PARAMS))); |