still have to resolve the static mut issue of getting the USB
controller state into the interrupt controller.
I'm not sure there *is* a good way to do it - this might actually
be "the" use case for static mut's - but the point of this
exercise was to just diff out the driver in machine mode versus
OS mode to try and figure out if there's a hardware problem
causing instability or if it's a driver issue
the conclusion so far is that the USB stack requires extremely
tight interrupt handling timing, and so, for better stability
we may have to mirgate away from the heavily user-space dependent
implementation currently in use.
disk enumerates now, and initiates r/w transactions but
the reference driver does not match the implementation in that
the USB stack can't access all of RAM, so we have to add
an intermediate stage that splits the command requests into
smaller chunks
this is in preparation for loader-based updates
may have to increase space even more when we pull in e.g.
firmware signing and verification primitives.
this loops an image from the camera to the oled display in real time.
it will also dump the Y (luminance) data to to a serial port for
offline development & testing of the QR code algorithm.
- fix tx_await() condition to consider both control and tx channels
- make tx_async more efficient for the common case that the buffer
fits in a single transaction by appending the CS de-assert as part
of the initial command stream
- make trait for the udma global clock setting
The high bit in this exploration is that there seems to be no
way to actually confirm when a UDMA transaction has fully completed
on the hardware interface. All the completion signals tell you
when the software-side UDMA resources are freed up. However, in this
case, the hardware-side resources may still be transmitting/receiving
data.
This is a problem for the case of a '4-wire SPI' display where you
need to set an extra line to control command/data mode addressing.
In this case, the current work-around is to read back the state of
the chip select pin as a GPIO to determine when the hardware has
finished.
I suspect that if we can figure out how to use UDMA in a full duplex
mode that we could do something more essentially linked to the
hardware, but this would also require having a dummy Rx buffer allocated
that is the same depth as the hardware Tx buffer if all you cared about
is the hardware conclusion of a Tx.
Realized that the last round of mixed values wasn't actually being
used because we nuke the `seed` value at the top of the loop.
We effectively had a round of ChaCha8 that we were doing but then
throwing away.
This construction should capture all the benefit of the computation
without wasting computation.
- use proper seeding of entire state
- chacha8 does not evolve internal state when extracting the seed,
so we have to run the cipher some to force mixing of the seed
state.
lots of terrible stuff going on, nothing tested, but we have
a baseline of whatever they put in C directly forced into Rust.
A lot of really naughty things going on with raw pointers in this
driver -- it's going to be a challenge to oxidize.
The loader bringup now has some IRQ testing built into it.
Couldn't actually get an IRQ to trigger, but it has to do something
more with me not getting the RV IRQ machine bits configured right
than anything else. However, the stub is useful for confirming
which IRQ bits actually fire on the UDMA UART implementation,
which is the big point. There's an ambiguity in the wiring
of the UDMA block which isn't explained at all, which is the
fact that there's an RX interrupt and an RX_CHAR interrupt.
I still don't know what RX_CHAR does, but the RX interrupt
does fire when a character is received, so that's the one
we're going to use.
not quite sure why it is even there, might just be a thing from
really old code we never removed. Removing this allows us to
specify pointer types to non-copy elements, making Rust do
the hard work of figuring out how big of a block we need to zero.
some errors were made in clearing memory because we weren't
using the Rust type system to our advantage. This cleans up
the phase 1 loader to use the native types of the block plus
the slice length we intend to create to block-zero the correct
region size.
also simplify mem::size_of to size_of
because the print! macro becomes a dummy when debug printing is
off, we get a bunch of warnings about unused variables because
the print! arguments aren't used. Add _ before variable names
to quiet these warnings.
trying to condense most of the RPT API into the loader so
that the userspace can use a single dependency for this.
We can't condense the kernel API into the loader unfortunately,
because the kernel actually uses a different type for representing
a process. This is probably a mistake, and is something that
may be fixed later so we can merge the representations.
We had a "coincidence" before that allowed things to work,
where we had some data line up that we happened to think
was some other header data, so we "fixed" it by
subtracting the offset of the header data.
Actually, it wasn't.
Clarify that decrypt_src_page_at() offsets are relative
to the beginning of encrypted data, and not relative
to the absolute beginning of the disk.
Image creation is now fixed so that stuff lines up to what
this routine expects, and some asserts added to try and
save ourselves in the future as we try to fix other bugs
we discover over time.
loaders are hard.
I think i recall somewhere that an alignment of 16 is required
for certain structures in Rust for the RV32 target; since anything
could be put in there, let's enforce that.
- swap session key has to be stored so we can pass it on to
the kernel to access swap
- setup all PT maps necessary for swapper to be functional
before the swapper is started.
This is to break circular dependencies mapping pages inside the
swapper, especially during boot.
We might also need to statically map the LRU swap count structure,
not sure. We'll burn that bridge when we get there, right now,
let's just get a non count-managed swap even working...