Commit Graph

181 Commits

Author SHA1 Message Date
Drew Galbraith dcc05f2741 Add a libc skeleton with a primitive malloc. 2023-06-07 10:33:10 -07:00
Drew Galbraith eb04242a59 Add a debug mode for the KernelHeap. 2023-06-07 10:01:22 -07:00
Drew Galbraith 40b21d9c75 [Mammoth] Add Channel object for simple IPC messages 2023-06-07 09:37:16 -07:00
Drew Galbraith 65439c163a Compile sys libraries without exceptions. 2023-06-07 09:36:14 -07:00
Drew Galbraith 3243b6024b Update init bg script to inclue AR 2023-06-07 09:29:38 -07:00
Drew Galbraith a5c4d40575 Refactor error types and error reporting 2023-06-07 08:51:23 -07:00
Drew Galbraith 81b925eea0 Add a basic IPC setup with Channel Object.
Pass a process a channel endpoint on startup that it will use to
get it's initial capabilities.
2023-06-07 08:24:10 -07:00
Drew Galbraith b79ec07636 Return Z_OK on all syscall paths 2023-06-07 07:15:25 -07:00
Drew Galbraith 55340e2917 Make Capability RefCounted 2023-06-07 06:21:36 -07:00
Drew Galbraith 6c10c57bfa Mass rename memory object variables.
Use shorthand:
AddressSpace -> vmas
MemoryObject -> vmmo

The VM prefix makes these a little more distinguishable in code.
2023-06-07 00:30:26 -07:00
Drew Galbraith a8a4f8d9ab Add checks to mammoth thread lib 2023-06-07 00:25:04 -07:00
Drew Galbraith e246f28d9c Get the second process elf from a MemoryObject instead of hardcoding.
Allows us to delete the CopyIntoNonResidentProcess function and simply
rely on the MemoryObject copy functions.
2023-06-07 00:19:15 -07:00
Drew Galbraith eb454300e6 Move elf loader into the init loader in the kernel 2023-06-07 00:08:21 -07:00
Drew Galbraith 23895b5c6c Spawn Processes using memory primitives rather than and elf loader.
This allows us to remove the temporary syscall for that style of process
spawn.
2023-06-07 00:04:53 -07:00
Drew Galbraith b06c76e477 Create a MemoryObject class and use it to load programs. 2023-06-06 21:44:10 -07:00
Drew Galbraith 1fda0f3fae Move VirtualMemory to AddressSpace Object 2023-06-06 20:43:15 -07:00
Drew Galbraith b5ad454ad1 Move Process & Thread to the object folder. 2023-06-06 20:18:53 -07:00
Drew Galbraith 4e278a4664 Make a KernelObject base class for all Capabilities. 2023-06-06 20:13:07 -07:00
Drew Galbraith d358c1d672 Move process be to RefCounted 2023-06-06 19:12:46 -07:00
Drew Galbraith 2e1357255c Create a RefCounted type and use it for Thread.
This should prevent me from actually creating 2 shared ptrs of
a single kernel object with their separate ref counts.
2023-06-06 19:05:03 -07:00
Drew Galbraith d9b17d96d7 Cleanup Thread constructor 2023-06-06 18:40:32 -07:00
Drew Galbraith 41d25a7b46 Reformat includes 2023-06-06 17:12:08 -07:00
Drew Galbraith 174d4b10fb Move threading calls into a basic user space library. 2023-06-06 16:56:19 -07:00
Drew Galbraith b0c2a6732b Always create threads in CREATED state.
Simplify the process class to have threads marked as runnable
separately.
2023-06-06 16:27:25 -07:00
Drew Galbraith ef8eb5d993 Add a threading syscall API. 2023-06-06 16:24:03 -07:00
Drew Galbraith e2aad55a8a Only dump bootloader modules once. 2023-06-06 15:04:34 -07:00
Drew Galbraith a092a57483 Begin defining the process/thread api 2023-06-06 15:01:31 -07:00
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