Commit graph

645 commits

Author SHA1 Message Date
Sean Cross
ab512c8996 kernel: services: fix recursion warning in Process
The `Process::defualt()` implementation started getting a recursion
warning in 1.60.0.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 13:32:48 +08:00
Sean Cross
6f4b58c47d kernel: add process name to server output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:41:22 +08:00
Sean Cross
ce4e40b28a kernel: add s command to print servers
This will print all allocated servers on the system.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 10:36:00 +08:00
Sean Cross
5fddf7c230 kernel: implement UpdateMemoryFlags syscall
This call is used to strip flags from a chunk of memory.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-02-07 13:36:48 +08:00
bunnie
002e098538 Fix issue #90
Turns out we didn't end up needing this capability, so, commenting it
out because it is a shy too powerful and is like packing a live
mortar shell in a storage unit: eventually, someone is going to
get hurt, even though it seems mostly harmless at the moment.

Code just commented out in case we need this feature in the future,
but, the main reason it was asked for (the PDDB) was accomplished
without it.
2022-02-02 00:37:57 +08:00
bunnie
4561336ebd try to fix the CI test routine 2022-01-10 19:03:20 +08:00
bunnie
eb0c1c4377 fix some hosted mode brokeness that came with pinning crates
the rand api was downgraded to be in line with the ed25519 crate
which removed some "modern" conveniences. Small price to pay for
less code to review.
2022-01-10 17:13:00 +08:00
bunnie
19f95e6bab fix kernel test build 2022-01-08 01:00:20 +08:00
bunnie
9fcd7e17ae warning-clean. need to clean up the hosted mode flow a bit. 2022-01-07 23:22:12 +08:00
bunnie
dd14dfc4c6 retrofit the seed into an atomicu64 so we can set it elsewhere 2021-12-27 02:49:08 +08:00
bunnie
0bd110c163 determinism achieved for testing. now to squash some bugs. 2021-12-26 01:50:30 +08:00
bunnie
66606ed3e0 initial attempt to make hosted mode more deterministic
replace all threadRng with a seeded Rng
2021-12-25 15:58:27 +08:00
Sean Cross
75116d36cd kernel: add debug command to print interrupts
This can be used to ensure the interrupt handlers are where we think
they are.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-10-29 16:21:07 +08:00
bunnie
013606a4b2 this time, with saving the merge file (some weirdness in vscode...) 2021-10-04 17:34:24 +08:00
bunnie
44615c9acf Merge branch 'main' of github.com:betrusted-io/xous-core into main 2021-10-04 17:28:35 +08:00
Sean Cross
24dd538a5c kernel: fix process exception handling state
Correctly handle transitions to and from exception handling.

Previously, the thread ID was incorrectly set such that the exception
handler became a valid thread. This has been adjusted so that the
exception handler is no longer considered a thread, and all other
threads will cease scheduling during this process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-28 09:20:12 +08:00
Sean Cross
1ef4c0d87d kernel: mem: actually free unmapped pages
Previously we would only free a page if it was valid. Now we
unconditionally free it.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:40:39 +08:00
Sean Cross
956d5f0866 kernel: remove debugging prints for memory allocation
Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:38:15 +08:00
Sean Cross
fa31e2235c kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:42:48 +08:00
Sean Cross
62216b7295 kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to
allocate and free memory without ever touching physical pages.

Previously, when we attempted to free memory, it would skip over pages
that were never backed by real memory.

With this patch, we continue to free the virtual page even if there is
no associated physical page.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 13:39:10 +08:00
bunnie
6304ba4616 backout syscall patch 2021-09-27 13:34:02 +08:00
bunnie
be8a3a9acd an attempt to create the failing test case, but it seems this is too simple 2021-09-26 00:43:46 +08:00
Sean Cross
7d3d710554 kernel: gdb_server: don't inline functions
This was a holdover from size benchmarks.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:05:27 +08:00
Sean Cross
30eb24af61 kernel: debug: fix wrap-print on xous target
When targeting the `xous` target, we were missing some variables due to
them relying on `target_os="none"`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:04:42 +08:00
Sean Cross
b43366e6ec kernel: services: fix suspend for running processes
If a process is currently running, it needs to be placed into the
`Debug` state rather than the `Ready` state.

Additionally, the process that's being switched to must enter the
`Running` state.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:03:06 +08:00
Sean Cross
1cb86078d5 kernel: riscv: suspend or terminate processes that fail
If a process fails for some reason (e.g. by performing a fault) and
there is no exception handler, either terminate the process or (if
gdbserver is enabled) have it suspend the process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:02:11 +08:00
Sean Cross
19653e9c53 kernel: compatibility with riscv32imac-unknown-xous-elf
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:14:24 +08:00
Sean Cross
e44eec2334 kernel: fix remaining warnings on hosted mode
This removes all remaining warnings from hosted mode. Tests pass, and
the system continues to run normally.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:07:25 +08:00
Sean Cross
5eaa3a41b1 kernel: services: fix warnings on hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 15:01:07 +08:00
Sean Cross
90d1c7a4b8 kernel: move arch mods into their own dir
Move `hosted.rs` into `hosted/mod.rs` and `riscv.rs` into
`riscv/mod.rs`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 14:55:38 +08:00
Sean Cross
c59cdfbd51 kernel: rename WouldBlock syscall result
This reflects the new naming convention, which is clearer.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-16 12:25:39 +08:00
Sean Cross
1b315de830 kernel: make init proces stack grown downwards
Previously, we were creating a stack beginning at the initial page,
and then growing it upwards. The correct behavior is to begin it at
the top and grow it downwards.

In order to do this, subtract the size of the stack from the initial
pointer.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 19:26:11 +08:00
Sean Cross
e29dc5a739 kernel: don't allow allocating exception thread
This prevents the exception thread from being allocated as a normal
system thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-15 19:25:29 +08:00
bunnie
5113df5eec Merge branch 'bunnie-dev' into main
Use a RefCell to solve the interior mutability issue introduced
by the &mut check introduced on MemoryRanges.
2021-08-10 18:13:33 +08:00
Sean Cross
fa2a841f8a kernel: fix hosted mode exception support
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:51:24 +08:00
Sean Cross
6985fda7ba kernel: get exceptions fully working
This finishes work with exceptions such that they now actually work.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 17:47:44 +08:00
Sean Cross
9bba083e2e kernel: remove debug print from mem.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 13:05:23 +08:00
Sean Cross
15c9eadc4c kernel: riscv: re-fix mem warnings
The previous approach did not work, and broke everything. This fixes it
properly.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 13:02:16 +08:00
Sean Cross
b6f706411b kernel: gdb_server: fix clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 12:55:22 +08:00
Sean Cross
68f5e81d3f kernel: riscv: fix warnings in process
Fix clippy warnings in the `process.rs` file.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 12:54:43 +08:00
Sean Cross
dbd34318ce Revert "kernel: fix remaining clippy warnings"
This appears to have broken things.

This reverts commit 8b0dd3630c.
2021-08-06 12:51:40 +08:00
Sean Cross
8b0dd3630c kernel: fix remaining clippy warnings
This removes all remaining clippy warnings from inside the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:43:34 +08:00
Sean Cross
0a6a1f2edd kernel: syscall: ignore final Clippy warning
This warning is due to some debug information that is currently unused.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:39:09 +08:00
Sean Cross
cc8dc49dba kernel: riscv: refactor irqs to support exceptions
This fixes the exception handler so that it can support user-defined
exceptions. Additionally, kernel mode errors are called out now.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:37:27 +08:00
Sean Cross
19f68edbb4 kernel: riscv: allow exceptions with NULL pc
When the program counter is NULL, we can still get exceptions. This
happens when we jump to an invalid address, for example.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:34:50 +08:00
Sean Cross
08b787a03e kernel: debug: fix remaining clippy lints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:34:30 +08:00
Sean Cross
c7ff0ceb21 kernel: mem: fix remaining clippy lints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:32:52 +08:00
Sean Cross
d27a2eb27e kernel: mem: use iter instead of array access
This compresses the entirety of the memory range finder into a single
statement. As a result, duplicate code is removed and we can elide more
range checks.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 11:30:29 +08:00
Sean Cross
9dc4fcbf55 kernel: services: fix all clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:16:29 +08:00
Sean Cross
d4675ef9cf kernel: services: allow unsetting exception handler
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:05:29 +08:00
Sean Cross
5b2ac0df68 kernel: implement SetExceptionHandler routine
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:03:29 +08:00
Sean Cross
76953985fe kernel: fix clippy warnings in mem/server
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:03:12 +08:00
Sean Cross
059fc18850 services: add exception handler routines
Add a function to set and one to clear the current exception handler.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:02:32 +08:00
Sean Cross
a096509a04 kernel: irq: use iter for IRQ_HANDLERS
Don't use direct indexing. Instead, use an iterator to go through the
IRQ_HANDLERS array.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-06 10:00:42 +08:00
Sean Cross
b98e465d12 kernel: more clippy warning fixes
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-05 16:59:27 +08:00
Sean Cross
759ddfedd6 kernel: add initial cut of exception handling
Though it is not yet wired up, the exception handler groundwork is laid
here.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-05 16:18:10 +08:00
bunnie
d68b6639cf remove now-unused stub 2021-08-04 23:29:00 +08:00
bunnie
d42658a65d fix kernel debug input
for whatever reason, by default, uarts in litex are configured
not to drain a fifo when you read them -- they only drain
after you write EV_PENDING.
2021-08-04 22:40:12 +08:00
Sean Cross
f5cf94524a kernel: add framework for exceptions
Add the ability to invoke exception handlers. This is not yet properly
wired up, but the framework is there.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-02 11:04:47 +08:00
Sean Cross
2cd42edc22 kernel: use target_os = "none" instead of baremetal
This is more portable, and plays nicer with `rust-analyzer`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-26 15:32:59 +08:00
Sean Cross
df30fd580d kernel: add Exception(usize) as process state
When a process encounters an exception of some sort, it will enter this
state if a handler is available.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-26 15:32:03 +08:00
Sean Cross
4e17946960 kernel: riscv: ensure stack is 16-byte aligned
Make sure processes are set up such that the stack is aligned to a
16-byte boundary.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-07 14:34:05 +08:00
Sean Cross
4e54bfdc7a kernel: use gdbstub dev/0.6
The previous brach will shortly be deleted.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-27 19:23:53 +08:00
Sean Cross
7b7be0fe9e hosted: fix MemoryRange refactor
This fixes the MemoryRange refactor where `.addr` and `.size` are now
private fields.

Previously it had only been tested on baremetal mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 18:02:28 +08:00
Sean Cross
a99839ecd6 xous: mark MemoryRange fields as private
Mark the private fields in a `MemoryRange` struct as being private. This
allows us to perform operations on the memory range armed with the
knowledge that the entire range is valid and unaliased.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:41:16 +08:00
Sean Cross
1fb7d4ebd5 kernel: use unsafe {} on Hosted mode
Since `MemoryRange::new()` is now unsafe, add an `unsafe {}` note when
calling this function on Hosted mode.

This fixes the build.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:07:41 +08:00
Sean Cross
977a175bb5 xous: mark MemoryRange::new() as unsafe
This function allows for creating arbitrary memory ranges. Mark this
function as `unsafe` in order to warn users that this can be used to
create invalid memory regions.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-24 17:02:02 +08:00
Sean Cross
e4d02301ee kernel: support pluggable debug printing
This allows us to support different printers in the kernel. For example,
this can be used to swap out the println!() function to print to GDB
when a debugger is attached.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-23 17:51:59 +08:00
Sean Cross
931b992063 kernel: gdb_server: return 0xff on read error
This seems to be rather universal.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 20:23:22 +08:00
Sean Cross
524df22667 kernel: riscv: ensure pages are writable when poking
Ensure pages of memory can be written to when we write to them. This
lets us patch program code to, for example, insert breakpoints.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 20:22:45 +08:00
Sean Cross
973e4601e4 kernel: don't use debug_here in CI
When running in CI, cause processes to panic rather than waiting for a
debugger to attach. This will ensure test failures are caught sooner
rather than later.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 20:05:24 +08:00
Sean Cross
4901453e3d syscall: retor_mem: switch to client in hosted mode
Switch to the message client when returning memory in Hosted mode. This
properly marks a process as ready-to-run, which was otherwise not
correctly done.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 20:04:22 +08:00
Sean Cross
86dd38f7fa kernel: fix hosted build
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 14:24:16 +08:00
Sean Cross
57b502e2c6 kernel: add gdb support to riscv
This adds various primitives that can be used to attach a debugger to
the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 14:13:01 +08:00
Sean Cross
0332959068 kernel: debug: add gdb_server support
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-21 14:12:42 +08:00
Sean Cross
80860f0a51 Merge remote-tracking branch 'origin/main' into debugger 2021-06-21 13:22:51 +08:00
Sean Cross
2a1aa24040 kernel: debug: add command to print processes
This changes the `p` command to only print processes, and renames the
existing behavior to `P` which prints processes and threads.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-18 12:56:27 +08:00
Sean Cross
9ced90190e kernel: fix process suspension
This enables processes to be "suspended" by going into a Debug state.
Messages will back up and processes will continue to be scheduled around
the suspended process, while the system will continue to operate.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-18 12:55:21 +08:00
Sean Cross
13204d1714 Merge branch 'master' into debugger
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-18 10:56:30 +08:00
bunnie
96ca0eb8a1 Merge remote-tracking branch 'origin/master' into ux-refactor 2021-06-16 17:56:44 +08:00
Sean Cross
180c99aa8d kernel: services: free servers on process termination
When a process is terminated, we disconnect it from all other processes.
We also need to free the slot in the server table.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-16 17:55:23 +08:00
Sean Cross
76b16579b0 kernel: syscall: remove warning in hosted mode
This was a function whose only purpose is useful in baremetal mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-16 17:54:55 +08:00
Sean Cross
62623f995c Merge branch 'master' of github.com:betrusted-io/xous-core 2021-06-16 16:54:06 +08:00
Sean Cross
fb839f3217 wip
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-16 16:53:40 +08:00
bunnie
a70b858812 convert to using the urandom interface 2021-06-11 16:29:25 +08:00
Sean Cross
651844ba20 Merge remote-tracking branch 'origin/master' into debugger 2021-06-06 19:21:18 +08:00
Sean Cross
3becfc03c5 kernel: debug: store only a single object in GDB_STATE
This keeps a single object in the global singleton.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-06 11:46:00 +08:00
Sean Cross
29c36c3b0f debug: get kernel building
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-06 11:39:41 +08:00
bunnie
bbfe0fb605 Merge remote-tracking branch 'betrusted/aes' into bunnie-dev 2021-06-02 14:49:11 +08:00
bunnie
fadc9c29ab Merge remote-tracking branch 'origin/master' into bunnie-dev 2021-06-02 03:59:25 +08:00
Sean Cross
bbda4365ae wip commit
Signed-off-by: Sean Cross <sean@xobs.io>
2021-06-01 17:57:01 +08:00
bunnie
2f9fa57bdd clock-gate based power management now seems to be more or less working 2021-05-31 23:14:35 +08:00
bunnie
d9e56fd321 very preliminary power savings working 2021-05-31 05:20:54 +08:00
bunnie
7c55925926 intermediate check-in on wfi 2021-05-30 23:07:16 +08:00
Sean Cross
be6e0a9895 kernel: fix thread termination and waiting
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 17:23:13 +08:00
Sean Cross
714aff830c kernel: implement JoinThread(tid)
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 16:32:38 +08:00
Sean Cross
7c2d3a2247 kernel: implement thread exit support
Threads now have the ability to exit. Previously this resulted in a
kernel panic.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-21 13:04:14 +08:00
Sean Cross
e616a4bf4f kernel: fix hosted build/warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:52:03 +08:00
Sean Cross
09b8242bb2 kernel: get process termination "working" on risc-v
This successfully allows a process to call `terminate_process(val)`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:42:31 +08:00
Sean Cross
eb7895d601 xous: add a return code to TerminateProcess
As part of this refactor, make `terminate_process()` a divergent call.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:01:00 +08:00
Sean Cross
6e57fbe29b kernel: riscv: make sure to flush mmu
THe MMU flushing logic got disabled due to an experiment. Re-enable it
to ensure pages are consistent when shifting them across boundaries.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 20:55:45 +08:00
Sean Cross
d15127fef6 kernel: run cargo fmt
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:18:46 +08:00
Sean Cross
47bf453325 kernel: riscv: use raw pointers for mmu mapping
This avoids using uninitialized arrays to manage the pagetables, and
instead uses raw pointers. This should avoid using potentially
uninitialized data.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:17:53 +08:00
Sean Cross
25f976dbb6 kernel: claim uart irq before we enable irqs
In order to prevent a race at the start, claim the IRQ before we enable
the IRQ.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:17:07 +08:00
Sean Cross
30b82b25b1 kernel: run cargo fmt
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:12:01 +08:00
Sean Cross
9a9cd25414 kernel: debug: add help screen to debug output
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 19:37:30 +08:00
Sean Cross
1b7ee904b2 kernel: print running total of memory usage size
Print the total of all processes in the system.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 15:09:46 +08:00
Sean Cross
5bca939c37 kernel: mem: fix build on hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:42:53 +08:00
Sean Cross
49904988c3 kernel: debug: add simple uart interface
Wire up the interrupt handler to allow printing various debug
information.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
1b85d8a4de kernel: format syscalls as hex
This improves readability, particuarly when addresses are involved.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
040759af25 kernel: services: add process_name(pid)
Add a function to determine the name of a process.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
1818256f5e kernel: mem: add ram_used_by() function
This can be used to determine the amount of ram used by a particular
process ID.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
5b92dd9874 kernel: services: use exception stack for kernel interrupts
When the kernel is processing an interrupt, use the exception stack.
This ensures that the kernel interrupt handler can switch processes
without having its stack go away.

This is used for debug information.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
ce66a6bde2 kernel: riscv: add exception const to mem
The address of the exception page is now available for use as a standard
variable.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
5bd9e40ace kernel: riscv: add print_thread_* family
These calls can be used to print out thread information for debugging.
This augments the existing `print_thread()` call, which has been renamed
to `print_current_thread()`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
bunnie
08a86749fe fix hosted mode bugs 2021-05-09 01:13:16 +08:00
bunnie
c0d72c282b increase process limit 2021-05-06 00:44:32 +08:00
bunnie
f975884f1e increase server limit to 128 2021-05-06 00:41:27 +08:00
Sean Cross
23e759ffd8 kernel: fix multi-page lending
Due to several errors, multi-page lending did not work properly.

To begin with, if a page was not allocated then it would not be able to
be sent. That is, if you allocated 8192 bytes but only ever accessed the
first 4096 bytes, then an error would be encountered when lending the
unaccessed upper page.

Furthermore, due to a striding error in accessing pointers, half-pages
were treated as full pages.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-05 10:58:12 +08:00
bunnie
46fe3885dc cleanup more turds left over during the bringup of suspend/resume 2021-05-01 00:35:32 +08:00
bunnie
48074b626b clean up more debug messages 2021-04-30 23:33:35 +08:00
bunnie
260b154741 clean up some boot process holdovers 2021-04-30 23:28:31 +08:00
bunnie
640ddb48e8 suspend/resume now works to hardware 2021-04-30 19:29:36 +08:00
bunnie
0e2d57c9fb retrofit the kernel and loader to handle resume
and now the even harder debuggening begins...zomg o_O
2021-04-30 01:55:38 +08:00
bunnie
308cda1af4 remove unused sie use 2021-04-25 21:44:21 +08:00
bunnie
77c44ccb76 depracate use of SIE by storing SIM to RAM-based backing 2021-04-25 18:49:57 +08:00
bunnie
aed2325f68 fix some minor bugs in hosted mode
memory is not page-aligned so `if !cfg()`-out the alignment
checks in hosted mode
2021-04-09 17:31:36 +08:00
Sean Cross
21a8ddd458 kernel: services: don't remap memory on intra-process lends
This brings intra-process lending in-line with intra-process sending,
where memory is not remapped the pointer is simply reused.

We may change this at a later point in order to further enforce the
concept of lent-memory-is-inaccessible, so do not rely in this behavior.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-06 09:08:03 +08:00
Sean Cross
4830f3eb2c kernel: server: implement DestroyServer(sid)
This implements a syscall to shut down a server. Servers may not be shut
down if they have outstanding messages that they have seen but not
responded to.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-05 18:18:48 +08:00
Sean Cross
49c1eacf8c kernel: remove split queues file
This file shouldn't have been checked in.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-05 18:17:09 +08:00
Sean Cross
85f0adbb2d kernel: implement Disconnect() syscall
Signed-off-by: Sean Cross <sean@xobs.io>
2021-04-02 18:37:09 +08:00
Sean Cross
5ae39de7da kernel: riscv: run rustfmt on mem.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-26 17:14:26 +08:00
Sean Cross
af5598d2dc kernel: move memory owner when a Move occurs
When moving memory between processes, update the owner of that page to
match the new PID. Otherwise, memory can never be released.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-26 17:14:26 +08:00
Sean Cross
078f6ba625 kernel: services: be more proactive about updating current_thread
The `current_thread` variable is used to determine which thread to
switch back to after a context switch occurs. Keep track of the thread
more closely.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 16:15:19 +08:00
Sean Cross
a5993f0445 kernel: fix hosted representation of ReturnMemory
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 14:56:40 +08:00
Sean Cross
c7b2b2cab0 xous: add offset and valid to returned memory
This will enable us to have more information about the result that is
returned when mutable memory is modified by a server.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 13:16:15 +08:00
Sean Cross
2b97ea25ab xous: add create_thread_n functions
These are used to create threads with between 0 and 4 arguments.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 10:42:49 +08:00
Sean Cross
568d1263a3 kernel: syscall: remove variables that never change
The `can_resume` variable doesn't change, and can be made a constant.
This slightly improves reasoning about what the function is doing.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 09:14:43 +08:00
Sean Cross
eb2014bc80 kernel: hosted: fix kernel tests
We don't need to re-create the PID1 process, since it is done
immediately now.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-25 09:13:27 +08:00
Sean Cross
455bd4ccfb kernel: services: add more debug print crumbs
These could be useful in finding out what's gone wrong.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 22:12:29 +08:00
Sean Cross
cc0c395e1e kernel: server: rework queue with generation counter
This reworks the server queue to add a "generation counter". This
counter ensures messages are removed from the queue in the order they
were added, even if they are jumbled up within the queue itself.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 22:10:11 +08:00
Sean Cross
f8309dc580 kernel: riscv: add klog messages to mem.rs
These are useful in tracking down certain violations.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 22:07:06 +08:00
Sean Cross
090354c882 kernel: services: remove syscall_stack
This field is unused, so remove it.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 20:21:30 +08:00
Sean Cross
b967712e5f kernel: use correct thread ID when server queue is full
Instead of queueing the client thread number inside the server, queue
the server's thread number inside the server.

This prevents many spooky messages that were occurring when server
queues got full.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-24 17:23:39 +08:00
Sean Cross
861565054e kernel: don't activate target thread on hosted mode
This operation is unneeded on hosted, and causes an error.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 21:35:52 +08:00
Sean Cross
bf3a3879d2 kernel: hosted: create thread id 1
This ensures that PID1 has a thread ID created as well.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 21:35:20 +08:00
Sean Cross
2a6de6ed67 kernel: hosted: remove unused interrupt calls
These were removed from riscv, and have no place in hosted mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 21:34:37 +08:00
Sean Cross
ff05fff4d6 kernel: syscall: run cargo fmt on syscall.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:53:22 +08:00
Sean Cross
0d77f704a9 kernel: services: run cargo fmt on this file
Minor text reformatting.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:51:33 +08:00
Sean Cross
00e7f07187 kernel: services: remember new thread if specified
If we switch to a thread and specify a thread ID, remember that as the
current thread ID.

This prevents thread starvation by repeatedly going back to the same
thread ID.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:50:12 +08:00
Sean Cross
9ab5b4880f kernel: server: allow taking multiple messages from queue
Previously, we would only look at the top item on the server queue. If
it was not a known message, we would return an error.

This patch changes this behavior to look through the entire queue for
something we can take, and then clean it up as we go along.

This allow for having outstanding requests in the queue an forms the
backbone of the sleep server.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:45:32 +08:00
Sean Cross
ccc7264b79 kernel: main: use iterator when printing processes
This avoids a C-style for() loop.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:42:33 +08:00
Sean Cross
6987df997d kernel: irq: don't disable interrupts when claiming irq
When claiming an IRQ, we used to disable interrupts.

This is unnecessary, as interrupts are already disabled when running in
kernel mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:40:56 +08:00
Sean Cross
6e290500db kernel: riscv: fix wfi handling for interrupts
Keep interrupts nominally disabled in supervisor mode, and only enable
them for a brief period after WFI hits.

If an interrupt occurs, then WFI becomes a NOP. The `idle()` function is
only called when no more processes are running, which happens when all
processes are waiting for an interrupt.

Therefore, enable interrupts for a brief period when WFI returns in
order to drain all pending interrupts and return to the caller to handle
any change in the process table.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:38:48 +08:00
Sean Cross
eb4ab4ca35 kernel: main: ignore interrupts in main loop
When the kernel is running its main loop, interrupts are disabled as it
is running in supervisor mode.

As a result, we can ignore any interrupt enabling/disabling that may
need to occur.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-23 19:34:53 +08:00
Sean Cross
06a5997a45 kernel: debug: add wrap-print feature
This feature works around a bug in Renode where unwrapped lines cause it
to crash. This forces columns to be wrapped at 80 characters.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-22 22:27:53 +08:00
Sean Cross
80c41f1dfc kernel: fix build in hosted mode for rand
The `rand` module exists now, which conflicts with the `rand` crate.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-15 11:21:29 +08:00
Sean Cross
55a09990f0 hosted: pre-allocate buffers for performace boost
Buffers have a known size. We can avoid reallocations by preallocating
buffers to this known size.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-14 18:29:45 +08:00
Sean Cross
9c8b562711 hosted: set tcp_nodelay
This might have a performance impact, but it's unclear.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-13 18:05:11 +08:00
Sean Cross
cf1e2435bc kernel: implement GetThreadID and GetProcessID
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-11 11:20:35 +08:00
Sean Cross
e00b958308 hosted: transmit PID to clients
Prior to this patch, all clients assumed they were PID 1.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-10 17:35:57 +08:00
bunnie
e62256b3df clean up hosted mode warnings 2021-03-03 22:50:46 +08:00
Sean Cross
83da8c4e7d syscall: remove commented-out pid code
This isn't used.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:20:21 +08:00
Sean Cross
f5a678e36f kernel: services: remove extra debugging prints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:20:03 +08:00
Sean Cross
8c599a3080 kernel: mem: remove unused debugging prints
Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:19:45 +08:00
Sean Cross
db8e814cb7 kernel: services: fix sending messages within a process
This fixes the case where there is only one process active and it tries
to send messages to itself, or it yields to itself.

This closes issue #42.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:18:58 +08:00
Sean Cross
cc4c0f3c58 kernel: services: implement Debug for ProcessState
This gives us prettier and more useful displays for ProcessState.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:18:01 +08:00
Sean Cross
506bd381b2 kernel: debug: don't print out if not initialized
This allows us to use println early on even before it's initialized,
which will allow us to ignore prints to an uninitialized port.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:13:03 +08:00
Sean Cross
93d295b93b kernel: riscv: fix memory reuse bug
Memory that was marked as reserved-but-not-in-use could get reallocated.
Practically speaking, this caused threads to share stack, which makes
things spooky.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-03-03 21:12:09 +08:00
bunnie
0889e83401 Merge remote-tracking branch 'betrusted/hardware' 2021-03-02 21:51:41 +08:00
bunnie
2d59adbe0e fix thread scheduling bug
the code originally would pick the same thread over and over again
this fix starts the thread search at one plus the current thread
wrapping around to one plus the current thread, so we always try
to pick a new thread compared to the current one, instead of
generally picking the same thread most of the time.
2021-03-02 21:46:14 +08:00
bunnie
4b0f50293f another intermediate commit 2021-03-02 21:15:40 +08:00
bunnie
96a19baa8d state before refactor of status to own process 2021-03-02 19:25:41 +08:00
bunnie
e175d922f0 Merge branch 'hardware' 2021-02-18 02:35:40 +08:00
bunnie
5cdf597a5b fixup tests 2021-02-18 02:35:11 +08:00
bunnie
cb77dde6d8
Merge pull request #39 from betrusted-io/hardware
Synchronize in the rkyv changes
2021-02-18 02:07:13 +08:00
bunnie
0af72ffb6d clean up Sendable references and warnings 2021-02-17 23:29:20 +08:00
Sean Cross
6119c78bc7 kernel: riscv: really fix sharing logic
We're comparing numbers and not MMUFlags, so invalid values crept in.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-17 17:35:13 +08:00
Sean Cross
b6a28a85fc kernel: riscv: invert shared logic
This logic was backwards.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-17 17:28:49 +08:00
Sean Cross
e9a1da25b0 kernel: riscv: mark address_available() as false when shared
When a page is shared, only report an address as being available when
we receive a `BadAddress` error when doing the translation. Otherwise,
assume it is in use.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-17 17:23:05 +08:00
Sean Cross
3b85392877 kernel: riscv: return ShareViolation when memory is shared
When memory has been shared, it is no longer valid. However, it is still
"in use".

Return a `ShareViolation` error in this case so we can check for it
elsewhere.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-17 17:23:05 +08:00
Sean Cross
fbad2e4391 kernel: riscv: don't allow multi-sharing of lends
Initially, we wanted to be able to immutably lend data in a one-to-many
fashion. However, this has proven challenging, and doesn't have any
immediately obvious useful benefits.

For now, only allow one-to-one immutable lends.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-16 20:26:27 +08:00
Sean Cross
b9a4e11a64 kernel: riscv: use bit flags for irq handler
Instead of hardcoding bit values, use the symbolic names. This will
ensure we don't make mistakes by using magic numbers.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-16 20:25:42 +08:00
bunnie
b803d7d4e9 commit that captures the multiple lend bug 2021-02-16 12:42:11 +08:00
bunnie
2a46f541f2 add PID identification facility to help with debugging 2021-02-15 19:15:58 +08:00
Sean Cross
715e76bee0 kernel: allow connection IDs to be u32
In an effort to homogonize platforms, we are moving away from `usize` in
favour of `u32`. Allow the `CID` type to be a `u32` in the kernel by
casting it to a `usize` as necessary.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-04 10:29:12 +08:00
Lina Ceballos
d18500f4d6 adding license and copyright headers 2021-01-25 14:54:00 +01:00
Sean Cross
6cf140f2da kernel: riscv: don't print valid page faults
Some page faults are valid, and shouldn't be printed unless they fail.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-13 21:09:40 +08:00
Sean Cross
8d99ee06cf kernel: fix extra-parens warning in syscall
Remove an extra set of parenthesis.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-13 21:09:14 +08:00
Sean Cross
e87eb112ae kernel: debug: fix const warnings
This makes debug a const, which prevents it from getting copied all over
the place.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-13 21:09:05 +08:00
bunnie
4ef581a266 riddled with race conditions, but...sort of works 2021-01-08 05:20:53 +08:00
Sean Cross
b16ad82e56 kernel: riscv: print out allocated address
This will aid in debugging.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-07 18:50:48 +08:00
Sean Cross
6cbec94953 kernel: riscv: use page base addr when allocating pages
When allocating a page, it is only assigned a physical address once it
is actually needed. This on-demand paging works well, however we were
assuming that the first address of a page was accessed first.

This fixes an issue where a Message is allocated but the first byte
isn't accessed first.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-07 13:34:42 +08:00
Sean Cross
7b50d00eb8 repo: run cargo fmt
This reformats line endings to be consistent, and reinforces the
contents of `.gitattributes`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-03 18:31:51 +08:00
Sean Cross
a36ceb00c2 kernel: use crossbeam for tests
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-30 16:51:21 +08:00
bunnie
ed5624635b Merge branch 'master' of https://github.com/betrusted-io/xous-core into hardware 2020-12-14 17:58:39 +08:00
bunnie
c9a18125df add hardware TRNG support to kernel (issue #16) 2020-12-14 17:57:29 +08:00
Sean Cross
ddd57c30bd kernel: fix compile error when debug-print enabled
This tracks a variable that has been renamed, and was preventing the
kernel from compiling when debug printing is enabled.

This fixes #19.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-14 17:02:58 +08:00
Sean Cross
f49518f7d5 kernel: add connect_for_process()
This allows one process to establish a connection to a server on behalf
of another process.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 23:25:41 +08:00
Sean Cross
b094f1147b xous: implement sender.pid()
This is mostly an implementation detail, but appears to work.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 22:38:35 +08:00
Sean Cross
1fa83d1d94 xous: make MessageSender a struct
This is now an object instead of an alias for `usize`, in preparation
for adding a `.pid()` function.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 22:16:24 +08:00
Sean Cross
1f1a535801 kernel: fix pid generation for non-test case
When compiling under non-test scenarios, the `rand` create conflicts
with the new `rand` module.

Disambiguate this field.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 21:12:18 +08:00
Sean Cross
168ffe004e kernel: use create_server() for some tests
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 20:59:21 +08:00
Sean Cross
85b6357d26 kernel: implement CreateServer
This implements CreateServer, which creates a server with a random name.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 20:58:14 +08:00
Sean Cross
25e4d16de3 xous-os: rename CreateServer to CreateServerWithAddress
Servers will, by default, get randomly-assigned SIDs. Certain servers
will want to have well-known SIDs, such as the log server or the
nameserver. These will use a separate call in order to perform this
priveledged operation.

A subsequent patch will add `CreateServer`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-04 20:33:33 +08:00
Sean Cross
f2e2505d4b kernel: server: remove bounds checks from take_waiting_message
This function has been rewritten to no longer have a bounds check.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 13:27:30 +08:00
Sean Cross
e4f7c7286d kernel: fix commented code in server
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 13:20:34 +08:00
Sean Cross
d5f82b7972 kernel: test: fix message ordering test
It turns out that it was working fine, the test was just broken.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 13:18:49 +08:00
Sean Cross
e7744b25ec kernel: services: format document
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 11:54:23 +08:00
Sean Cross
8c994e0397 kernel: add test for message ordering
Messages are arriving out-of-order, which is considered a bug.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-01 10:29:46 +08:00
Sean Cross
f0db281c7d kernel: add test for try_receive_message()
Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-25 20:52:13 +08:00
Sean Cross
8927ef00a2 kernel: add TryReceiveMessage support
This is a nonblocking form of ReceiveMessage.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-25 20:26:21 +08:00
bunnie
db25b05a14 Merge branch 'master' of github.com:betrusted-io/xous-core 2020-11-24 22:46:24 +08:00
bunnie
772bceeb2d fix interrupt pending clear issue in debug module
during conversion to documented interrupts from Litex a case was
missed.
2020-11-24 22:46:10 +08:00
Sean Cross
f3a2c31067 kernel: add test for out-of-order blockingscalars
This already works, we just want to make sure it works.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-24 15:35:54 +08:00
Sean Cross
e3cb05baf5 kernel: syscall: send WouldBlock to retry messages
This is handled by the client library to re-send the request.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 20:04:37 +08:00
bunnie
1aa01fdf5d confirm sleep works, some minor fixup to UTRA style usage 2020-11-23 19:02:02 +08:00
Sean Cross
65c8c6eef5 kernel: implement and use klog!() macro
This replaces the majority of println!() and print!() calls, and works
on baremetal and hosted modes.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:24:28 +08:00
Sean Cross
eecd9c2367 kernel: syscall: return Ok for yield() on hosted
When running in Hosted mode, a yield shouldn't do anything.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:23:53 +08:00
Sean Cross
dfa20cc1b1 kernel: test: rename send_repeat_mutableborrow_message
This function would previously clash with the other name.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:22:59 +08:00
Sean Cross
657604a199 kernel: test: use as_ptr() for memory messages
Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:22:37 +08:00
Sean Cross
1291a2b3aa kernel: hosted: fix unused variable warnings
These only appear when not printing messages.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 17:21:57 +08:00
Sean Cross
8a3f6a2b43 kernel: fix mutableborrow message returning
We weren't properly updating the packet when a mutableborrow was getting
returned.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-23 15:19:02 +08:00
Sean Cross
be1687ffdd Merge branch 'master' of github.com:betrusted-io/xous-core 2020-11-23 14:20:27 +08:00
bunnie
710abce418 fixup to latest soc.svd register documentation standard 2020-11-22 03:45:44 +08:00
Sean Cross
5186594f17 kernel: remove excess debug output from hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:22:29 +08:00
Sean Cross
b8d9d1e1b3 Revert "kernel: hosted: don't send responses twice"
This causes problems, and fixes an issue that doesn't actually exist.
Revert it.

This reverts commit fc9f597092.
2020-11-11 16:18:39 +08:00
Sean Cross
4e6a189e4e kernel: fix returning scalars in interrupt context
This is now allowed.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:06:08 +08:00
Sean Cross
4b83edc43b kernel: server: replace ctx with tid
Threads haven't been called contexts for a very long time.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:04:35 +08:00
Sean Cross
7156ab5e79 kernel: mem: match riscv printf with rest of formatting
We don't use `println` anymore, we use `print`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:03:52 +08:00
Sean Cross
aee42bf264 kernel: print message when idling
Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 16:03:29 +08:00
Sean Cross
fc9f597092 kernel: hosted: don't send responses twice
If we've already sent a response, don't send a second response.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-11 12:55:58 +08:00
Sean Cross
2698333382 kernel: allow making syscalls from an interrupt
This enables calling some syscalls from within an interrupt context.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-01 17:59:26 +08:00
Sean Cross
c6e12a5ecd kernel: remove dead code from hosted/irq.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-01 16:29:36 +08:00
Sean Cross
7ab2338ff3 kernel: add in_irq parameter to syscall::handle()
This parameter will determine whether a syscall is being handled from
within an interrupt context. This is because certain calls cannot be
called from such a context.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-01 16:27:39 +08:00
Sean Cross
719549a2cb xous: rename ReturnToParentI -> ReturnToParent
This syscall isn't the only one that can be called from an interrupt
context.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-01 16:26:19 +08:00
Sean Cross
d76832dada kernel: services: return ServerNotFound when server isn't found
This is more intuitive than `OutOfMemory`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 20:43:59 +08:00
Sean Cross
2244a78f16 kernel: allow syscall processing when printing is disabled
Due to a missing comment, syscalls wouldn't work at all when printing
was disabled. Fix this.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 20:43:22 +08:00
Sean Cross
6e312ffc8a kernel: process: only print process inits when printing is enabled
Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 20:42:57 +08:00
Sean Cross
e5003eee6d kernel: only print RISC-V exceptions when printing is enabled
Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 20:42:25 +08:00
Sean Cross
49d3ce8a6f kernel: syscall: unify print!() messages
Use `print!()` instead of `println!()` in order to make error messages
easier to read in the debug console.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:19:28 +08:00
Sean Cross
b3d918358e kernel: syscall: don't error on unaligned memory when Hosted
When running in a Hosted environment, unaligned memory is not an error,
so don't return `BadAlignment`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:18:50 +08:00
Sean Cross
95ab9d3c02 kernel: server: unify print messages
Don't use `println!()`, and instead prefer to use `print!()` when in the
kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:17:27 +08:00
Sean Cross
20a65b88f2 kernel: server: don't Forget Borrow and MutableBorrow messages
These should be returned to the client process after the message is
done, not forgotten straightaway.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:16:52 +08:00
Sean Cross
cb2d810b38 kernel: irq: prefix pagefault message with KERNEL(pid)
This unifies this message with other kernel messages.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:16:14 +08:00
Sean Cross
04a3493550 kernel: hosted: print status adding memory to return val
When returning memory to a thread, attach memory if present.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:15:32 +08:00
Sean Cross
74b3fde198 kernel: add memory from Results to network packets
If a Result contains attached memory, add that memory on to the network
packet that gets sent by the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:14:43 +08:00
Sean Cross
702676031e kernel: hosted: run rustfmt
Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:14:33 +08:00
Sean Cross
5f6b42d534 kernel: hosted: print pid of a process that exited
Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-30 10:14:02 +08:00
Sean Cross
fa9a3e0954 kernel: rework hosted network protocol
This fixes issues regarding passing memory between processes.

We now properly catch `ReturnMemory` and give the memory back.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-29 19:46:17 +08:00