Commit graph

728 commits

Author SHA1 Message Date
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
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
a19b1b4f51 kernel: use wfi() on Renode
While it would be nice if we stopped the PLLs as we do on hardware,
Renode does not yet have the ability to issue the `wfi` instruction from
a peripheral write.

As such, directly call `wfi()` on Renode similar to how Cramium
operates.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-24 15:20:11 +08:00
Sean Cross
0673ad912c kernel: gdb: don't panic when accessing kernel memory
Instead, just return 0x00000000.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-22 23:24:39 +08:00
bunnie
fa3f349a0a bump pins as xous-rs has changed 2023-12-01 21:20:01 +08:00
bunnie
6ab88117f6 bump xous-api-log version & fix version pins 2023-10-31 20:07:28 +08:00
Vihaan Jim
0a7a4fcfc1 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-10-14 14:45:50 -04:00
bunnie
d63b5912b1 absorb new xous-rs version 2023-10-10 16:50:00 +08:00
Vihaan Jim
e7445e1b62 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-10-05 17:17:26 -04:00
bunnie
83256257e1 bump xous-rs crate to absorb Send derives on Messages
this is necessary for the smoltcp port
2023-10-03 20:54:14 +08:00
Vihaan Jim
5dda363157 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-09-30 18:07:58 -04:00
bunnie
661b832d7e Merge branch 'cram-udma-uart' into main 2023-09-15 16:34:56 +08:00
bunnie
82c7b6ebed bring the versions up to date with main for a cleaner merge 2023-09-15 16:32:04 +08:00
bunnie
5116d51de5 move kernel UART to DUART port
using the DUART means we don't get console input on the kernel
(because the DUART is incapable of this) but it's a decent compromise
I think because the DUART is fast and efficient, and mostly we want
it to capture kps?

Eventually we'll need an input mode but for now, this will get us
moving.
2023-09-15 15:21:18 +08:00
bunnie
478a612c02 commit version bump 2023-09-12 16:25:10 +08:00
Sean Cross
5dfad296ae xous: mark MemoryRange::as_slice and friends as unsafe
Mark `MemoryRange::as_slice()` and `MemoryRange::as_slice_mut()` as
unsafe.

This is due to the fact that not all representable types can be cast to
an arbitrary value. For example, if Process A sends random values to
Process B, then Process B casts the memory to a slice of `bool`, then
any values that are not 0 or 1 are undefined.

Because these functions can leak UB into the program, they are marked as
unsafe.

This patch adds `unsafe {}` blocks to all instances where this function
is called. Additionally, all instances have been checked to verify that
they do not cast to any invalid types -- most use `u8` or `u32`.

Additionally, the long-deprecated `MemoryRange::from_parts()` call was
removed, since that causes UB without being marked as unsafe.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-09-12 10:07:38 +08:00
Vihaan Jim
41126ec57b Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-08-29 11:29:39 -04:00
bunnie
53469a68d0 publish package updates, sync to release tag 2023-08-08 14:35:49 +08:00
bunnie
b127cd093f bump version pins for change to xous-rs 2023-08-03 13:29:39 +08:00
Vihaan Jim
218e783053 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-07-26 15:13:59 -04:00
bunnie
51278451a0 update version pins to pull in cramium target 2023-07-19 21:07:56 +08:00
bunnie
ca14ed78d2 fix renode build 2023-07-18 13:58:14 +08:00
bunnie
3c13516d57 kernel integrations for cramium 2023-07-17 18:49:21 +08:00
Sean Cross
e7cb72c478 kernel: services: remove unneeded muts
With Rust 1.71.0, mut detection has changed slightly, and it is more
aggressive about warning when things do not need to be mutable.

Remove these from the `services` file.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:28:21 +08:00
Sean Cross
cb32b31e18 kernel: support debugging interrupt handlers
SUpport debugging when interrupt handlers go awry, such as when they
blow out their own stack.

Do this by creating a dummy sentinal of 255 for interrupt handlers.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:26:15 +08:00
Sean Cross
85055052fd kernel: allow debugging panics in interrupt handlers
When an interrupt handler panics, restore the system and allow it to
continue. This will help to debug IRQ handlers that panic for one reason
or another, such as infinite recursion.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:22:47 +08:00
Vihaan Jim
dc9411669c Correctly set process.inner on riscv
This changes the process.inner.pid to the correct PID. Before, it was
simply 1. This lead to problems, for example when sending messages
where an assert checks to make sure that the current PID and the
process PID are the same. Now, you can send messages from a new process.
2023-07-04 15:22:44 -04:00
bunnie
4ac979f0ab update pins, again 2023-07-04 11:20:12 +08:00
bunnie
c9f8f2681b update version pins 2023-07-04 11:09:13 +08:00
bunnie
952ba18fba commit vesrion pin bumps 2023-06-16 01:30:18 +08:00
bunnie
fbe3cb2a3d bump package numbers to absorb PR #388 2023-05-28 15:58:11 +08:00
bunnie
a244b204cc
Merge pull request #388 from Foundation-Devices/syscall-virt-to-phys-pid
Add virt_to_phys_pid syscall
2023-05-28 15:52:57 +08:00
eupn
05d7f6a286
Add virt_to_phys_pid syscall
This syscall allows to obtain a physical address from a mapping of a specific process
2023-05-23 19:43:53 +04:00
bunnie
5a2df4432c technical debt: cleanup UTRA package
- make the "base" field no longer public. It is accessible, but only
through an `unsafe` method, because, it is unsafe.
- add accessors to offest/mask fields. Because, it's not at all
unsafe to access these, and it can be useful for bit-ops that are
not part of the generic set of UTRA.
- add Arc to AtomicCSR, and require `std` for AtomicCSR types.
This should not break anything, I checked inside @foundation-devices
keyOS and they don't seem to be using AtomicCSR anywhere.

The Arc makes it a bit safer to clone the AtomicCSR base pointer
and share it between threads, but it will have an impact on performance.
The USB stack (which requires AtomicCSR) was regression testing and the
impact seems minimal.

Recall that the main purpose of AtomicCSR is to provide a CSR accessor
that does not require a mutable reference to the base object. This
can make certain Rust idioms a bit cleaner. We wrap the base accessor
in Arc+Atomic to try and improve the safety of throwing the borrow
checker under the bus, but it's still not perfect because hardware
mutable state can have side-effects within hardware itself that cannot
be modeled or checked by Rust's borrow checker.
2023-05-23 18:11:24 +08:00