Commit graph

761 commits

Author SHA1 Message Date
bunnie
d6cfb13e4f upgrade irq path to handle the new API 2024-03-23 11:59:31 +08:00
bunnie
5234127b7b support multiple irq-like contexts with an enum 2024-03-23 11:59:31 +08:00
bunnie
70639214e1 specify the swap return address for swaps 2024-03-23 11:59:31 +08:00
bunnie
500a641848 specify the irq return address for irqs 2024-03-23 11:59:31 +08:00
bunnie
474e8f0822 make return address of callback configurable 2024-03-23 11:59:31 +08:00
bunnie
f2e44d364a implement blocking callback
a roughed-out nonblocking callback version also staged
2024-03-23 11:59:31 +08:00
bunnie
9008452a36 add arguments to register syscall for handler and state 2024-03-23 11:59:31 +08:00
bunnie
6806403da8 make the release page mechanism visible externally for swap config 2024-03-23 11:59:31 +08:00
bunnie
47a16b6ce4 add RETURN_FROM_ISR magic address
this is picked to not conflict with other addresses used by
the ARM implementation. I think it should be OK?
2024-03-23 11:59:31 +08:00
bunnie
26047bf956 add the routine to evict a page 2024-03-23 11:59:31 +08:00
bunnie
6f18a0ed21 add trampoline to return from swapper 2024-03-23 11:59:31 +08:00
bunnie
daf4d9a93e make valid bit mapping symbolic instead of hard coded constant 2024-03-23 11:59:31 +08:00
bunnie
bc91055307 add template for EvictPage
actual function is still a todo
2024-03-23 11:59:31 +08:00
bunnie
b0665c3412 implement RegisterSwapper syscall 2024-03-23 11:59:31 +08:00
bunnie
9fb1acb705 swap module, with some initial functionality for registration 2024-03-23 11:59:31 +08:00
bunnie
4f15af3fee add swap module to the kernel, and initialize it from args 2024-03-23 11:59:31 +08:00
bunnie
a1cffed9cd un-use the P bit in the page table
prep for re-allocating it to swap
2024-03-23 11:59:31 +08:00
Sean Cross
b4d6884cc4 kernel: use addr_of!() and addr_of_mut!()
DUe to https://github.com/rust-lang/rust/issues/114447 direct access to
static mut variables causes a warning which will be turned into an
error in the 2024 edition.

The workaround is to use `addr_of!()` and `addr_of_mut!()` macros and
then dereference that.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-03-22 15:53:11 +08:00
bunnie
717abf4af8 work around dependency conflict on atsma5d27
the dependency is pinned to an old version of utralib that
causes a build conflict...
2024-02-08 00:33:14 +08:00
bunnie
699004e7b0 bump xous pins 2024-02-06 14:49:10 +08:00
Sean Cross
bf61ce5071 kernel: remove dead code
This code is commented-out and dead. It gets adjusted with `cargo fmt`,
so just remove it.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-02-06 10:33:33 +08:00
Sean Cross
ed4ec01017 kernel: support riscv32imac-unknown-none-elf
With Rust 1.76.0, we no longer support building with `#![no_std]` or
`panic = "abort"`, both of which are required within the kernel. As a
workaround, go back to building the kernel under
`riscv32imac-unknown-none-elf`.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-02-06 10:28:33 +08:00
bunnie
64f8285239 cleanup warning 2024-01-29 03:49:33 +08:00
bunnie
1e93171575 turn of rkyv derives in kernel and loader, as these are no-std 2024-01-23 03:59:49 +08:00
bunnie
5df2e27447 add production TRNG to cramium target for kernel 2024-01-20 16:16:07 +08:00
bunnie
a79b134d14 add placeholder for v2p/PID mapping
We need the V2P feature, but don't need the ability to swap
PID spaces yet. Leave the alternate API as a todo!() item
in the kernel for riscv targets.
2024-01-19 23:23:28 +08:00
bunnie
0267a56989 format Cargo.tomls
because apparently cargo fmt doesn't format Cargo.toml files???
2024-01-15 00:14:39 +08:00
bunnie
607db9c573 remove trailing space in kernel 2024-01-14 23:40:30 +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
bunnie
0750644e45
Merge pull request #479 from betrusted-io/process-arguments
Support process arguments
2024-01-07 23:39:45 +08:00
Sean Cross
60f2a17649 kernel: support receiving process arguments
Support passing process arguments in register 2 as part of arguments to
a process.

This requires updating the `InitialProcess` struct that is received from
the loader, and so requires modeifications to be made in tandem.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-01-07 23:02:58 +08:00
bunnie
d44ab2f2aa add the .a artifacts to the tree for the asm.S
these are just sync'd to the asm.S and checked in.

Eventually, we should migrate that .S file into using
in-line assembly macros, but now that I look at it, I remember
why it hasn't been done yet -- there are some fancy conditionals
used to enable compatibility with different architectures that
I don't know off the top of my head how to translate into
in-line assembly syntax.
2024-01-06 16:41:40 +08:00
bunnie
c3f3ef91b2 fix #474
dbf28fbd61 from 9 months ago
actually broke the resume path, but we didn't see it until now
because the .a files are checked into the tree.
2024-01-06 16:41:31 +08:00
bunnie
8ec08c9c76 fix rust v1.75.0 warnings that are probably benign
a lot of re-import warnings have cropped up. While I appreciate
their studiousness on this, the problem is that removing some
of these exports in the API crate could mean that future users
who want access to some API features that aren't used in this
configuration are now unaccessible.

I think it's not a huge problem at the moment, just spam-cleaning
the warnings because there are too many to deal with carefully
at the moment.
2024-01-04 19:15:28 +08:00
bunnie
c9407a2d47 harmonize hosted mode to latest kernel API for get_pid() 2024-01-04 18:30:48 +08:00
Sean Cross
6b5b4a5d21 kernel: services: don't crash when a process quits
When enumerating processes, the `find_process()` process didn't consult
whether a process was actually free. This resulted in a crash,
particularly when attaching a debugger to a crashed process.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
b95d442e20 kernel: debug: add "check memory" command
This command ensures memory is all owned by the correct process and is
unique in its ownership.

It takes a long time to run, so ensure the watchdog timer is disabled.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
e44d009b84 kernel: mem: add function for verifying mappings
Add a function to ensure mappings are unique across the whole system.
This takes a very long time and can crash if the watchdog timer isn't
paused.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
d5816b667a kernel: riscv: remove unsafe code from process
Remove transmutes from process.rs and replace them with ordinary casts.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:24:31 +08:00
Sean Cross
d4893c1c83 kernel: riscv: add phys_to_virt function
The phys_to_virt function can be used to determine what physical address
page is mapped to a virtual address page.

This throws an error when a page is mapped twice, which shouldn't
happen.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:23:19 +08:00
Sean Cross
124040bbb3 kernel: asm: align kernel stack to 16 bytes
The kernel stack offset should be aligned to 16 bytes. Previously it was
aligned to 8 bytes. It's unclear if this was the cause of any issues,
but it is best practice to keep things aligned to 16 bytes.

As part of this, key the atomic instructions off of the CPP macro
presence of atomic instructions.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:15:48 +08:00
bunnie
488d976f23 move original copy to new location, trying to preserve commit history 2023-12-27 15:04:27 +08:00
bunnie
336da86915 remove duplicate asm.S 2023-12-27 15:03:58 +08:00
bunnie
c2c56f9d3f fix typo in kernel feature specifier 2023-12-26 00:20:56 +08:00
bunnie
fda782663a bump version pins for xous change 2023-12-26 00:13:10 +08:00
Sean Cross
3658940260 kernel: add big-heap flag for running tests
When running Rust tests, a larger heap is needed. Add a kernel flag to
support this by default.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:35:37 +08:00
Sean Cross
006a50d206 kernel: mem: fix memory zeroing
Fix memory zeroing when requesting a physical pointer. Previously, only
the first 25% of a page was zeroed due to a bug when casting between
*mut u8 and *mut usize.

This now uses `write_volatile` to ensure the memory clear isn't
optimized out, and uses `usize` pointers everywhere.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:30:26 +08:00
Sean Cross
f2e9d2b76c kernel: riscv: threads: ensure registers are zeroed
The register set should be cleared already, however it is possible
(though remote) that register values are not cleared when a thread is
created.

Ordinarily threads are zeroed when destroyed, but this makes sure
they're zeroed upon creation as well.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:29:20 +08:00