Commit Graph

54 Commits

Author SHA1 Message Date
Drew Galbraith e3661e7848 Add LICENSE and README 2023-05-31 00:03:44 -07:00
Drew Galbraith 69b5cd001f Add a skeleton framework for capabilities.
Use the first capability to spawn a child process.
2023-05-30 23:55:42 -07:00
Drew Galbraith 09b8136ef9 Fix formatting on panic 2023-05-30 23:52:50 -07:00
Drew Galbraith 69c73a9386 Add a qemu mode that dumps interrupt info. 2023-05-30 23:22:52 -07:00
Drew Galbraith 9e3df0ccd0 Add pid/tid to all log messages 2023-05-30 23:22:29 -07:00
Drew Galbraith 2eefda6114 add a class to allocate and manage user space stacks 2023-05-30 22:35:57 -07:00
Drew Galbraith 1db93e5b12 Move PML4 initialization into the VirtualMemory class. 2023-05-30 21:39:19 -07:00
Drew Galbraith f22dd66c8d Manage KernelStacks separately rather than just allocing bytes.
Create a global KernelStackManager that will handle the relevant allocs.
2023-05-30 21:28:44 -07:00
Drew Galbraith 3c3341a90f Add a process spawn syscall and use it to start a proc.
Also add a skeleton VirtualMemory manager to be used per process.
2023-05-30 20:55:03 -07:00
Drew Galbraith 5bcf1f4e4a Add a second process to be loaded by the bootloader. 2023-05-30 20:54:37 -07:00
Drew Galbraith b9b45c5e45 Add the ability to copy memory to non resident process.
Use/Test this by loading the user space elf from the kernel process
before it starts rather than as a part of the first thread.

This simplifies thread start a fair bit.
2023-05-30 01:27:47 -07:00
Drew Galbraith f6609983d2 Move away from using recursive mapping for page tables.
Having the HHDM-based mapping allows us to more easily map data into
non-resident processes.
2023-05-30 01:06:01 -07:00
Drew Galbraith c6921b5459 Add validity check in shared ptr 2023-05-30 01:05:50 -07:00
Drew Galbraith de49dcc01a Move scheduler to new global class format. 2023-05-29 23:48:32 -07:00
Drew Galbraith 7fe6c24aa5 Add a ProcessManager class to store Process objects.
Trying out a new method for exposing global objects directly via a
variable.
2023-05-29 23:35:44 -07:00
Drew Galbraith b58186265e Split Yield and Preempt into separate scheduling functions.
This switch makes the logic for each much easier to parse.
2023-05-29 23:09:39 -07:00
Drew Galbraith 3fee5ac9d7 Rework scheduler to store the current thread separately.
This works better with the sleep thread and lets us check state
transitions more easily.
2023-05-29 22:54:22 -07:00
Drew Galbraith 656687b183 Schedule on PIC timer raise.
This causes a page fault because we don't properly handle the sleep
case.
2023-05-29 22:32:50 -07:00
Drew Galbraith 496dfeaef9 Update the timer to a more reasonable time slice of 50ms 2023-05-29 22:17:56 -07:00
Drew Galbraith 9869d1022a Mask all interrupts on the master PIC except the timer.
This prevents us from getting a GP fault when an unhandled interrupt
arises.
2023-05-29 22:07:47 -07:00
Drew Galbraith a949055bce Flesh out the GP Fault hanlder slightly. 2023-05-29 22:01:06 -07:00
Drew Galbraith 629dca278b Enable the PIC and add a timer.
This causes a GP fault after the timer runs for some time.
2023-05-29 21:52:01 -07:00
Drew Galbraith 80d2bf1aaa Move Processes and Threads to be stored in SharedPtr
Reference counting lets us pass these around a bit more easily.

SharedPtr was lightly tested using uint64_t in the main zion funcion.

Also add a sleep functionality instead of panicking. Functionally the
same right now since we don't preempt.
2023-05-29 15:50:38 -07:00
Drew Galbraith 9f3ffbf5b4 Move Process to storing Threads in a linked list.
This should really be a vector or hashmap of some sort but this is fine
for now.
2023-05-29 15:08:02 -07:00
Drew Galbraith 5cab9f843e Move process list to a linked list.
Add basic iteration ability to the linked list.
2023-05-29 14:59:23 -07:00
Drew Galbraith 71196dc90f Move scheduler threads to a linked list implementation.
Removes the internal next ptr from the Thread class.

We avoid doing a memory operation when scheduling on yield because we
simply cycle the item to the back of the list.
2023-05-29 14:32:49 -07:00
Drew Galbraith a06c9dced4 Add thread and process states.
Add a thread exit call.
2023-05-29 13:51:03 -07:00
Drew Galbraith 8d87791fa2 Differentiate syscall handler by number.
This causes us to panic on the unhandled exit syscall.
2023-05-29 13:06:43 -07:00
Drew Galbraith 6f5b65de30 Map user pages in the proper mode.
This causes the user code to execute succesfully.
However now we don't differentiate between syscalls so we pass right
over the exit syscall and continue executing until we fault.
2023-05-29 13:06:08 -07:00
Drew Galbraith 7184f527a0 Jump to user mode.
This instantly creates a page fault as we always map pages with ring 0
permissions.
2023-05-29 13:06:08 -07:00
Drew Galbraith aefb4f082b Add a kernel ELF module and load it in a new process.
Don't yet jump to userspace.
2023-05-29 00:32:54 -07:00
Drew Galbraith f86bbe6ea9 Wireframe for syscalls in place 2023-05-18 16:03:09 -07:00
Drew Galbraith d3024211a7 Cycle through multiple tasks in multiple processes 2023-05-18 13:56:54 -07:00
Drew Galbraith 7a3b4d2d42 Add true page fault handler. 2023-05-18 13:56:09 -07:00
Drew Galbraith 0d275c72a1 Have processes enqueue their own threads 2023-05-18 13:28:22 -07:00
Drew Galbraith cb41953354 Scheduler with working threads.
Currently only one process but it is a start.
2023-05-18 13:24:02 -07:00
Drew Galbraith 960cbf9519 Add Scheduler wireframe.
Right now does nothing but has containing classes for process and thread
information.
2023-05-18 12:43:53 -07:00
Drew Galbraith de2c96b848 Internal many paging_util functions. 2023-05-18 11:40:13 -07:00
Drew Galbraith fa2bb4df89 Added a PhysicalMemoryManager class.
Stores a linkedlist of free blocks of PhysicalMemory.
2023-05-18 11:34:45 -07:00
Drew Galbraith 4380590af2 Add new and delete operator implementations to the kernel heap.
For now delete does nothing.
2023-05-18 11:29:44 -07:00
Drew Galbraith 2d719d0443 Add a bootstrap physical memory manager.
This will allow the real physical memory manager to use allocations.
2023-05-18 11:00:05 -07:00
Drew Galbraith 747c2a4e17 Add a page fault handler 2023-05-18 10:59:45 -07:00
Drew Galbraith 0b7e667368 Add a basic kernel heap object.
Currently allocation always fails because we don't
have a way to allocate a physical page.
2023-05-18 10:59:39 -07:00
Drew Galbraith 45b5817a36 Recursively map the PML4 2023-05-18 02:00:01 -07:00
Drew Galbraith b3f8cb9003 Dump the memory map from limine.
Also adds the ability to print formatted messages.
2023-05-18 01:16:53 -07:00
Drew Galbraith 9fc1aa15ef Add an interrupt descriptor table.
Set up a very basic handler for divide by zero and
general protection faults.
2023-05-17 22:54:37 -07:00
Drew Galbraith 3e1a1f7485 Add a qemu debug option and gdb init file. 2023-05-17 22:53:32 -07:00
Drew Galbraith 03fe4d8c2e Load our own GDT.
Replace the GDT from limine with our own.
2023-05-17 21:41:08 -07:00
Drew Galbraith 872e6f3392 Add a debug output utility. 2023-05-17 20:42:59 -07:00
Drew Galbraith c2af2eee97 Add compile_commands.json to .gitignore 2023-05-17 20:42:21 -07:00