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