Commit graph

67 commits

Author SHA1 Message Date
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
2e69ae8a12 spawn: compiles, but does not work yet
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-28 05:10:48 +08:00
Sean Cross
5fddf7c230 kernel: implement UpdateMemoryFlags syscall
This call is used to strip flags from a chunk of memory.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-02-07 13:36:48 +08:00
bunnie
013606a4b2 this time, with saving the merge file (some weirdness in vscode...) 2021-10-04 17:34:24 +08:00
bunnie
44615c9acf Merge branch 'main' of github.com:betrusted-io/xous-core into main 2021-10-04 17:28:35 +08:00
Sean Cross
1ef4c0d87d kernel: mem: actually free unmapped pages
Previously we would only free a page if it was valid. Now we
unconditionally free it.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:40:39 +08:00
Sean Cross
956d5f0866 kernel: remove debugging prints for memory allocation
Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:38:15 +08:00
Sean Cross
fa31e2235c kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:42:48 +08:00
Sean Cross
62216b7295 kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:39:10 +08:00
Sean Cross
e44eec2334 kernel: fix remaining warnings on hosted mode
This removes all remaining warnings from hosted mode. Tests pass, and
the system continues to run normally.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:07:25 +08:00
Sean Cross
6985fda7ba kernel: get exceptions fully working
This finishes work with exceptions such that they now actually work.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:47:44 +08:00
Sean Cross
9bba083e2e kernel: remove debug print from mem.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 13:05:23 +08:00
Sean Cross
c7ff0ceb21 kernel: mem: fix remaining clippy lints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:32:52 +08:00
Sean Cross
d27a2eb27e kernel: mem: use iter instead of array access
This compresses the entirety of the memory range finder into a single
statement. As a result, duplicate code is removed and we can elide more
range checks.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:30:29 +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
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
86dd38f7fa kernel: fix hosted build
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 14:24:16 +08:00
Sean Cross
e616a4bf4f kernel: fix hosted build/warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:52:03 +08:00
Sean Cross
09b8242bb2 kernel: get process termination "working" on risc-v
This successfully allows a process to call `terminate_process(val)`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:42:31 +08:00
Sean Cross
5bca939c37 kernel: mem: fix build on hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:42:53 +08:00
Sean Cross
1818256f5e kernel: mem: add ram_used_by() function
This can be used to determine the amount of ram used by a particular
process ID.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +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
af5598d2dc kernel: move memory owner when a Move occurs
When moving memory between processes, update the owner of that page to
match the new PID. Otherwise, memory can never be released.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-26 17:14:26 +08:00
Sean Cross
8c599a3080 kernel: mem: remove unused debugging prints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:19:45 +08:00
Lina Ceballos
d18500f4d6 adding license and copyright headers 2021-01-25 14:54:00 +01: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
96c5739cdd kernel: fix remaining warnings
This fixes all remaining warnings in the kernel. For now.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-30 01:17:35 +08:00
Sean Cross
0ca7fe6f12 kernel/loader: fix build arguments
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-18 12:10:46 +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
cb959eb1cf kernel: fix interrupts
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-10 22:43:38 +08:00
Sean Cross
10ecacd136 kernel: native: create process for initial processes
These all need to bootstrap themselves.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 23:08:54 +08:00
Sean Cross
bef0168c20 kernel: more warning fixes
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 22:14:14 +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
8ccecb6d99 kernel: down to 12 errors again
Slowly chipping away at it.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 20:59:31 +08:00
Sean Cross
e7a4927943 kernel: down to 7 compile errors
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 19:21:54 +08:00
Sean Cross
ebf568dadd baremetal: slowly whittling down the number of errors
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 16:14:34 +08:00
Sean Cross
285b92401e mem: get tests working again on hosted
This fixes all tests so they now work (and pass!) when running in a
hosted environment.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-03 18:15:56 +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
cece761ff1 xous: SID: convert to using newtype
Rather than simply casting a tuple as a type, create a new struct SID.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-29 20:03:21 +08:00
Sean Cross
0ffbaa369a kernel: fix remaining warnings
This just silences them, which isn't great in the long run.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 15:16:51 +08:00
Sean Cross
05ccba9450 kernel: implement move test
We can now `Move` memory from one "process" to another.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 18:31:51 +08:00
Sean Cross
40ed6365e2 first memory message works
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 17:41:50 +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
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
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
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