The kernel should run in a `no_std` environment, which means it must
currently run without `alloc`. We have our own allocation methods when
running on baremetal hardware.
Begin the work to break out the allocation method so that it will work
on both desktop and baremetal environments.
Signed-off-by: Sean Cross <sean@xobs.io>
The kernel and userspace both need to use `xous`, but have different
requirements. If we use a workspace, then all instances of `xous-rs`
must have the same feature set.
This breaks them apart so the kernel can have one set of features and
programs can have another set.
As part of this change, tests are now integrated into the kernel, and a
new `create_process_as_thread()` and `wait_process_as_thread()` function
pair have been added.
Signed-off-by: Sean Cross <sean@xobs.io>
This package serves only to build tests for the kernel, because the
kernel wants to use a different mechanism for spawning processes.
Cargo doesn't support having `#[cfg(test)]` attributes on modules in
order to allow conditional compilation depending on whether we're
running a test or not. To work around this, `main.rs` is included in
another dummy crate.
Signed-off-by: Sean Cross <sean@xobs.io>
Due to an ordering issue, it was possible for thread message responses
to become deadlocked, wherein a message would get stored in the shared
table in between checking the table value and locking the network
connection.
This change makes a second check of the table after the network
connection is locked, in order to prevent this condition.
Signed-off-by: Sean Cross <sean@xobs.io>
This now uses a system of access keys to associate processes with the
kernel.
This currently does not pass tests.
Signed-off-by: Sean Cross <sean@xobs.io>
Connections weren't getting multiplexed correctly. As a result, they
would respond with the wrong message to a given thread.
Signed-off-by: Sean Cross <sean@xobs.io>
For Scalar and Move messages, the client does not need to block if the
server does not have any waiting messages. In this case, send an `Ok`
response.
Signed-off-by: Sean Cross <sean@xobs.io>
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>