Commit graph

57 commits

Author SHA1 Message Date
Sean Cross
23e759ffd8 kernel: fix multi-page lending
Due to several errors, multi-page lending did not work properly.

To begin with, if a page was not allocated then it would not be able to
be sent. That is, if you allocated 8192 bytes but only ever accessed the
first 4096 bytes, then an error would be encountered when lending the
unaccessed upper page.

Furthermore, due to a striding error in accessing pointers, half-pages
were treated as full pages.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-05 10:58:12 +08:00
bunnie
aed2325f68 fix some minor bugs in hosted mode
memory is not page-aligned so `if !cfg()`-out the alignment
checks in hosted mode
2021-04-09 17:31:36 +08:00
Sean Cross
4830f3eb2c kernel: server: implement DestroyServer(sid)
This implements a syscall to shut down a server. Servers may not be shut
down if they have outstanding messages that they have seen but not
responded to.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-05 18:18:48 +08:00
Sean Cross
cc0c395e1e kernel: server: rework queue with generation counter
This reworks the server queue to add a "generation counter". This
counter ensures messages are removed from the queue in the order they
were added, even if they are jumbled up within the queue itself.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 22:10:11 +08:00
Sean Cross
9ab5b4880f kernel: server: allow taking multiple messages from queue
Previously, we would only look at the top item on the server queue. If
it was not a known message, we would return an error.

This patch changes this behavior to look through the entire queue for
something we can take, and then clean it up as we go along.

This allow for having outstanding requests in the queue an forms the
backbone of the sleep server.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:45:32 +08:00
Lina Ceballos
d18500f4d6 adding license and copyright headers 2021-01-25 14:54:00 +01:00
Sean Cross
7b50d00eb8 repo: run cargo fmt
This reformats line endings to be consistent, and reinforces the
contents of `.gitattributes`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-03 18:31:51 +08:00
Sean Cross
ddd57c30bd kernel: fix compile error when debug-print enabled
This tracks a variable that has been renamed, and was preventing the
kernel from compiling when debug printing is enabled.

This fixes #19.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-14 17:02:58 +08:00
Sean Cross
b094f1147b xous: implement sender.pid()
This is mostly an implementation detail, but appears to work.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 22:38:35 +08:00
Sean Cross
1fa83d1d94 xous: make MessageSender a struct
This is now an object instead of an alias for `usize`, in preparation
for adding a `.pid()` function.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 22:16:24 +08:00
Sean Cross
25e4d16de3 xous-os: rename CreateServer to CreateServerWithAddress
Servers will, by default, get randomly-assigned SIDs. Certain servers
will want to have well-known SIDs, such as the log server or the
nameserver. These will use a separate call in order to perform this
priveledged operation.

A subsequent patch will add `CreateServer`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 20:33:33 +08:00
Sean Cross
f2e2505d4b kernel: server: remove bounds checks from take_waiting_message
This function has been rewritten to no longer have a bounds check.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 13:27:30 +08:00
Sean Cross
e4f7c7286d kernel: fix commented code in server
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 13:20:34 +08:00
Sean Cross
e7744b25ec kernel: services: format document
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 11:54:23 +08:00
Sean Cross
65c8c6eef5 kernel: implement and use klog!() macro
This replaces the majority of println!() and print!() calls, and works
on baremetal and hosted modes.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:24:28 +08:00
Sean Cross
4b83edc43b kernel: server: replace ctx with tid
Threads haven't been called contexts for a very long time.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:04:35 +08:00
Sean Cross
95ab9d3c02 kernel: server: unify print messages
Don't use `println!()`, and instead prefer to use `print!()` when in the
kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:17:27 +08:00
Sean Cross
20a65b88f2 kernel: server: don't Forget Borrow and MutableBorrow messages
These should be returned to the client process after the message is
done, not forgotten straightaway.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:16:52 +08:00
Sean Cross
fa9a3e0954 kernel: rework hosted network protocol
This fixes issues regarding passing memory between processes.

We now properly catch `ReturnMemory` and give the memory back.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-29 19:46:17 +08:00
Sean Cross
e5583a7646 kernel: fix message sender parameter
The `sender` was, previously, somewhat mislabeled. It was a combination
of PID and TID, except when it wasn't.

Instead, make this value a combination of ConnectionID and queue index.
This makes it easier to reason about which connection we're responding
to.

Additionally, don't expose teh global Server Index Table to userspace
programs.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-09-23 10:52:22 +08:00
Sean Cross
43002b8627 kernel: add blocking scalars
Add a new type: BlockingScalar, that can be used to do blocking scalar
calls such as sleep().

Signed-off-by: Sean Cross <sean@xobs.io>
2020-09-22 22:05:18 +08:00
Sean Cross
8f70c0640c kernel: fix server indexing
Server IDs were being improperly indexed, resulting in a
probably-invalid server index being returned.

Adjust these so that correct server indices are returned.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-29 22:10:24 +08:00
Sean Cross
bb17038bfe kernel: rename "xous" to "xous-kernel" in import
Cargo appears to cache packages in the workspace when multiple packages
use the same crate. Unfortunately, Xous uses different features
depending on whether it's running in the kernel or in userspace.

Pull the kernel version of "xous" in under a different namespace in
order to force it to use a different build.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-17 18:37:40 +08:00
Sean Cross
ba30b4919d kernel: remove more warnings
Still haven't run it on real hardware, but this removes more warnings
from the system.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 21:52:28 +08:00
Sean Cross
9bba5cbe4d server: pass memory buffer to server init
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 19:02:05 +08:00
Sean Cross
814be7cd84 kernel: down to 29 errors on bare metal
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 16:48:58 +08:00
Sean Cross
ea3a473c9f reworking memory allocation
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>
2020-08-03 17:40:57 +08:00
Sean Cross
ef0ef924c8 fix more clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-29 22:48:48 +08:00
Sean Cross
b9d211af3b xous: begin adding a create_process() call
This will mimic the `create_thread()` call and will obviate our own
process-creation code.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-26 10:54:54 +08:00
Sean Cross
4130ce7bd1 kernel: fix threading and multiplexing issues
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>
2020-07-21 15:51:51 +08:00
Sean Cross
e1bf9965c3 kernel: more renaming context -> thread
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-21 10:01:57 +08:00
Sean Cross
1a6b1160a3 syscall: move send_message into its own function
This breaks up the giant `handle()` function.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-21 09:44:16 +08:00
Sean Cross
e2296fceac ThreadID: rename from CtxID
Contexts are now renamed to Threads, which better reflects what they
actually are.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-16 11:04:31 +08:00
Sean Cross
bf15ac08f4 kernel: tests: add memory measurement to test suite
This adds a feature to enable memory measurement, so we can determine if
we're leaking memory anywhere.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-15 17:08:05 +08:00
Sean Cross
e652150c6e kernel: get multiple message passing working
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-15 16:09:42 +08:00
Sean Cross
d7006e675e kernel: get send_borrow_message test working
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 12:11:57 +08:00
Sean Cross
964b6e0f46 kernel: disable more debug prints
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 10:08:49 +08:00
Sean Cross
8f74159674 rename ImmutableBorrow -> Borrow
THis is more in-line with Rust conventions.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 19:19:25 +08:00
Sean Cross
e1a92e929c kernel: replace more unimplemented!() with UnhandledSyscall
This should prevent pacnics when calling unhandled functions.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-04 11:58:18 +08:00
Sean Cross
9f1b1e7ec8 kernel: tests: get both tests working
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>
2020-06-25 17:41:17 +08:00
Sean Cross
54a0db50b3 kernel: start using tls
This allows us to run multiple kernels in parallel.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-24 17:51:31 +08:00
Sean Cross
14bb1ac1e5 kernel: working on getting process termination functioning
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-22 17:42:24 +08:00
Sean Cross
2786ad697b kernel: get scalar message passing working again
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>
2020-06-16 16:34:49 +08:00
Sean Cross
723529ba20 wip: working on getting message passing working
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>
2020-06-15 18:13:10 +08:00
Sean Cross
21c46de60e kernel: move to allow hosted init
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>
2020-06-03 18:28:22 +08:00
Sean Cross
17ae34a1c1 kernel: begin actor refactor
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>
2020-06-03 15:34:55 +08:00
Sean Cross
1f478925ce kernel: return context on failure
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-06 10:43:26 +08:00
Sean Cross
9c5cb3da32 kernel: properly share pages between processes
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>
2020-04-03 12:28:44 +08:00
Sean Cross
bedb499edb kernel: get immutable borrows working
We can now pass memory immutably between processes

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-01 17:27:59 +08:00
Sean Cross
bdb8eac9ad MemoryRange: move to using this struct for memory ranges
This is a combination of MemoryAddress and MemorySize.  This is
guaranteed to be not null.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-01 10:28:36 +08:00