Commit graph

5122 commits

Author SHA1 Message Date
Sean Cross
fc8d78c2ec kernel: fix hosted mode
The process scheduler changed in subtle ways taht completely broke
hosted mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 11:24:09 +08:00
bunnie
ca2a47e67f fix hosted mode again 2023-01-31 03:27:28 +08:00
bunnie
215f15f138 add missing feature flags to usb device crate 2023-01-31 03:19:17 +08:00
bunnie
b7c4587505 remove the hack to work around ms config issues 2023-01-31 03:19:00 +08:00
bunnie
f40462dc90 fix tts build 2023-01-31 02:46:00 +08:00
bunnie
583198af07 bump verifiers and cargo.lock 2023-01-31 02:28:38 +08:00
bunnie
84368c3f3a bump versions for publication 2023-01-31 02:18:12 +08:00
bunnie
ea5d8acd3d Merge branch 'main' of github.com:betrusted-io/xous-core into main 2023-01-31 02:17:42 +08:00
bunnie
c193d20e55
Merge pull request #306 from betrusted-io/libstd-fixups
Libstd fixups
2023-01-31 02:17:17 +08:00
bunnie
801d164cf4 bump release notes 2023-01-31 02:07:59 +08:00
bunnie
a85c0f336c add missing feature dependency to transientdisk 2023-01-31 02:06:56 +08:00
bunnie
2e10c181b5 Merge branch 'main' of github.com:betrusted-io/xous-core into main 2023-01-31 01:35:47 +08:00
bunnie
c48f88ab93
Merge pull request #302 from gsora/feat/apps-block-device
feat: user-space USB block devices
2023-01-31 01:34:08 +08:00
bunnie
5113c8e18d refactor xous-api-names to properly block (fix #303)
This refactors the lib function to use the existing
`std` call for blocking if at first a regular connection
attempt does not succeed.
2023-01-31 01:31:42 +08:00
bunnie
c87ed72736 chore: fix typos 2023-01-31 01:31:15 +08:00
bunnie
2191503f0c fix #304
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.
2023-01-30 23:14:16 +08:00
bunnie
ea31e50de7 fix typo on feature flag 2023-01-30 23:14:06 +08:00
Sean Cross
bf33196b6b Merge branch 'libstd-fixups' of github.com:betrusted-io/xous-core into libstd-fixups 2023-01-30 22:16:11 +08:00
Sean Cross
ba5cde1169 fixup cargo
Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
adcca270b2 emulation: ticktimer: fix higher bits of ticktimer
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>
2023-01-30 22:15:01 +08:00
Sean Cross
d645f00d5b emulation: timer0: adapt timer0 to custom precursor
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>
2023-01-30 22:15:01 +08:00
Sean Cross
8875d9b4b4 kernel: services: fix corner cases on thread selection
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>
2023-01-30 22:15:01 +08:00
Sean Cross
af3f89d245 kernel: syscall: add notes for handing mem to user
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>
2023-01-30 22:15:01 +08:00
Sean Cross
1d6c1e34de kernel: mem: increase default mem size
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>
2023-01-30 22:15:01 +08:00
Sean Cross
a75d030d77 kernel: main: simplify process search
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>
2023-01-30 22:15:01 +08:00
Sean Cross
7f7142d948 kernel: riscv: print processes from tid #0
Start numbering threads from index 0. This matches up with what the rest
of the system uses.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
8c82736524 kernel: syscall: short-circuit return_scalar irq
When in an IRQ, short-circuit the return logic. This should make
interrupt returns slightly faster.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
502223ec9b kernel: syscall: rename context to tid
The word `context` is an older word. We now use "thread" or "tid".

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:01 +08:00
Sean Cross
a24291b462 xous: use asm!() macro for syscalls
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>
2023-01-30 22:15:01 +08:00
Sean Cross
5185b2ee07 xous-ticktimer: overhaul condvars
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>
2023-01-30 22:15:01 +08:00
Sean Cross
2cb44cdfc2 kernel: services: optimize find_next_thread()
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>
2023-01-30 22:15:01 +08:00
Sean Cross
153736810b Revert "renode: remove custom LiteX_Timer_32"
The custom litex timer is more custom than we thought.

This reverts commit 46fab8cbc8.
2023-01-30 22:15:01 +08:00
Sean Cross
a75bc4f54c kernel: minor formatting cleanups
These files have had rustfmt run on them.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
516876a30f kernel: use common function for finding next thread
THe act of finding a runnable thread is so common, yet the kernel
contains three ways of doing this.

Use a unified function to select the next available thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
69b5e924f3 kernel: properly set current_thread on init
Previously the `current_thread` was set to 0, which is invalid. Set the
`current_thread` so that it defaults to the initial thread ID.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
fcf74c4d9b kernel: limit memory regions to 4 MB
This memory region is much smaller than the previous value of 256 MB,
but it will limit the amount of memory used by superpages in
long-running processes.

Previously, we would march through memory as messages were passed back
and forth and a process' memory space would quickly be eaten up by 1024
pages.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
5dae8f7662 kernel: don't yield when JoinThread returns immediately
When waiting on a thread, it may be the case that the thread we're
joining has exited already. In this case, the correct approach is to
resume execution rather than switching to the parent process.

This fixes an issue where `SWITCHTO_CALLER` is None when joining a
short-lived thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
b18e7d7e99 kernel: immediately switch to new thread on CreateThread
When a new thread is created, immediately switch to the new thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
d25629a3ed kernel: return DoubleFree on invalid Return calls
When attempting to return an invalid item, return `DoubleFree`. This is
because such cases are most likely due to instances where a message was
responded to twice.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
841059e885 ticktimer: implement freemutex/freecondition
With these two API Calls, the ticktimer server will no longer grow
without bounds.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
1f2f08084b xous-api-ticktimer: add calls for freeing objects
Add calls to free Mutexes and Condvars. These will go in a destructor,
and will remove any trace of these mutexes within the ticktimer server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
17195f082f ticktimer: improve condvar handling
Improve condvar so that it is more reliable.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
511f77f897 ticktimer: only allow RecalculateSleep from ourselves
Rewrite the RecalculateSleep opcode handler so that it will only be
processed if sent by our own process.

As part of this rewrite, use the new `let else` pattern.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
3b7b49b4da ticktimer: use sleep_heap.pop_first()
This function was stabilized in Rust 1.66.0.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
Sean Cross
c541c1b000 xous-ticktimer: don't panic in an interrupt
If we are unable to send a message in an interrupt, simply ignore it.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-30 22:15:00 +08:00
bunnie
a455f0ae1d add the evicted record and remove a debug line i forgot to trim 2023-01-30 22:15:00 +08:00
bunnie
1a60fe4aad fix bugs in key invalidation/eviction logic
1. track evictions as separate from cleanliness. not clean means
the data is dirty and needs writing back. eviction simply means
the data needs be re-retrieved from disk.

2. actually fill the data when we do a sync -- previously
we only copied the old data into the new page but then forgot
to allocate the data and assign it to the cache (oops)

3. sync the small pools after doing a remove inside the update()
command to make sure we've met invariants for future calls
to cache fills

so many corner cases, i'm going around in circles....
2023-01-30 22:15:00 +08:00
bunnie
5d926294be only invalidate the key entry if it is within the current range of interest
previously, we were invalidating at the first instance of
encountering the key; instead we should only invalidate once
we've processed it in our range of interest.
2023-01-30 22:15:00 +08:00
bunnie
1e9bfc00ba increase threshold for GC on PDDB
for some reason it's being called a bit earlier than i expected.
2023-01-30 22:15:00 +08:00
bunnie
4013ed0098 add api call to increase PDDB debug level at runtime 2023-01-30 22:15:00 +08:00