this creates a feature flag for cramium-soc targets. This
should be unset for builds that don't target cramium-soc,
and this discipline is managed by xtask.
Haven't dug into it, but the AES instruction is not working
correctly in MPW cramium target silicon. There isn't a great way
to selectively disable hardware acceleration for sub-targets of
patched crates. So, as a work-around, we use xtask to patch
the default arguments of the AES crate, just for cramium-soc
targets, to use software emulated AES. This allows us to move
on with bring-up. To wit, there is another AES accelerator
on-chip that could be much faster than RV32 AES acceleration
(and with better DPA characteristics), and to use that option,
we might have to use a patch like this anyways, because Rust
doesn't have a good way to pass feature flags through patched
crates like this.
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.
if not in quad mode, command is ignored; but without this,
the command is never accepted if you are in quad mode.
the idea is you use this to reset the chip when you don't
know what mode it's in.
We want to use the finish_callback_and_resume() function because
it's well-tested and sets up everything just right, but it expects
that we're coming from another process. Unfortunately, in the
middle of all of this, we need to map a page back into the
destination process' memory space, so we end up starting from
the swapper's memory space, changing into the destination process'
memory space, then mapping the page, then changing back into
the swapper's memory space, then using the finish_callback_and_resume()
call.
I think the impact might not be *that* bad, mainly it's a TLB
miss and the PTW isn't super bad, and this comes after a disastrously
expensive decrypt-from-RAM operation -- so probably not worth it
to angonize over optimizing this bit at this point, and stick
with well-tested primitives.
the reason we're doing this is because the pre-emption timer
lives in this crate too. We don't (can't!) suspend/resume
with swap (yet!) but the pre-emption timer got stuck in susres
so it can be directly turned off without message passing/context
switching during the suspend and resume ops.
- 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...
The check of mapping sanity happens after the VA mapping, so this
undoes that. I think this is a good idea, because we're also
checking the PA->VA mapping of the PTEs as well now.
The addresses put into the swapper's page table are physical
addresses, which are unusable by the swapper itself. This
patches the PTEs with the repsective virtual address, so we
don't have to do a PT walk inside the swapper when handling
a swap event.
Also fix an off-by-one on the processes count. This is sort of
an old architectural bug in the loader that would be nice to fix
someday.
- debug UART is now a static object. Less safe, kinda gross, but
gets us debug access at any time! Probably fine, because once we
turn off the feature all taht ugliness goes away.
- use memory mapped structures for initialization of the swapper state
traits are kind of awful in Rust...it's true, they don't
know how big they are at compile time, so they have to be dyn,
reference, lifetimes, etc...
lot of baggage for a static structure. I guess there's probably
some idk bounds I could put on the traits to make it less poopy
but also just as easy to make it a static structure and not deal
with traits.