Commit graph

68 commits

Author SHA1 Message Date
bunnie
7af009be78 migrations for moving constants out of xous-rs/kernel and into board/platform
this is a fairly major re-org of where key constants go that
define platform features. things that were in xous-rs that were
platform specific (namely precursor) were moved into a boards file,
and things that are generic to the system (like PAGE_SIZE) are moved
to a public location in xous-rs::arch.
2025-05-11 12:50:02 +08:00
bunnie
f9fc3d0d4b ok, format the kernel now that all in-line assembly has been checked 2024-01-14 19:27:14 +08:00
bunnie
710c45969f Revert "format the kernel"
This reverts commit 1f69e6aa39.

this has in-line assembly, let's fix that before we format
2024-01-14 19:24:33 +08:00
bunnie
1f69e6aa39 format the kernel 2024-01-14 19:11:19 +08:00
Sean Cross
d798962151 kernel: format some files
Format some files prior to patching them.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:28:52 +08:00
Sean Cross
ab0c7d3b32 kernel: server: check buf is some when returning mem
Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:03:39 +08:00
Sean Cross
a2e57195ba kernel: implement CreateProcess for riscv
Implement a functioning CreateProcess syscall on riscv. This call
creates a server in the child process, and connects the server to the
parent. The parent can communicate with the child process using this
server.

The Server ID is passed as four `u32` values to the entrypoint function.
This can be reassembled into something that can then be passed to the
`ReceiveMessage` syscall.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 18:47:37 +08:00
Sean Cross
76953985fe kernel: fix clippy warnings in mem/server
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:03:12 +08:00
Sean Cross
a99839ecd6 xous: mark MemoryRange fields as private
Mark the private fields in a `MemoryRange` struct as being private. This
allows us to perform operations on the memory range armed with the
knowledge that the entire range is valid and unaliased.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:41:16 +08:00
Sean Cross
977a175bb5 xous: mark MemoryRange::new() as unsafe
This function allows for creating arbitrary memory ranges. Mark this
function as `unsafe` in order to warn users that this can be used to
create invalid memory regions.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:02:02 +08:00
Sean Cross
30b82b25b1 kernel: run cargo fmt
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:12:01 +08:00
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