Drew Galbraith
3110087498
[zion] Don't dump process states on sleep
2023-08-01 10:42:53 -07:00
Drew Galbraith
02e6b49d90
[glacier] Add a vector class
2023-06-26 15:46:03 -07:00
Drew Galbraith
64d355b20d
[glacier] Move LinkedList to glacier.
2023-06-26 15:01:55 -07:00
Drew Galbraith
7f2530bc15
[zion] Rename cmake zion_lib to zion_stub.
2023-06-26 11:57:19 -07:00
Drew Galbraith
36d82370c1
[zion] Add a thread wait syscall
2023-06-22 02:17:50 -07:00
Drew Galbraith
f0e8ce14a4
[victoria] Create and start VictoriaFalls process
2023-06-22 00:22:59 -07:00
Drew Galbraith
dc63084d61
[zion] Move synchronization to the message queue
2023-06-21 23:57:23 -07:00
Drew Galbraith
9dd457391c
[zion] Move IPC objects to share code
2023-06-21 23:47:45 -07:00
Drew Galbraith
58df2c0ed2
[zion] Move ipc syscalls to one file to prep refactor
2023-06-21 23:20:56 -07:00
Drew Galbraith
c064af5fa7
Endpoint syscalls implemented
2023-06-21 23:14:42 -07:00
Drew Galbraith
69501bfe01
[all] Add stub for new Endpoint kernel object
2023-06-21 21:43:27 -07:00
Drew Galbraith
0ec2fa3e76
[glacier] Move Pair to glacier.
2023-06-21 20:47:40 -07:00
Drew Galbraith
c2dfe17363
[zion] Use ErrorOr in PciConfiguration
2023-06-21 18:46:06 -07:00
Drew Galbraith
0b86a94f14
Migrate to error constants in glacier
2023-06-21 18:28:54 -07:00
Drew Galbraith
3ab9b4d818
[zion] Move Channel and Port blocked threads to IntrusiveList.
2023-06-21 16:34:30 -07:00
Drew Galbraith
a99096b0ff
[zion] Move the scheduler to the IntrusiveList for runnable threads
2023-06-21 16:28:42 -07:00
Drew Galbraith
e1af79b975
[zion/glacier] Move RefPtr to glacier.
2023-06-21 15:07:40 -07:00
Drew Galbraith
8bcb574677
[zion/glacier] Move RefCounted to glacier.
2023-06-21 14:52:40 -07:00
Drew Galbraith
56eae3d4e5
[zion/glacier] Move SharedPtr to glacier
2023-06-21 14:48:29 -07:00
Drew Galbraith
f3443cf4de
[zion] Link against glacier as a POC
2023-06-21 14:42:37 -07:00
Drew Galbraith
172bf51db7
[zion] Move capability validation to capability.h
2023-06-20 15:50:49 -07:00
Drew Galbraith
93cf8f2740
[zion] Cleanup syscall entrance.
2023-06-20 15:40:21 -07:00
Drew Galbraith
d60b2bdc61
[zion] Move channel to use the message queue.
2023-06-20 15:36:17 -07:00
Drew Galbraith
fe1641ac38
[zion] Create a message queue to be shared between the port and channel
2023-06-20 15:29:32 -07:00
Drew Galbraith
1edd5023ce
[zion] Move the final syscalls to the new format.
2023-06-20 15:03:33 -07:00
Drew Galbraith
bd431b94ce
[zion] Move port calls to new syscall process.
2023-06-20 14:55:54 -07:00
Drew Galbraith
77bb3acfb4
[zion] Move channel syscalls to new format.
2023-06-20 14:41:44 -07:00
Drew Galbraith
1a70ce4855
[zion] Move memory syscalls to the new format
2023-06-20 14:26:06 -07:00
Drew Galbraith
f755cd38fe
[zion] Move thread syscalls to the new format.
2023-06-20 14:10:28 -07:00
Drew Galbraith
c6dd0bbb0f
[zion] Migrate process syscalls to new format.
2023-06-20 14:01:43 -07:00
Drew Galbraith
76107b7db7
[zion] Handle syscall cases by macro as well.
2023-06-20 13:50:18 -07:00
Drew Galbraith
5fc7296b20
[zion] POC for defining syscalls using macros
2023-06-20 13:43:12 -07:00
Drew Galbraith
4fef54084f
[zion] Remove legacy capability method.
2023-06-19 23:48:06 -07:00
Drew Galbraith
164309eada
[zion] Add utility to zero out a page when allocating one.
2023-06-19 23:44:33 -07:00
Drew Galbraith
0b9e0adfbb
[zion] Remove legacy capability table method.
2023-06-19 23:32:49 -07:00
Drew Galbraith
1cebe547c0
[zion] Allow the sleep thread to be preempted.
...
We can't yield it when the next thread is unblocked for now because it
may still be holding a lock that the prempted thread is waiting on.
2023-06-19 21:47:37 -07:00
Drew Galbraith
27f540e9ae
Move ipc calls to take a void*
2023-06-19 18:39:46 -07:00
Drew Galbraith
685070d65e
Get rid of the type field on zmessage
2023-06-17 02:01:21 -07:00
Drew Galbraith
7bd6aa42b0
[zion] Declare z_cap_t and start replacing existing types
2023-06-17 01:53:19 -07:00
Drew Galbraith
5e99dbf7d1
Refactor all Zion decls into one header
2023-06-17 01:45:53 -07:00
Drew Galbraith
7dcbbd671e
[denali] Get all caps from the init port.
...
This allows us to remove the bootstrap capabilities for good woo hoo!
2023-06-17 01:30:47 -07:00
Drew Galbraith
6e86ce67f0
[zion] Fix capability permission issues
2023-06-17 01:24:07 -07:00
Drew Galbraith
424b032146
[zion] Remove old debug messages
2023-06-17 01:09:48 -07:00
Drew Galbraith
bbc31a0d2b
[zion] Return proper code from PortCreate
2023-06-17 01:05:51 -07:00
Drew Galbraith
857b7fae03
[zion] Add a port send syscall
2023-06-17 01:05:10 -07:00
Drew Galbraith
cc191cd6bb
[zion] Add a syscall to duplicate capabilities
2023-06-17 00:59:44 -07:00
Drew Galbraith
378ced6b6c
[zion] Add a port create syscall
2023-06-17 00:31:02 -07:00
Drew Galbraith
09ac87e6f5
[yellowstone] Recieve all caps via init port.
2023-06-17 00:17:43 -07:00
Drew Galbraith
2ea1f90690
[zion] Add a direct port write for the kernel
2023-06-17 00:07:58 -07:00
Drew Galbraith
0a909eae0e
Print exit codes in hex
2023-06-17 00:03:09 -07:00
Drew Galbraith
528723e490
[mammoth] Create a method for getting initial caps.
2023-06-16 23:51:49 -07:00
Drew Galbraith
35f24e7c77
Add a Port poll operation
2023-06-16 23:15:28 -07:00
Drew Galbraith
21b73b5b92
[zion] [yellowstone] Pass the denali VMMO by port as a POC.
...
Preparing to bootsrap via port write rather than hard coding capability
ids.
2023-06-16 15:58:50 -07:00
Drew Galbraith
75b1f2d21c
[zion] Store capability ids on the CapabilityTable.
...
This is preferable to storing it in the capability itself since the id
is really just an index for the containing process.
2023-06-16 15:27:09 -07:00
Drew Galbraith
b27672d5de
[zion] Update LinkedList iterator semantics.
2023-06-16 15:24:38 -07:00
Drew Galbraith
242a18ae3c
[zion] Finish cleaning up process capability interface.
...
Make all functions generic and specify existing/vs new cap.
2023-06-16 15:09:15 -07:00
Drew Galbraith
fc94bc5bf5
[zion] Update process interface to simplify capability insertion.
...
Take a templated KernelObject with explicit permissions.
2023-06-16 15:04:33 -07:00
Drew Galbraith
a47bac9966
[zion] Dynamically check Capability type.
...
Instead of passing an enum with the capability when creating it, relying
on polymorphism and a template struct tag to determine the object type
at runtime.
This is cleaner and avoids errors where we pass the wrong capability
type with the cap and do a bad cast at runtime.
2023-06-16 14:53:57 -07:00
Drew Galbraith
b4902a79ef
[zion] Add per-process CapabilityTable object
...
Store this information in it's own object to make the API clearer.
2023-06-16 14:25:54 -07:00
Drew Galbraith
be12fa9a19
Add mutex fixme
2023-06-16 14:25:23 -07:00
Drew Galbraith
4e328c2f7a
Set RSP0 on context switch
...
Previously we only set it on thread init which caused interrupts to
stomp on the stack of the most recently started thread, potentially
overwriting their cr3 and other variables and causing a crash.
2023-06-16 01:52:59 -07:00
Drew Galbraith
71e51730b7
Mark unblocked threads as runnable before enqueueing them
2023-06-16 01:29:00 -07:00
Drew Galbraith
ffa2d97a64
First iteration of denali server
2023-06-15 16:20:29 -07:00
Drew Galbraith
b8b6576b7f
Cleanup AHCI Ident a bit and reduce logging
2023-06-12 23:32:24 -07:00
Drew Galbraith
72885190e9
Resolved page faults from user stacks
2023-06-12 23:28:23 -07:00
Drew Galbraith
6986f534f8
Add a method for blocking threads on ports.
...
Additionally add the first lock class since we are becoming more
concurrent.
2023-06-12 20:56:25 -07:00
Drew Galbraith
b6735d3175
[zion] Fix an over-allocation bug when creating a memory object
2023-06-12 20:55:53 -07:00
Drew Galbraith
0f0e39d1e9
Further parse AHCI information.
...
Send an IDENTIFY command to each drive and set up a hook to handle
interrupts.
2023-06-12 19:20:51 -07:00
Drew Galbraith
4e1888bd24
Set eflags properly for jump to userspace
2023-06-12 19:20:42 -07:00
Drew Galbraith
8ac5366882
[zion] Add ability to dump MADT (APIC) tables
2023-06-12 19:17:00 -07:00
Drew Galbraith
c35cef65fe
Don't mistakenly mask interrupts in user space
2023-06-12 19:01:09 -07:00
Drew Galbraith
30bb10207e
Add the Denali disk driver.
...
Begin enumerating information from the PCI structure and HBA AHCI
structures.
Currently the PCI structure address is hardcoded but it should be
passed via a capability from the init process in the future.
2023-06-08 02:36:59 -07:00
Drew Galbraith
47e3d11060
Add a syscall for creating a physical memory VMO
2023-06-08 02:36:47 -07:00
Drew Galbraith
56789400d7
Allow mapping the PCI Config so Yellowstone can map it.
...
This is a temp system call. Evemtually we should probably supply the
root process with all of the system physical memory objects.
2023-06-07 22:45:42 -07:00
Drew Galbraith
bd32e85164
Fix race condition in page fault handler.
...
We enabled interrupts before getting the value of cr2 in the handler.
If the handler was preempted, cr2 could have been overriden by a page
fault in a separate thread or process.
2023-06-07 22:24:50 -07:00
Drew Galbraith
3e1e37bf03
Probe RSDP for PCIe Config
2023-06-07 16:24:13 -07:00
Drew Galbraith
4bd7f972c1
Add additional physical memory logging
2023-06-07 16:22:39 -07:00
Drew Galbraith
53ff49b265
Add preprocessor directives to supress logs per file.
...
Makes the output much cleaner by default but allows for getting more
infor if debugging in the future.
2023-06-07 13:51:13 -07:00
Drew Galbraith
add533071b
Use APIC for interrupts rather than PIC.
...
Still rely on the PIT for now rather than the local APIC timer.
2023-06-07 13:40:36 -07:00
Drew Galbraith
7c9d1075eb
Move sys/test to Yellowstone init process.
2023-06-07 11:18:35 -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
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
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
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
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
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
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
91b52f1872
Move IO Port Function to a separate file
2023-05-17 20:26:51 -07:00
Drew Galbraith
a164d9d67c
Boot directly into AcadiaOS
2023-05-17 20:26:20 -07:00
Drew Galbraith
e9705f7579
Barebones Kernel Commit
...
Uses limine to boot off of a disk.
Outputs a character to the debug port.
2023-05-17 20:20:53 -07:00