Commit graph

699 commits

Author SHA1 Message Date
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
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
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
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
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
Sean Cross
b0ecc26002 kernel: gdb: batch 2- and 4-byte accesses
Instead of always doing bytewise accesses, support 2- and 4-byte access.
Additionally, recognize when multiple 4-byte reads are required.

Note that an additional optimization may be made here in the future to
prevent having to check every address, but this is left for a future
optimization.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-05-11 15:13:03 +08:00
Sean Cross
55d27cbf1b kernel: riscv: use SUM bit for debug visibility
Instead of remapping the page to allow the kernel to access a process'
memory, simply set the SUM bit. This makes it no longer an error for the
kernel to access userspace.

Keep setting the `W` bit when we poke, to allow for updating program
memory with breakpoints.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-05-11 15:11:17 +08:00
bunnie
697d44de3d bump version pins to absorb changes to svd2utra etc. 2023-05-03 23:11:12 +08:00
Jean-Pierre De Jesus DIAZ
66df563313
kernel: update rand to 0.8
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-05-02 12:50:56 +02:00
bunnie
8a574f937f bump for xous-rs version pin update 2023-04-27 22:18:30 +08:00
bunnie
fb710592b0 harmonize scripts around xpack distro (goodbye sifive) 2023-04-27 22:09:08 +08:00
Sean Cross
97da54437e kernel: allow debug of crashed processes
When a process crashes, report this in the kernel console and offer to
attach a debugger.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-20 13:06:02 +08:00
bunnie
cbbeaa27ad prevent overwriting current process ID in case of double-interrupt
this is part of #361, per @xobs
2023-04-12 23:14:09 +08:00
bunnie
849c136b90 bump versions because API crate changed 2023-04-12 23:02:30 +08:00
bunnie
b471b604d0 add option to print panics to screen on certain kernel panic events 2023-04-10 16:11:37 +08:00
bunnie
344dd5094b make the LCD panic handler Precursor-specific 2023-04-10 15:41:59 +08:00
bunnie
2903de5b7b
Merge pull request #363 from betrusted-io/lcdpanic
kernel: initial lcdpanic implementation
2023-04-10 15:31:02 +08:00
Sean Cross
31235c2547 kernel: initial lcdpanic implementation
Panic to the LCD when the kernel panics.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-10 14:42:59 +08:00
bunnie
cb875cf54e various fixes to gdb-stub
these are from @xobs via issue #361
2023-04-09 22:15:57 +08:00
Sean Cross
dbf28fbd61 kernel: use correct fake interrupt cause
Previously, we were creating a fake interrupt that was a "user software
interrupt". Update this to be a "supervisor external interrupt" to fix
hardware resume.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-09 15:31:06 +08:00
bunnie
8357ab31a5 bump all pins because utralib got updated 2023-04-09 00:48:35 +08:00
bunnie
9c94d6b4c0 bump versions because xous-rs API changed for gdb-stub 2023-04-08 23:49:24 +08:00
Sean Cross
6016f951ef kernel: gdb: unpause process on disconnect
Resume the debugged process when the debugger disconnects.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 14:34:13 +08:00
Sean Cross
916a0bde42 kernel: fixup gdb guardrails
The riscv target requires stepi to be implemented, which we now do.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 11:23:35 +08:00
Sean Cross
7c2ffbb34e kernel: implement gdb server
The gdb server runs on an additional serial port and provides
process-level debugging to the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
3469c292ec kernel: riscv: fixup exception debug handling
Debug handling was not correct, and didn't work at all. Additionally,
interrupt masking didn't work.

Fix these problems.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
eb33af53e0 kernel: gdb: break features into individual files
Since gdbstub is able to do this, break individual features into their
own files.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
fd71993b68 kernel: gdb: begin ext implementation
Implement the basics required to get "extended mode" working. This is
waiting on upstream to fix issues, but should allow us to attach to
processes once it works.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
ec97b3cdcf kernel: throw error when debugging invalid process
When debugging an invalid process (e.g. not yet run, terminated, etc.)
return an error rather than silently continuing.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
7b36f33ef9 kernel: gdbuart: disable IRQs during destruction
Disable IRQs during destruction, but only if constructed with
`GdbUart::new()`. This allows characters to buffer when the GDB bridge
is destroyed while avoiding the double-free error we were getting from
creating a new UART in the IRQ handler.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
a34733e5e9 kernel: basic version of gdb serevr
This adds a basic gdb server. Currently, it is possible to list
processes and inspect memory and threads. It is not yet possible to
actually interact with code (e.g. no breakpoints and no single
stepping).

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
13029a76a2 kernel: initial gdb-stub reimplementation
Add an initial reimplementation of the gdb-stub using the gdbstub
backing crate.

This supports process enumeration and basic thread investigation.
Processes will pause when the debugger is inspecting them. Memory and
registers can be investigated. Threads can be listed and selected.

It does not yet support breakpoints.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:45:42 +08:00
Sean Cross
e48c108288 kernel: riscv: fix disable_irq when irqs are disabled
Previously, `disable_irq()` would unconditionally mask an interrupt in
the `sim` register. However, when interrupts are disabled this register
is zero, and we really should be updating `SIM_BACKING`.

Consult the state of the interrupt handler and update the appropriate
field as necessary.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:46 +08:00
Sean Cross
02065a6a0b kernel: make disable_irq() infallible
This function never failed. Make it infallible so that it matches the
same calling convention as `enable_irq()`

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:46 +08:00