Commit graph

168 commits

Author SHA1 Message Date
bunnie
755556611c prep kernel for packaging
- strip out gdb-stub. Per xobs, the feature never worked, and it
depends upon a branch of a git repo which is not allowed by crates.io
Since the feature hasn't been developed, and crates.io will not
allow even an optional feature that points to a git repo, the feature
was stripped out.

- rename "kernel" to "xous-kernel", so that we can live in a crates.io
package namespace that is specific to Xous.

still have to figure out the riscv package issue.
2022-09-27 17:02:20 +08:00
Sean Cross
581603b205 kernel: services: fix compile error when debugging enabled
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-26 16:45:41 +08:00
Sean Cross
75e855cc4d hosted: fix hosted mode after CreateProcess addition
Hosted mode spawns processes very differently, and this difference was
not reflected after changes were made to native mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-30 13:41:05 +08:00
Sean Cross
a241d89b5b kernel: ignore "ppid unused" warning for now
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:41:13 +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
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
d8eb7be352 process: finish implementing ProcessStartup as return
We now us `ProcessStartup` as the return type. This builds in tset
mode, hosted mode, and RISC-V mode.

Process Startup is still not implemented for RISC-V mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-28 22:43:42 -04:00
Sean Cross
ab512c8996 kernel: services: fix recursion warning in Process
The `Process::defualt()` implementation started getting a recursion
warning in 1.60.0.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 13:32:48 +08:00
Sean Cross
ce4e40b28a kernel: add s command to print servers
This will print all allocated servers on the system.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:36:00 +08:00
bunnie
002e098538 Fix issue #90
Turns out we didn't end up needing this capability, so, commenting it
out because it is a shy too powerful and is like packing a live
mortar shell in a storage unit: eventually, someone is going to
get hurt, even though it seems mostly harmless at the moment.

Code just commented out in case we need this feature in the future,
but, the main reason it was asked for (the PDDB) was accomplished
without it.
2022-02-02 00:37:57 +08:00
Sean Cross
24dd538a5c kernel: fix process exception handling state
Correctly handle transitions to and from exception handling.

Previously, the thread ID was incorrectly set such that the exception
handler became a valid thread. This has been adjusted so that the
exception handler is no longer considered a thread, and all other
threads will cease scheduling during this process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-28 09:20:12 +08:00
Sean Cross
b43366e6ec kernel: services: fix suspend for running processes
If a process is currently running, it needs to be placed into the
`Debug` state rather than the `Ready` state.

Additionally, the process that's being switched to must enter the
`Running` state.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:03:06 +08:00
Sean Cross
19653e9c53 kernel: compatibility with riscv32imac-unknown-xous-elf
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:14:24 +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
5eaa3a41b1 kernel: services: fix warnings on hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:01:07 +08:00
Sean Cross
1b315de830 kernel: make init proces stack grown downwards
Previously, we were creating a stack beginning at the initial page,
and then growing it upwards. The correct behavior is to begin it at
the top and grow it downwards.

In order to do this, subtract the size of the stack from the initial
pointer.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 19:26:11 +08:00
Sean Cross
fa2a841f8a kernel: fix hosted mode exception support
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:51:24 +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
9dc4fcbf55 kernel: services: fix all clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:16:29 +08:00
Sean Cross
d4675ef9cf kernel: services: allow unsetting exception handler
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:05:29 +08:00
Sean Cross
059fc18850 services: add exception handler routines
Add a function to set and one to clear the current exception handler.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:02:32 +08:00
Sean Cross
759ddfedd6 kernel: add initial cut of exception handling
Though it is not yet wired up, the exception handler groundwork is laid
here.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-05 16:18:10 +08:00
Sean Cross
f5cf94524a kernel: add framework for exceptions
Add the ability to invoke exception handlers. This is not yet properly
wired up, but the framework is there.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-02 11:04:47 +08:00
Sean Cross
df30fd580d kernel: add Exception(usize) as process state
When a process encounters an exception of some sort, it will enter this
state if a handler is available.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-26 15:32:03 +08:00
Sean Cross
1fb7d4ebd5 kernel: use unsafe {} on Hosted mode
Since `MemoryRange::new()` is now unsafe, add an `unsafe {}` note when
calling this function on Hosted mode.

This fixes the build.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:07:41 +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
9ced90190e kernel: fix process suspension
This enables processes to be "suspended" by going into a Debug state.
Messages will back up and processes will continue to be scheduled around
the suspended process, while the system will continue to operate.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-18 12:55:21 +08:00
Sean Cross
13204d1714 Merge branch 'master' into debugger
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-18 10:56:30 +08:00
Sean Cross
180c99aa8d kernel: services: free servers on process termination
When a process is terminated, we disconnect it from all other processes.
We also need to free the slot in the server table.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-16 17:55:23 +08:00
Sean Cross
fb839f3217 wip
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-16 16:53:40 +08:00
Sean Cross
bbda4365ae wip commit
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-01 17:57:01 +08:00
Sean Cross
be6e0a9895 kernel: fix thread termination and waiting
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 17:23:13 +08:00
Sean Cross
714aff830c kernel: implement JoinThread(tid)
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 16:32:38 +08:00
Sean Cross
7c2d3a2247 kernel: implement thread exit support
Threads now have the ability to exit. Previously this resulted in a
kernel panic.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 13:04:14 +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
30b82b25b1 kernel: run cargo fmt
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:12:01 +08:00
Sean Cross
040759af25 kernel: services: add process_name(pid)
Add a function to determine the name of a process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
5b92dd9874 kernel: services: use exception stack for kernel interrupts
When the kernel is processing an interrupt, use the exception stack.
This ensures that the kernel interrupt handler can switch processes
without having its stack go away.

This is used for debug information.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
bunnie
08a86749fe fix hosted mode bugs 2021-05-09 01:13:16 +08:00
bunnie
f975884f1e increase server limit to 128 2021-05-06 00:41:27 +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
Sean Cross
21a8ddd458 kernel: services: don't remap memory on intra-process lends
This brings intra-process lending in-line with intra-process sending,
where memory is not remapped the pointer is simply reused.

We may change this at a later point in order to further enforce the
concept of lent-memory-is-inaccessible, so do not rely in this behavior.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-06 09:08:03 +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
85f0adbb2d kernel: implement Disconnect() syscall
Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-02 18:37:09 +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
078f6ba625 kernel: services: be more proactive about updating current_thread
The `current_thread` variable is used to determine which thread to
switch back to after a context switch occurs. Keep track of the thread
more closely.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 16:15:19 +08:00
Sean Cross
2b97ea25ab xous: add create_thread_n functions
These are used to create threads with between 0 and 4 arguments.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 10:42:49 +08:00
Sean Cross
455bd4ccfb kernel: services: add more debug print crumbs
These could be useful in finding out what's gone wrong.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 22:12:29 +08:00