summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-06-26arch: i386: kmalloc: fix last element being ignoredHEADmasterDanny Holman
Fix a bug in kmalloc in which the last element of the mem_block linked list would be ignored and potentially overwritten. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-25arch: i386: kmalloc: don't ignore the last blockDanny Holman
Fix a bug in which the kfree function would ignore the last mem_block struct. This allows the kernel to free a mem_block at the end of the linked list. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-25arch: i386: paging: reserve the last page tableDanny Holman
Reserve the last, usable page table for temporary mappings, such as those required by the physical memory manager. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-25kernel: interrupt: create a generic interrupt APIDanny Holman
Create a generic interface for drivers to make use of interrupt vectors. This API should be platform-agnostic enough to allow any driver to make use of virtually any interrupt vector on any CPU. On x86, the first 32 interrupts are set aside for CPU exceptions, and interrupt 128 is set aside for system calls. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-24kernel: panic: generate a stack frame on panicDanny Holman
Add a function that generates and prints a stack trace to the screen. This function relies on walk_stack() being implemented on the target architecture. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-24arch: i386: add a function that walks the stackDanny Holman
Add a function that will walk the stack and save the return addresses into an array. This will allow the kernel to print out stack traces during a panic or on demand inside a debugger. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-24arch: i386: boot: zero ESP before calling i386_entryDanny Holman
Set the ESP register to NULL before calling any C code. This allows a stack trace to occur without overrunning the initial bootstrap stack. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-22arch: i386: multiboot: refactor i386_entryDanny Holman
Refactor the i386_entry function such that it is in line with how the paging and memory systems operate. Further, the kernel command line must now be copied before calling the physical memory initialization routines due to an address conflict that cannot be resolved otherwise. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21libk: use a random value for the stack protectorDanny Holman
Don't hardcode the __stack_chk_guard value, generate a random value (using RDRAND on x86) before running any C code. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21arch: i386: gdt: flush_gdt no longer takes argumentsDanny Holman
The function flush_gdt() no longer accepts arguments. Update the function call to reflect this change. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21arch: i386: pmem: refactor the physical memory managerDanny Holman
Refactor the physical memory manager to be more efficient and require fewer function calls from layers above. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21arch: i386: paging: do the recursive paging trickDanny Holman
Map the page directory to the last page table. This allows the kernel to access every page table on the system from the address 0xFFC00000 plus an offset. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21arch: boot: allocate a few pages at startupDanny Holman
Allocate a few pages at startup just to get the paging and physical memory manager up and running. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-06-21Makefile: decrease test memory to 1GBDanny Holman
Decrease the amount of memory given to the testing VM to 1GB. This makes testing the memory systems a little faster during tight build cycles. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29arch: i386: asm: make flush_gdt availableDanny Holman
Make the declaration of flush_gdt available to files including asm.h. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29arch: i386: paging: make a temp map in init_page_tableDanny Holman
Make a temporary mapping for a alloc'd page in init_page_table. This ensures that the mapping is firmly inside the page table set aside for page accounting structures. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29kernel: sched: implement the round-robin schedulerDanny Holman
Implement a basic round-robin scheduler and tie it to the PIT timer interrupt on x86. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29arch: i386: paging: remove ref to non-existant headerDanny Holman
Remove a reference to a non-existant header file in an include statement. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29include: kernel: input: add in keyboard.hDanny Holman
Add in a missing header file that allows the AT keyboard driver to be used. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29arch: i386: remove last refs to moved headersDanny Holman
Remove all the remaining references to headers that were moved into the libk. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-29arch: i386: fix several bugs in paging subsystemDanny Holman
Fix several triple-faulting bugs in the paging initialization routines. These include causing a page fault during physical memory manager initialization, causing a page fault during paging initialization and other double-faulting and triple-faulting bugs. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27arch: i386: pmem: refactor the physical MMDanny Holman
Refactor the physical memory manager to be dramatically simpler. The new design uses only a single freelist, and only uses temporary mappings where needed. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27arch: i386: update all files to use the new libkDanny Holman
Update all the files under arch to make use of the new libk implementation. Most of these changes are simply path changes in include directives. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27arch: i386: add a spinlock implementationDanny Holman
Add two functions to control thread-local spinlocks. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27arch: i386: pass entry page directory to entry funcDanny Holman
Add a third argument to i386_entry. This argument is the bootstrap page directory. Pages can be temporarily mapped in during the initialization of the paging system. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27drivers: create a subdir just for driver codeDanny Holman
Create a subdirectory branching from the project root. This directory will contain nothing but driver and device code. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-05-27libk: create a subset libc for kernel useDanny Holman
Create a subset of the C library for use inside the kernel. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-03-28kernel: sched: add a flag that is set on initDanny Holman
Add a flag that is set to 1 when the scheduler_init function is called. This allows the PIT interrupt to preempt the current thread and schedule the next one according to the scheduler's internal agorithm. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-03-28kernel: add a basic thread schedulerDanny Holman
Add a basic thread scheduler. This should allow the kernel to schedule threads according to the round robin algorithm. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-03-28arch: i386: kernel: implement a kmalloc functionDanny Holman
Add a basic kmalloc implementation. This allows the kernel to allocate blocks smaller than a whole page. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-03-28arch: i386: kernel: add mostly finished PFA and paging systemDanny Holman
Add the mostly finished physical memory allocator and expose its functions to the paging system. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-24kernel: string: add a strcpy functionDanny Holman
Add an implmentation of strcpy. This function is used in several places in the kernel to copy strings between memory addresses. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-24arch: i386: cleanup everything and reorganizeDanny Holman
Clean up everything in the i386 arch directory. This code has been in dire need of refactoring for a long while. All the inline assembly functions and the data structures related to the architecture should be placed into their own header file. Now the scheduler can access registers and ISRs without having to deal with arch-specific code. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-24arch: i386: move jump_userspace to its own fileDanny Holman
Move the function that jumps to ring 3 to its own assembly file. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-21README: update copyright lineDanny Holman
Update the copyright year and contact email in the README file. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: add basic keyboard driverDanny Holman
Add a basic driver for the PS/2 keyboard. This driver just prints whatever it receives back out to the framebuffer. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16kernel: panic: add a variable that locks other CPUsDanny Holman
Add a static variable to the panic function that should lock all other CPUs. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: roll physical memory control into VMMDanny Holman
The VMM should control the physical memory as well as paging. This allows the VMM to grab frames as it sees fit. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: move GDT definitions to their own headerDanny Holman
Move all the data structures required for operation of the GDT to their own header file. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: multiboot: move arch-specific inits hereDanny Holman
Move all the architecture-specific initialization calls to this file. This frees up the main function to initialize other parts of the kernel. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: move IRQ functions to PIC driverDanny Holman
Move all the functions that control IRQ lines to the PIC driver. This allows the IDT controller to handle only raw interrupts no matter where they come from. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: move raw assembly calls to their own headerDanny Holman
Move simple assembly calls to their own header. All one or two line assembly calls should be defined in a single place. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16kernel: mem: kmalloc should not call page allocationDanny Holman
Strip the code calling for the memory manager to allocate pages to kmalloc. The function should just return a raw pointer while a page fault will allocate the required memory. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16kernel: add a panic functionDanny Holman
Add a panic function that stops the current CPU and prints an error message into the ring buffer. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: syscall.c: add functions that dump dataDanny Holman
Add functions to the syscall handlers that dump registers and stack in case of catastrophic failure. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: gdt.c: fix a bug in userspace jumpDanny Holman
Fix a bug in the GDT that prevented the kernel from jumping to userspace correctly. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: boot: ISR frame should not include ESPDanny Holman
The code that constructs an isr_frame struct should not push ESP to the stack. In addition, the kernel should set its own copy of ESP into a function defined elsewhere for scheduling purposes. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16Makefile: add flags to qemu that activate the serial portDanny Holman
Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16arch: i386: add operations to control PIT timerDanny Holman
Add a set of functions that control the programmable interrupt timer. This will be used as the primary means of preemption on this architecture. Signed-off-by: Danny Holman <dholman@gymli.org>
2024-02-16include: kernel: add the container_of.h fileDanny Holman
Add the container_of.h file that defines the container_of macro. This macro allows the kernel to get the parent struct of a pointer with an offset. Signed-off-by: Danny Holman <dholman@gymli.org>