Previously, we were recycling PIDs when devices disconnected, however we
weren't cleaning up PIDs within the system-level table.
This now cleans up these entries.
Signed-off-by: Sean Cross <sean@xobs.io>
We now have two tests. These tests may be run either in parallel or in series.
If they are run in parallel, then they will each have their own thread
local storage, and each will initialize things from scratch.
If they are run in series, then the thread local storage will be reused
between the two processes.
Signed-off-by: Sean Cross <sean@xobs.io>
This gets basic scalar message passing working again. With this, the
following operations may be performed:
* Starting a server
* Connecting to a server
* Sending a scalar message
Care must be taken to not overflow a server's queue, particularly if
writers are faster than readers.
Signed-off-by: Sean Cross <sean@xobs.io>
The goal is to get a basic message passing engine working that will also
function as a device that works on real hardware.
This is still reworking it to function correctly on a desktop system.
Once that is working, it will be reworked to function once again on
hardware.
Signed-off-by: Sean Cross <sean@xobs.io>
This prepares for new calls to init SystemServices and the MemoryManager
so that they can be initialized with something other than a
KernelArguments struct.
Signed-off-by: Sean Cross <sean@xobs.io>
This refactors the kernel so that it *can* run on baremetal, but it can
also run as part of a full system.
This will aid in developing, and ensure that a minimum amount of unsafe
code is present within the kernel.
Signed-off-by: Sean Cross <sean@xobs.io>
This improves page sharing. Permissions are retained during sharing,
and we should now be able to share multiple pages. Additionally, this
lays the groundwork for mutable sharing.
Signed-off-by: Sean Cross <sean@xobs.io>
This lays groundwork to support lending pages from one process to
another, and to restore permissions when pages are handed back.
Signed-off-by: Sean Cross <sean@xobs.io>
After an IRQ occurs, check to see if there are any available threads.
If there are none, put the process back to sleep.
Signed-off-by: Sean Cross <sean@xobs.io>
We were resuming the wrong context after returning from an interrupt.
This resulted in us resuming context 3 more often than not.
This now properly banks the current process context prior to the switch.
Signed-off-by: Sean Cross <sean@xobs.io>
Due to an initial misunderstanding of how the RISC-V is architected,
contexts were going to be an emergent property of the kernel.
However, after further consideration, contexts must now be baked into
the kernel. Switching between contexts can be handled by the scheduler,
but the kernel must keep track of processor registers.
Keep track of context IDs and ensure they are sane. With this patch,
interrupts work, as does basic context switching.
Signed-off-by: Sean Cross <sean@xobs.io>
We were loading both the context and the banked context, which resulted
in an invalid context being selected. This caused a cascading failure.
Load only the lower halfword in order to correctly enter the interrupt
context.
Signed-off-by: Sean Cross <sean@xobs.io>
With this, we now have enough space to store the return context
information for when `message_reply()` is called.
Signed-off-by: Sean Cross <sean@xobs.io>
This [broken] commit starts to add message polling to the kernel, so a
server can use the MessageReceive call.
Signed-off-by: Sean Cross <sean@xobs.io>
Until now, we were relying on luck to ensure pages were zeroed.
However, now we properly zero pages in the kernel before handing them
off to userspace.
Signed-off-by: Sean Cross <sean@xobs.io>
We now have a concept of context banking. When an interrupt fires, the
process context is banked.
As part of this, process-level data is now stored in the page within the
process itself. This reduces memory consumption and allows us to have
features such as a hash within each process itself.
Signed-off-by: Sean Cross <sean@xobs.io>
Currently we use the ASID inside the MMU to figure out the current PID.
We should also keep track of what we think it is, for consistency.
Signed-off-by: Sean Cross <sean@xobs.io>