For some reason, the current thread becomes 0 during suspend or resume.
This causes an error during boot.
Patch this up while we figure out what's causing it.
Signed-off-by: Sean Cross <sean@xobs.io>
The `libstd` implementation has a bug where it was going through
a vector and mutating it by removing items from the vector,
but not updating the indices.
This fix goes through the vector in reverse order, so that removed
items don't affect the position of the next items in iteration order.
This seems to make the blocking connect much more stable.
Unify scalar return calls so that we only have one return path rather
than three.
We can almost unify memory returning as well, but it's not quite there.
Signed-off-by: Sean Cross <sean@xobs.io>
this adds a "kicker" thread that gets updated with a target time
to kick the UX by the FIDO2 USB handler. When the target time is
met, an "update" command is issued to the UX.
This hopefully creates an efficient mechanism for triggering a
UX redraw that also has an acceptable delay.
The ticktimer wasn't properly adjusting the upper bits, meaning delays
of more than 42 days did not function properly. This was discovered as
part of the libstd tests.
Signed-off-by: Sean Cross <sean@xobs.io>
Precursor has a custom TIMER0 module that is different from other LiteX
timers. Adapt the Renode model to match the hardware.
Signed-off-by: Sean Cross <sean@xobs.io>
There were a few corner cases when it came to thread selection. Namely,
the same thread had a higher chance of repeatedly being executed.
Clean up these corner cases, and as a result get libstd tests to pass.
Signed-off-by: Sean Cross <sean@xobs.io>
Add notes on how to properly hand memory to userspace. This does not yet
work, but is committed here as a work-in-progress.
Signed-off-by: Sean Cross <sean@xobs.io>
The default mem size got shrunk down to 4 MB earlier, but there is a
lingering issue that prevents specifying virtual addresses. As a result,
pddb and others don't work.
Temporarily revert this change.
Signed-off-by: Sean Cross <sean@xobs.io>
The process search now uses iterators properly. It's still not ideal
because it needs to investigate every process, but it's better than it
was.
Signed-off-by: Sean Cross <sean@xobs.io>
Previously we used externally-linked assembly in order to make syscalls.
Now that `asm!()` is stable, use this macro.
This will help to optimize IPC between programs and the kernel.
Additionally, it resolves an unsoundness issue where we were filling in
values on the stack and hoping that Rust didn't reorder the structs.
Signed-off-by: Sean Cross <sean@xobs.io>
The previous condvar implementation was unsound, and didn't do the right
thing. Overhaul condvars so that they now pass the libstd tests.
As part of this, function calls were added to free the mutex and condvar
objects that may have been allocated.
Signed-off-by: Sean Cross <sean@xobs.io>
Use a multiply-based algorithm to count the number of leading zeroes.
This results in a function that's just 20 instructions long.
Signed-off-by: Sean Cross <sean@xobs.io>