summaryrefslogtreecommitdiff
path: root/kernel (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kernel: interrupt: create a generic interrupt APIDanny Holman2024-06-251-0/+20
| | | | | | | | | | 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>
* kernel: panic: generate a stack frame on panicDanny Holman2024-06-241-1/+15
| | | | | | | | 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>
* kernel: sched: implement the round-robin schedulerv0.06Danny Holman2024-05-291-52/+56
| | | | | | | Implement a basic round-robin scheduler and tie it to the PIT timer interrupt on x86. Signed-off-by: Danny Holman <dholman@gymli.org>
* arch: i386: pmem: refactor the physical MMDanny Holman2024-05-271-18/+1
| | | | | | | | 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>
* libk: create a subset libc for kernel useDanny Holman2024-05-273-227/+17
| | | | | | Create a subset of the C library for use inside the kernel. Signed-off-by: Danny Holman <dholman@gymli.org>
* kernel: sched: add a flag that is set on initDanny Holman2024-03-281-0/+6
| | | | | | | | 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>
* kernel: add a basic thread schedulerDanny Holman2024-03-281-0/+64
| | | | | | | 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>
* arch: i386: kernel: implement a kmalloc functionDanny Holman2024-03-281-1/+5
| | | | | | | 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>
* arch: i386: kernel: add mostly finished PFA and paging systemDanny Holman2024-03-282-16/+3
| | | | | | | Add the mostly finished physical memory allocator and expose its functions to the paging system. Signed-off-by: Danny Holman <dholman@gymli.org>
* kernel: string: add a strcpy functionDanny Holman2024-02-242-4/+29
| | | | | | | 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>
* arch: i386: cleanup everything and reorganizeDanny Holman2024-02-241-2/+20
| | | | | | | | | | 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>
* kernel: panic: add a variable that locks other CPUsDanny Holman2024-02-161-0/+3
| | | | | | | Add a static variable to the panic function that should lock all other CPUs. Signed-off-by: Danny Holman <dholman@gymli.org>
* kernel: mem: kmalloc should not call page allocationDanny Holman2024-02-161-13/+5
| | | | | | | | 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>
* kernel: add a panic functionDanny Holman2024-02-161-0/+8
| | | | | | | 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>
* kernel: string: add more functions to string libraryDanny Holman2024-02-161-0/+64
| | | | | | Add more functions to the string library to process buffers and strings. Signed-off-by: Danny Holman <dholman@gymli.org>
* kernel: make kprintf print to a ring bufferDanny Holman2024-02-161-11/+23
| | | | | | | | The function kprintf should print to an internal ringbuffer instead of directly to the framebuffer. This reduces dependence on the existence of a framebuffer in the first place. Signed-off-by: Danny Holman <dholman@gymli.org>
* kernel: mem: add a simple kmalloc implementationDanny Holman2023-11-261-0/+23
| | | | | | | Add a simple implementation of kmalloc. This system only works on x86-based processors at the time of commit. Signed-off-by: Danny Holman <dholman@gymli.org>
* i386: create idt.c and isr.sDanny Holman2021-08-301-1/+1
| | | | | | Create files that add IDT support for i386. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* arch: i386: add GDT setup routinesDanny Holman2021-07-241-1/+1
| | | | | | Add a set of routines that setup the x86's global descriptor table. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* io: prefix a 'k' to print functionsDanny Holman2021-07-202-6/+4
| | | | Add a 'k' prefix to the kernel versions of the printf family.
* serial: add serial_writestring as a functionDanny Holman2021-01-201-0/+1
| | | | | | | Add a function in the serial interface that writes an entire string to the serial line. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: iterate over string with indexDanny Holman2021-01-201-6/+6
| | | | | | | | Iterate over a formatted string with an index and strlen instead of using a non-const pointer. The latter method may result in unsafe memory conditions. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: maintain const on stringsDanny Holman2021-01-201-2/+2
| | | | | | Keep const pointers const when casting from void to char. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* serial: don't declare serial_init as staticDanny Holman2021-01-201-0/+1
| | | | | | | | The function serial_init should not be declared as static. This function could change under a different architecture and should be defined with the target architecture. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* i386: add serial port supportDanny Holman2021-01-201-1/+2
| | | | | | Add support for serial communication in the i386 architecture. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: finish implementing string functionsDanny Holman2021-01-181-4/+38
| | | | | | Finish implementing the functions from string.h in string.c. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: implement a basic printf functionDanny Holman2021-01-171-0/+72
| | | | | | Implement a basic printf function using primitives from the TTY library. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: add main initialization functionsDanny Holman2021-01-171-0/+7
| | | | | | Add the main initialiazation functions within the main kernel directory. Signed-off-by: Danny Holman <dholman@gymli.xyz>
* kernel: add string.h implementationsDanny Holman2021-01-171-0/+24
Add implementations for functions declared in string.h. Signed-off-by: Danny Holman <dholman@gymli.xyz>