Commit graph

7976 commits

Author SHA1 Message Date
bunnie
83dad63fa2 re-add the kernel publish argument
i forgot this was commented out
2024-12-16 18:55:08 +08:00
bunnie
45a8eb2227 stage tomls for version bump: try_send added to xous-ipc 2024-12-16 18:50:11 +08:00
bunnie
cb3f792f46
Merge pull request #604 from betrusted-io/cram-dev
Rewrite of USB stack
2024-12-16 18:49:00 +08:00
bunnie
370eb75ac1
Merge branch 'main' into cram-dev 2024-12-16 18:48:00 +08:00
bunnie
11ce81c6ea add frunk to the cargo lock for cramium usb 2024-12-16 18:47:17 +08:00
bunnie
e90bd02cae note that debug-print needs to be mutually exclusive
...with other crates that might want to use the application
console, e.g., the USB crate.
2024-12-16 18:03:11 +08:00
bunnie
eb7973f939 make the keyboard API more public
this allows us to access the mappings function in other crates
2024-12-16 18:02:42 +08:00
bunnie
f5cae8b975 add visibility for third-party IRQ implementation
Had to promote the visibility of a bunch of event handler
structures so we can put an IRQ handler outside of the core
USB crate.
2024-12-16 18:02:01 +08:00
bunnie
186534187e add a try_send() routine to buffers
this allows us to send memory messages from an IRQ context
2024-12-16 18:00:51 +08:00
bunnie
9a0bbbd2fb initial stab at a usb-cramium implementation
The approach here turns the usb-device crate "inside out". The
working hypothesis for the unreliability of the previous implementation
is that we try to do all the IRQ-handling in userspace, where
the operation can be pre-empted. Unfortunately, this doesn't set well
with the corigine USB hardware driver, as it assumes that it has
the full CPU attention while its state is being manipulated (and
some things must be responded to in basically real time otherwise
you get protocol inconsistencies).

In this implementation, we use the Xous subsystem to do the
API-level exchanges of information to a USB handler that, for the
most part, runs directly inside an IRQ context.

There's some trickiness in terms of sharing the hardware state
across the boundary between IRQ and userland, but most of it
got handled I think fairly cleanly in this implemnetation by
using the xous-native server queuing mechanism to shuttle data
in between the two domains. The main spot where I think panics
can creep in is in data transmission, where the Tx data is
shoved into a RefCell and then the IRQ is invoked to pull the
data from a RefCell. As long as we don't invoke the IRQ to
pull data from the RefCell while it's borrowed mutably, we should
be OK.

Wrapping the structure in a Mutex actually doesn't help here
because the IRQ context can't do a "wait" to get a lock - it
would never get it, because it's in an uninterruptable context.
Thus we skip the complexity of a Mutex and let Rust panic if
we mesesd up the data hand-off.
2024-12-16 17:56:05 +08:00
bunnie
bd3e99c606
Merge pull request #603 from betrusted-io/cram-dev
Merge cram-dev WIP to avoid branch divergence & check CI status
2024-12-12 15:09:47 +08:00
bunnie
5d35dee4f6 final i2c changes based on sim results 2024-12-11 04:05:24 +08:00
bunnie
946c0f7c4f
Merge pull request #602 from rowr111/small-updates-to-the-locales-readme
small updates to the locales readme
2024-12-10 23:53:39 +08:00
Jeanie
3f6778450b small revision 2024-12-10 23:23:45 +09:00
Jeanie
4f5f4e2a90 small updates to the locales readme 2024-12-10 23:18:42 +09:00
bunnie
4d148c9a55 check only the busy status bit for i2c to confirm command initiation 2024-12-10 18:18:15 +08:00
bunnie
90317b0adb wait for i2c commands to propagate before moving on 2024-12-10 18:06:24 +08:00
bunnie
a3ef478688 more mpw vs nto differences 2024-12-10 17:10:24 +08:00
bunnie
6e1023e5ea update comments 2024-12-10 17:05:59 +08:00
bunnie
f66bd30951 adjust timeouts for simulation 2024-12-10 17:03:52 +08:00
bunnie
5cd21f4330 add an RTL-only i2c test mode
The test is abridged because i2c is a pretty slow protocol, so we
do the bare minimum to exercise a write and a read.
2024-12-10 14:25:14 +08:00
bunnie
c8e4392a95 pass a handle to udma_global to i2c init 2024-12-06 03:33:39 +08:00
bunnie
76ffbf6e27 loader feature for mpw 2024-12-06 03:33:10 +08:00
bunnie
785826ca23 modifications to the HAL for DAR-699 2024-12-06 03:32:49 +08:00
bunnie
a5ebcf5d0f refactor reset api for UDMA
there's now unfortunately branch divergence in the NTO/MPW
code base

The methodology is to code like we're running on NTO, and
if the "mpw" feature is selected, we put hacks in to run
on MPW hardware.

Under the theory that MPW should be totally deprecated
once NTO comes out, and therefore the hacks should accumulate
in the MPW code base (and ideally be somewhat easy to cull when
the time comes).
2024-12-06 03:28:13 +08:00
bunnie
9c1d3c37c9 absorb DAR-699 (udma reset change)
Peripheral reset is now controlled by udma_global
(and actually does something, instead of being a /dev/null)
2024-12-06 03:27:25 +08:00
bunnie
7c727e026f bump release notes with some of the cramium developments 2024-12-06 02:20:57 +08:00
bunnie
a57f3f1977 rework camera main loop to be interrupt driven
this will free up some time for concurrent processing instead of
spin-waiting on new frames
2024-12-04 16:15:58 +08:00
bunnie
02b2b86184 add notes for NTO rework 2024-12-04 16:15:44 +08:00
bunnie
b8ecabedcf add more peripherals to register set 2024-12-03 01:05:50 +08:00
bunnie
05f0f96940
Merge pull request #601 from rowr111/fix-up-i18n_helper.py
Fix up i18n_helper.py
2024-12-02 22:52:00 +08:00
Jeanie
56e741207a just handle errors, no need for the unicode specific stuff.. 2024-12-02 23:30:57 +09:00
Jeanie
6f9e371754 add back cheeky comment 2024-12-02 23:18:55 +09:00
Jeanie
9995ba4852 get this script working again and handle all the decoding error issues 2024-12-02 23:17:38 +09:00
bunnie
9aecddad69
Merge pull request #600 from betrusted-io/rust-1.83-fixes
bump lockfile to track sha2 rev
2024-12-02 21:53:49 +08:00
bunnie
e522c153d2 bump lockfile to track sha2 rev 2024-12-02 21:49:46 +08:00
bunnie
d3c4836eba
Merge pull request #599 from betrusted-io/bunnie-patch-1
Update verifier.rs
2024-12-02 19:38:41 +08:00
bunnie
69f476b26c
Update verifier.rs 2024-12-02 19:37:09 +08:00
bunnie
625d7e63dc
Merge pull request #598 from betrusted-io/rust-1.83-fixes
Rust 1.83 fixes
2024-12-02 19:28:02 +08:00
bunnie
e4a885ea14 commit lock changes 2024-12-02 19:18:56 +08:00
bunnie
93b9ec00bf bump version numbers on all the packages so we can absorb num-derive changes 2024-12-02 19:14:11 +08:00
bunnie
4f21bf3c3e raw pointer dance for memory allocations and extra allocations
this is probably the most significant source of consternation but
also this code path has been fairly well-trodden.

That being said it might be worth considering if there is any
way to use some of the new Rust const based reasoning logic
to see if we can't tighten this up someday, but today is not
that day.
2024-12-02 19:10:39 +08:00
bunnie
b59177176b raw pointer dance for the SWITCHTO_CALLER 2024-12-02 19:06:25 +08:00
bunnie
8876f6e7f5 raw pointer dance for IRQ handlers 2024-12-02 19:05:56 +08:00
bunnie
9662f13d31 raw pointer dance for kernel TRNG 2024-12-02 19:05:24 +08:00
bunnie
64612352d3 raw pointer dance for debug UART 2024-12-02 19:04:37 +08:00
bunnie
95611d9598 This begins a series of commits to cleanup a static_mut warning
So in Rust 1.83, we now get a strongly worded warning telling
us to really, really don't use static muts. They aren't wrong,
except that in some places like the kernel we have few options:
we are conjuring pointers out of thin air, creating memory mappings,
and then doing things with them that are hard for the compiler
to reason about.

I think the newly minted warning was made because the intention
is that we could use the new fancy `const` semantics to take
the place of static mut usage by wrapping things in UnsafeCell,
and I think maaaaybe in some
cases this could apply here, but as a simple example a dive
into the kernel debug UART indicates that to initialize the
shared variable we have to allocate pages in the page table,
which involves calling the memory manager and doing some
decidedly non-const type of things. So one option is we could
just push the debug UART initialization into the loader and
paper over the whole thing by pretending it's static.

Instead of that, we adopt a pattern of casting all our static
muts to a raw pointer, and then back into what we want. The
cast to raw pointer is like an "uber unsafe" marker that says
"no we really mean that this pointer is where it is and we
conjured it out of thin air and we promise that the behavior
is defined and values are representable, etc.".

In general we're fairly judicious about the use of static
mut in the kernel, and when in the kernel there's no thread
pre-emption (although we could take an interrupt or page
fault) so generally we are single-threaded. The trickiest
spots are when we have to take a page fault while handling
a page fault (for example, allocating a new L1 page table
entry would require something like this) but this code path
is fairly carefully vetted.

So instead of just doing a global lint silence, we use an
`&raw` idiom to call out the fact that we're doing something
naughty wherever we do it, which makes the compiler "happy"
(for now) while still making the code ugly enough that it
looks sufficiently scary and you have to apply some
cognitive burden to even reason about what's going on,
which I *think* is the intention of Rust in this case.

Basically you get a get out of jail free card but you can't
simply wear it on a lanyard and pass through the gate -- every
time we need to use it, we have to do a little dance and
wash ourselves in the waters of unsafety and recite the
mantras about defined behavior, representable numbers, thread
safety, etc.
2024-12-02 18:55:18 +08:00
bunnie
2ace34abee cleanup static mut warning in hosted mode 2024-12-02 18:54:44 +08:00
bunnie
e4e6db8bc9 fix implicit lifetime warning 2024-12-02 18:54:26 +08:00
bunnie
83e26ff4c7 update num-derive dependency
this became mandatory in 1.83 to remove warnings. I think it
should have no impact on functionality.
2024-12-02 18:52:59 +08:00