diff --git a/include/arch/x86.h b/include/arch/x86.h index 0e6ad58..d6900e3 100644 --- a/include/arch/x86.h +++ b/include/arch/x86.h @@ -36,7 +36,7 @@ struct idtr { // All general-purpose registers (except rsp) as stored on the stack, // plus the values we pushed (vector number, error code) and the iret frame // In reverse order because the stack grows downwards. -struct cpu_status_t { +struct cpu_status { uint64_t r15; uint64_t r14; uint64_t r13; @@ -63,6 +63,6 @@ struct cpu_status_t { uint64_t iret_ss; }; -struct cpu_status_t* syscall_handler(struct cpu_status_t* regs); +struct cpu_status* syscall_handler(struct cpu_status* regs); #endif \ No newline at end of file diff --git a/include/kernel.h b/include/kernel.h index 04836ca..d77ca98 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -35,7 +35,7 @@ extern volatile uint64_t ticks; // printf("debug: [%s]: " log "\n", __FILE__, ##__VA_ARGS__); -void panic(struct cpu_status_t* ctx, const char* str); +void panic(struct cpu_status* ctx, const char* str); void hcf(void); void idle(void); diff --git a/include/mem/kheap.h b/include/mem/kheap.h index 52a9fb7..08c7766 100644 --- a/include/mem/kheap.h +++ b/include/mem/kheap.h @@ -16,11 +16,11 @@ #include #include -struct heap_block_t { +struct heap_block { size_t size; bool free; // 1byte uint8_t reserved[7]; // (7+1 = 8 bytes) - struct heap_block_t* next; + struct heap_block* next; } __attribute__((aligned(16))); void kheap_init(void); diff --git a/include/mem/paging.h b/include/mem/paging.h index f5cf406..e7b38fe 100644 --- a/include/mem/paging.h +++ b/include/mem/paging.h @@ -34,7 +34,7 @@ extern uint64_t hhdm_off; #define PAGE_ALIGN_DOWN(x) ((x) & PTE_ADDR_MASK) #define ALIGN(size) ALIGN_UP(size, 16) -#define BLOCK_MIN_SIZE (sizeof(struct heap_block_t) + 16) +#define BLOCK_MIN_SIZE (sizeof(struct heap_block) + 16) #define PML4_INDEX(x) (((x) >> 39) & 0x1FF) #define PDPT_INDEX(x) (((x) >> 30) & 0x1FF) diff --git a/include/sched/process.h b/include/sched/process.h index 02a313a..22548f6 100644 --- a/include/sched/process.h +++ b/include/sched/process.h @@ -17,23 +17,23 @@ typedef enum { DEAD } status_t; -struct process_t { +struct process { size_t pid; char name[PROCESS_NAME_MAX]; status_t status; - struct cpu_status_t* context; + struct cpu_status* context; void* root_page_table; // Process PML4 (should contain kernel PML4 in higher half [256-511] - struct process_t* next; + struct process* next; }; void process_init(void); -struct process_t* process_create(char* name, void(*function)(void*), void* arg); -void process_add(struct process_t** processes_list, struct process_t* process); -void process_delete(struct process_t** processes_list, struct process_t* process); -struct process_t* process_get_next(struct process_t* process); +struct process* process_create(char* name, void(*function)(void*), void* arg); +void process_add(struct process** processes_list, struct process* process); +void process_delete(struct process** processes_list, struct process* process); +struct process* process_get_next(struct process* process); void process_exit(void); -void process_display_list(struct process_t* processes_list); +void process_display_list(struct process* processes_list); #endif diff --git a/include/sched/scheduler.h b/include/sched/scheduler.h index 071321e..89251e6 100644 --- a/include/sched/scheduler.h +++ b/include/sched/scheduler.h @@ -7,7 +7,7 @@ #ifndef SCHEDULER_H #define SCHEDULER_H -struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context); +struct cpu_status* scheduler_schedule(struct cpu_status* context); void scheduler_init(void); #endif \ No newline at end of file diff --git a/include/sched/spinlock.h b/include/sched/spinlock.h index fabf089..ea4d9dd 100644 --- a/include/sched/spinlock.h +++ b/include/sched/spinlock.h @@ -10,13 +10,13 @@ #include #include -struct spinlock_t +struct spinlock { bool locked; uint64_t rflags; }; -void spinlock_acquire(struct spinlock_t* lock); -void spinlock_release(struct spinlock_t* lock); +void spinlock_acquire(struct spinlock* lock); +void spinlock_release(struct spinlock* lock); #endif \ No newline at end of file diff --git a/src/arch/x86/idt.c b/src/arch/x86/idt.c index c4b17c2..75d5514 100644 --- a/src/arch/x86/idt.c +++ b/src/arch/x86/idt.c @@ -108,7 +108,7 @@ static inline uint64_t read_cr2(void) * Also displays an interpretation of the thrown error code. * Then halts the system. We could implement demand paging later. */ -static void page_fault_handler(struct cpu_status_t* ctx) +static void page_fault_handler(struct cpu_status* ctx) { // It could be used to remap pages etc. to fix the fault, but right now what I'm more // interested in is getting more info out of those numbers cause i'm lost each time i have @@ -149,7 +149,7 @@ static void page_fault_handler(struct cpu_status_t* ctx) * Shows detail about a General Protection Fault, * and what may have caused it. Halts the system. */ -static void gp_fault_handler(struct cpu_status_t* ctx) +static void gp_fault_handler(struct cpu_status* ctx) { DEBUG("\x1b[38;5;231mGeneral Protection Fault at rip=0x%p, err=%u (%s)\x1b[0m", ctx->iret_rip, @@ -185,7 +185,7 @@ static void gp_fault_handler(struct cpu_status_t* ctx) * Return: * - CPU context after interrupt */ -struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context) +struct cpu_status* interrupt_dispatch(struct cpu_status* context) { if (context == NULL) { panic(NULL, "Interrupt dispatch recieved NULL context!"); diff --git a/src/arch/x86/syscall.c b/src/arch/x86/syscall.c index 380c5fc..544c2a6 100644 --- a/src/arch/x86/syscall.c +++ b/src/arch/x86/syscall.c @@ -7,7 +7,7 @@ #include #include -struct cpu_status_t* syscall_handler(struct cpu_status_t* regs) +struct cpu_status* syscall_handler(struct cpu_status* regs) { DEBUG("Syscall %lx with argument %lx", regs->rdi, regs->rsi); diff --git a/src/debug/panic.c b/src/debug/panic.c index 22ff590..bbeb884 100644 --- a/src/debug/panic.c +++ b/src/debug/panic.c @@ -47,7 +47,7 @@ void read_rflags(uint64_t rflags) * Will display to terminal if it is initialized, otherwise serial only. * Can be called with or without a CPU context. */ -void panic(struct cpu_status_t* ctx, const char* str) +void panic(struct cpu_status* ctx, const char* str) { CLEAR_INTERRUPTS; panic_count += 1; diff --git a/src/io/serial/serial.c b/src/io/serial/serial.c index f36a450..655d479 100644 --- a/src/io/serial/serial.c +++ b/src/io/serial/serial.c @@ -11,7 +11,7 @@ extern struct init_status init; extern int panic_count; -struct spinlock_t serial_lock = {0}; +struct spinlock serial_lock = {0}; /* * outb - Writes a byte to a CPU port diff --git a/src/io/term/term.c b/src/io/term/term.c index e4f7546..e3bd2ca 100644 --- a/src/io/term/term.c +++ b/src/io/term/term.c @@ -29,8 +29,8 @@ because this shitty implementation will be replaced one day by Flanterm extern struct flanterm_context* ft_ctx; extern struct init_status init; -struct spinlock_t term_lock = {0}; -struct spinlock_t printf_lock = {0}; +struct spinlock term_lock = {0}; +struct spinlock printf_lock = {0}; extern int panic_count; diff --git a/src/kmain.c b/src/kmain.c index 813e761..470bc73 100644 --- a/src/kmain.c +++ b/src/kmain.c @@ -63,9 +63,9 @@ extern volatile struct limine_hhdm_request hhdm_request; extern volatile struct limine_kernel_address_request kerneladdr_request; extern volatile struct limine_boot_time_request date_request; -extern struct process_t* processes_list; -extern struct process_t* current_process; -struct process_t* idle_proc; +extern struct process* processes_list; +extern struct process* current_process; +struct process* idle_proc; void idle_main(void* arg) { diff --git a/src/mem/kheap.c b/src/mem/kheap.c index 2359c36..5c58e36 100644 --- a/src/mem/kheap.c +++ b/src/mem/kheap.c @@ -17,7 +17,7 @@ extern uint64_t kernel_virt_base; uintptr_t kheap_start; -static struct heap_block_t* head = NULL; +static struct heap_block* head = NULL; static uintptr_t end; // Kernel root table (level 4) @@ -55,8 +55,8 @@ void kheap_init() end = current_addr; // Give linked list head its properties - head = (struct heap_block_t*)kheap_start; - head->size = (end-kheap_start) - sizeof(struct heap_block_t); + head = (struct heap_block*)kheap_start; + head->size = (end-kheap_start) - sizeof(struct heap_block); head->free = true; head->next = NULL; DEBUG("Kernel heap initialized, head=0x%p, size=%u bytes", head, head->size); @@ -80,16 +80,16 @@ void* kmalloc(size_t size) if (!size) return NULL; size = ALIGN(size); - struct heap_block_t* curr = head; + struct heap_block* curr = head; while (curr) { // Is block free and big enough for us? if (curr->free && curr->size >= size) { // We split the block if it is big enough - if (curr->size >= size + sizeof(struct heap_block_t) + 16) { - struct heap_block_t* split = (struct heap_block_t*)((uintptr_t)curr + sizeof(struct heap_block_t) + size); + if (curr->size >= size + sizeof(struct heap_block) + 16) { + struct heap_block* split = (struct heap_block*)((uintptr_t)curr + sizeof(struct heap_block) + size); - split->size = curr->size - size - sizeof(struct heap_block_t); + split->size = curr->size - size - sizeof(struct heap_block); split->free = true; split->next = curr->next; @@ -99,7 +99,7 @@ void* kmalloc(size_t size) // Found a good block, we return it curr->free = false; - return (void*)((uintptr_t)curr + sizeof(struct heap_block_t)); + return (void*)((uintptr_t)curr + sizeof(struct heap_block)); } // Continue browsing the list if nothing good was found yet curr = curr->next; @@ -127,11 +127,11 @@ void kfree(void* ptr) if (!ptr) return; // Set it free! - struct heap_block_t* block = (struct heap_block_t*)((uintptr_t)ptr - sizeof(struct heap_block_t)); + struct heap_block* block = (struct heap_block*)((uintptr_t)ptr - sizeof(struct heap_block)); block->free = true; // merge adjacent free blocks (coalescing) - struct heap_block_t* curr = head; + struct heap_block* curr = head; while (curr && curr->next) { if (curr->free && curr->next->free) { curr->size += sizeof(*curr) + curr->next->size; @@ -169,7 +169,7 @@ void* kalloc_stack() void kheap_info() { uint64_t free_bytes = 0; - struct heap_block_t* curr = (struct heap_block_t*)kheap_start; + struct heap_block* curr = (struct heap_block*)kheap_start; while (curr) { if (curr->free == true) { diff --git a/src/sched/process.c b/src/sched/process.c index 9a20c42..81c7eb2 100644 --- a/src/sched/process.c +++ b/src/sched/process.c @@ -16,8 +16,8 @@ extern struct flanterm_context* ft_ctx; -struct process_t* processes_list; -struct process_t* current_process; +struct process* processes_list; +struct process* current_process; extern uint64_t *kernel_pml4; @@ -39,10 +39,10 @@ void process_init() * This function prints the linked list of processes * to the DEBUG output. */ -void process_display_list(struct process_t* processes_list) +void process_display_list(struct process* processes_list) { int process_view_id = 0; - struct process_t* tmp = processes_list; + struct process* tmp = processes_list; while (tmp != NULL) { DEBUG("{%d: %p} -> ", process_view_id, tmp); tmp = tmp->next; @@ -64,11 +64,11 @@ void process_display_list(struct process_t* processes_list) * Return: * - pointer to created process */ -struct process_t* process_create(char* name, void(*function)(void*), void* arg) +struct process* process_create(char* name, void(*function)(void*), void* arg) { CLEAR_INTERRUPTS; - struct process_t* proc = (struct process_t*)kmalloc(sizeof(struct process_t)); - struct cpu_status_t* ctx = (struct cpu_status_t*)kmalloc(sizeof(struct cpu_status_t)); + struct process* proc = (struct process*)kmalloc(sizeof(struct process)); + struct cpu_status* ctx = (struct cpu_status*)kmalloc(sizeof(struct cpu_status)); // No more memory? if (!proc) return NULL; @@ -108,7 +108,7 @@ struct process_t* process_create(char* name, void(*function)(void*), void* arg) * @processes_list: pointer to the head of the linked list * @process: process to add at the end of the linked list */ -void process_add(struct process_t** processes_list, struct process_t* process) +void process_add(struct process** processes_list, struct process* process) { if (!process) return; process->next = NULL; @@ -119,7 +119,7 @@ void process_add(struct process_t** processes_list, struct process_t* process) return; } - struct process_t* tmp = *processes_list; + struct process* tmp = *processes_list; while (tmp->next != NULL) { tmp = tmp->next; } @@ -132,7 +132,7 @@ void process_add(struct process_t** processes_list, struct process_t* process) * @processes_list: pointer to head of linked list * @process: the process to delete from the list */ -void process_delete(struct process_t** processes_list, struct process_t* process) +void process_delete(struct process** processes_list, struct process* process) { if (!processes_list || !*processes_list || !process) return; @@ -144,7 +144,7 @@ void process_delete(struct process_t** processes_list, struct process_t* process return; } - struct process_t* tmp = *processes_list; + struct process* tmp = *processes_list; while (tmp->next && tmp->next != process) { tmp = tmp->next; } @@ -167,7 +167,7 @@ void process_delete(struct process_t** processes_list, struct process_t* process * Return: * next> - process right after the one specified */ -struct process_t* process_get_next(struct process_t* process) +struct process* process_get_next(struct process* process) { if (!process) return NULL; return process->next; diff --git a/src/sched/scheduler.c b/src/sched/scheduler.c index 34acfdf..c320b70 100644 --- a/src/sched/scheduler.c +++ b/src/sched/scheduler.c @@ -10,9 +10,9 @@ #include #include -extern struct process_t* processes_list; -extern struct process_t* current_process; -extern struct process_t* idle_proc; +extern struct process* processes_list; +extern struct process* current_process; +extern struct process* idle_proc; /* * scheduler_init - Choose the first process @@ -32,7 +32,7 @@ void scheduler_init() * Return: * - CPU context for next process */ -struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context) +struct cpu_status* scheduler_schedule(struct cpu_status* context) { if (context == NULL) { panic(NULL, "Scheduler called with NULL context"); @@ -51,7 +51,7 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context) current_process->context = context; for (;;) { - struct process_t* prev_process = current_process; + struct process* prev_process = current_process; if (current_process->next != NULL) { current_process = current_process->next; } else { diff --git a/src/sched/spinlock.c b/src/sched/spinlock.c index efe4213..54d70ed 100644 --- a/src/sched/spinlock.c +++ b/src/sched/spinlock.c @@ -16,7 +16,7 @@ * Saves the RFLAGS register, then acquires a lock. * Pause instruction is used to ease the CPU. */ -void spinlock_acquire(struct spinlock_t* lock) +void spinlock_acquire(struct spinlock* lock) { uint64_t rflags; asm volatile("pushfq ; pop %0 ; cli" : "=rm"(rflags) : : "memory"); @@ -36,7 +36,7 @@ void spinlock_acquire(struct spinlock_t* lock) * unlocks it (clears locked state). * RFLAGS is then restored. */ -void spinlock_release(struct spinlock_t* lock) +void spinlock_release(struct spinlock* lock) { uint64_t rflags = lock->rflags; __atomic_clear(&lock->locked, __ATOMIC_RELEASE);