Commit graph

482 commits

Author SHA1 Message Date
bunnie
b275660a71 add an "endcap" to the kernel region
This works around https://github.com/SpinalHDL/VexRiscv/issues/296
2023-01-17 23:07:05 +08:00
bunnie
3417046e7b cleanup memset command a bit more
- we don't need a general memset call -- just a zero page call
- use native rust semantics to embody the call. some alignment checking is
done on the arguments on the way in and out that seem worth it
- the unrolled loop doesn't pay off because we're at the limit of
write bandwidth on the CPU at this point. we would need write-back
caches to gain more performance through unrolling.
2023-01-17 23:05:20 +08:00
bunnie
7be4a88a9b fix scheduler bug (credit: @xobs)
@xobs found a scheduler bug that would trigger a runnable process
search every time a scalar message returned. This fixes the problem,
causing the quantum to go back to the caller as intended.

Improves performance on the syscall by about 40%.
2023-01-17 02:11:48 +08:00
bunnie
aa48476937 Unroll loop for initializing memory in kernel
This also changes the initialization method from using `u8`
to `u32`.

The loop is unrolled to one iteration per cache line.
2023-01-17 02:10:46 +08:00
Sean Cross
3593d715c1 kernel: fix memorymessages with ReplyAndReceiveNext
Fix a segfault that occurred when using ReplyAndReceiveNext on hosted
mode. This now properly passes memory messages back to the client.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-05 11:56:15 +08:00
Sean Cross
3218bde2b4 kernel: implement reply_and_receive_next
Implement `ReplyAndReceiveNext` as a syscall. This will reply to a
message, pull the next message out of the queue, and then re-queue the
server to run. This should make servers much more responsive.

This patch has been tested on both hosted and native modes.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-30 11:07:04 +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
46f340324d kernel: rename Message -> MessageEnvelope
This syncs with the latest changes to `xous-rs`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:02:57 +08:00
Sean Cross
911ddb60fc kernel: debug: fix klog on baremetal
klog() refers to an outdated `.uart` struct, which has since been
renamed to `.serial`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:01:27 +08:00
Sean Cross
da5647539f kernel: syscall: add support for return_scalar5
Add kernel support for returning 5 scalars.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-11-05 18:39:54 +08:00
bunnie
6332bf1c90
Merge branch 'main' into driver-refactor 2022-11-03 01:53:23 +08:00
Jean-Pierre De Jesus DIAZ
d8807e6cea
kernel: Move rand driver to platform module.
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-11-02 14:36:41 +01:00
Jean-Pierre De Jesus DIAZ
b334e5bc31
kernel: Split debug shell and uart driver.
I've added a `platform` module to store all platform specific code, (not
architecture specific) as some platforms will require custom drivers, e.g.
for debug output and for the random number generation code.  The platform
code is in charge of mapping any peripherals needed to work, also to
initialize any other parts of the kernel that require drivers, for example
the debug shell.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-11-02 14:30:31 +01:00
Sean Cross
c17a6d3786 kernel: make SYSTEM_SERVICES unmangled
This symbol will be viewed by external tools.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-28 17:38:25 +08:00
bunnie
ab940e18db fixup warnings 2022-09-27 17:27:21 +08:00
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
bunnie
ea37ce2ea1 add feature gate on v2p per xobs' request 2022-09-15 14:06:07 +08:00
bunnie
6d9848c239 add virt_to_phys syscall
this will help speed up performance profiling as we can
resolve the physical address of the performance buffer allocated
in RAM and use a USB command to read it out, instead of streaming
it over serial.
2022-09-14 18:09:13 +08:00
Sean Cross
c9d5074dd2 kernel: riscv: use pointers for pagetable entries
Instead of passing a constructed mutable ref from the pagetable entry,
pass a raw pointer and use `read_volatile()` / `write_volatile(x)` on
this pointer.

This should remove a little bit of UB from the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:46:54 +08:00
Sean Cross
426fe4b91f kernel: riscv: don't crash when mapping invalid memory
Previously, the kernel would dutifully try to map memory that was in the
kernel space. It did this by investigating the kernel memory offset,
which immediately causes a double-fault.

Check to make sure a userspace process is not trying to map kernel
memory before checking the valid page.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:45:08 +08:00
Sean Cross
dcc964c3c1 kernel: riscv: use klog for memory exception printing
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:44:06 +08:00
Sean Cross
748d4ce87d Merge remote-tracking branch 'origin/main' into libstd-fs 2022-06-27 09:14:04 +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
08958745ba kernel: implement AdjustProcessLimit syscall
Implement the syscall to adjust a process' limit. Currently this
only supports adjusting the heap maximum and the heap size.

In order to adjust a limit, you must first present the current limit.
This can be obtained by requesting a bogus value. The current limit is
returned as part of the result.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-24 00:09:35 +08:00
bunnie
6793f9c5da return non-0 heap size in case of increaseheap of 0
this allows hosted mode to work, as it always reports a 0
heap size.
2022-06-17 02:00:52 +08:00
bunnie
7456158fa9 remove custom ditherpunk flag from kernel
we can now do per-process stack size adjustment
2022-06-16 03:39:25 +08:00
Sean Cross
c6c9a26bf9 kernel: syscall: return heap size for DecreaseHeap
Return the heap size and offset when decreasing the heap. Additionally,
return the heap size when increasing the heap by 0 bytes.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-15 12:35:34 +08:00
bunnie
c687f7dc02 add a kernel feature flag so we can adjust stack size for ditherpunk
Don't want to make the stack size adjustment across the board
because it's helpful for managing/checking bloat as it happens.
2022-06-14 17:08:32 +08:00
bunnie
09a968ef09 remove debug-here dependency
this contains a dependency to `failure` two levels down that has a critical
vulnerability. Unfortunately no new versions of debug-here have been
published in a while. It's no longer used, so just stripping it out
altogether.
2022-06-07 14:00:25 +08:00
Sean Cross
8edf03a243 kernel: fix warning in hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 11:18:43 +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
9aa83bbfb5 kernel: unmap child process pages after setup
Unmap the pages from the child process after we're done setting them up.
This ensures they're not still aliased by our process, despite being
marked as "owned" by the other process.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:38:22 +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
6d294c97c5 kernel: print connection count on per-process output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 15:11:47 +08: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
6f4b58c47d kernel: add process name to server output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:41:22 +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
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
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
bunnie
4561336ebd try to fix the CI test routine 2022-01-10 19:03:20 +08:00
bunnie
eb0c1c4377 fix some hosted mode brokeness that came with pinning crates
the rand api was downgraded to be in line with the ed25519 crate
which removed some "modern" conveniences. Small price to pay for
less code to review.
2022-01-10 17:13:00 +08:00
bunnie
19f95e6bab fix kernel test build 2022-01-08 01:00:20 +08:00
bunnie
9fcd7e17ae warning-clean. need to clean up the hosted mode flow a bit. 2022-01-07 23:22:12 +08:00
bunnie
dd14dfc4c6 retrofit the seed into an atomicu64 so we can set it elsewhere 2021-12-27 02:49:08 +08:00
bunnie
0bd110c163 determinism achieved for testing. now to squash some bugs. 2021-12-26 01:50:30 +08:00
bunnie
66606ed3e0 initial attempt to make hosted mode more deterministic
replace all threadRng with a seeded Rng
2021-12-25 15:58:27 +08:00
Sean Cross
75116d36cd kernel: add debug command to print interrupts
This can be used to ensure the interrupt handlers are where we think
they are.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-10-29 16:21:07 +08:00