Commit graph

924 commits

Author SHA1 Message Date
Sean Cross
6b5b4a5d21 kernel: services: don't crash when a process quits
When enumerating processes, the `find_process()` process didn't consult
whether a process was actually free. This resulted in a crash,
particularly when attaching a debugger to a crashed process.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
b95d442e20 kernel: debug: add "check memory" command
This command ensures memory is all owned by the correct process and is
unique in its ownership.

It takes a long time to run, so ensure the watchdog timer is disabled.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
e44d009b84 kernel: mem: add function for verifying mappings
Add a function to ensure mappings are unique across the whole system.
This takes a very long time and can crash if the watchdog timer isn't
paused.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:42:16 +08:00
Sean Cross
d5816b667a kernel: riscv: remove unsafe code from process
Remove transmutes from process.rs and replace them with ordinary casts.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:24:31 +08:00
Sean Cross
d4893c1c83 kernel: riscv: add phys_to_virt function
The phys_to_virt function can be used to determine what physical address
page is mapped to a virtual address page.

This throws an error when a page is mapped twice, which shouldn't
happen.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:23:19 +08:00
Sean Cross
124040bbb3 kernel: asm: align kernel stack to 16 bytes
The kernel stack offset should be aligned to 16 bytes. Previously it was
aligned to 8 bytes. It's unclear if this was the cause of any issues,
but it is best practice to keep things aligned to 16 bytes.

As part of this, key the atomic instructions off of the CPP macro
presence of atomic instructions.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:15:48 +08:00
bunnie
488d976f23 move original copy to new location, trying to preserve commit history 2023-12-27 15:04:27 +08:00
bunnie
336da86915 remove duplicate asm.S 2023-12-27 15:03:58 +08:00
bunnie
c2c56f9d3f fix typo in kernel feature specifier 2023-12-26 00:20:56 +08:00
bunnie
fda782663a bump version pins for xous change 2023-12-26 00:13:10 +08:00
Sean Cross
3658940260 kernel: add big-heap flag for running tests
When running Rust tests, a larger heap is needed. Add a kernel flag to
support this by default.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:35:37 +08:00
Sean Cross
006a50d206 kernel: mem: fix memory zeroing
Fix memory zeroing when requesting a physical pointer. Previously, only
the first 25% of a page was zeroed due to a bug when casting between
*mut u8 and *mut usize.

This now uses `write_volatile` to ensure the memory clear isn't
optimized out, and uses `usize` pointers everywhere.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:30:26 +08:00
Sean Cross
f2e9d2b76c kernel: riscv: threads: ensure registers are zeroed
The register set should be cleared already, however it is possible
(though remote) that register values are not cleared when a thread is
created.

Ordinarily threads are zeroed when destroyed, but this makes sure
they're zeroed upon creation as well.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:29:20 +08:00
Sean Cross
d798962151 kernel: format some files
Format some files prior to patching them.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-25 23:28:52 +08:00
Sean Cross
a19b1b4f51 kernel: use wfi() on Renode
While it would be nice if we stopped the PLLs as we do on hardware,
Renode does not yet have the ability to issue the `wfi` instruction from
a peripheral write.

As such, directly call `wfi()` on Renode similar to how Cramium
operates.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-24 15:20:11 +08:00
Sean Cross
0673ad912c kernel: gdb: don't panic when accessing kernel memory
Instead, just return 0x00000000.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-22 23:24:39 +08:00
bunnie
fa3f349a0a bump pins as xous-rs has changed 2023-12-01 21:20:01 +08:00
bunnie
6ab88117f6 bump xous-api-log version & fix version pins 2023-10-31 20:07:28 +08:00
Vihaan Jim
0a7a4fcfc1 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-10-14 14:45:50 -04:00
bunnie
d63b5912b1 absorb new xous-rs version 2023-10-10 16:50:00 +08:00
Vihaan Jim
e7445e1b62 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-10-05 17:17:26 -04:00
bunnie
83256257e1 bump xous-rs crate to absorb Send derives on Messages
this is necessary for the smoltcp port
2023-10-03 20:54:14 +08:00
Vihaan Jim
5dda363157 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-09-30 18:07:58 -04:00
bunnie
661b832d7e Merge branch 'cram-udma-uart' into main 2023-09-15 16:34:56 +08:00
bunnie
82c7b6ebed bring the versions up to date with main for a cleaner merge 2023-09-15 16:32:04 +08:00
bunnie
5116d51de5 move kernel UART to DUART port
using the DUART means we don't get console input on the kernel
(because the DUART is incapable of this) but it's a decent compromise
I think because the DUART is fast and efficient, and mostly we want
it to capture kps?

Eventually we'll need an input mode but for now, this will get us
moving.
2023-09-15 15:21:18 +08:00
bunnie
478a612c02 commit version bump 2023-09-12 16:25:10 +08:00
Sean Cross
5dfad296ae xous: mark MemoryRange::as_slice and friends as unsafe
Mark `MemoryRange::as_slice()` and `MemoryRange::as_slice_mut()` as
unsafe.

This is due to the fact that not all representable types can be cast to
an arbitrary value. For example, if Process A sends random values to
Process B, then Process B casts the memory to a slice of `bool`, then
any values that are not 0 or 1 are undefined.

Because these functions can leak UB into the program, they are marked as
unsafe.

This patch adds `unsafe {}` blocks to all instances where this function
is called. Additionally, all instances have been checked to verify that
they do not cast to any invalid types -- most use `u8` or `u32`.

Additionally, the long-deprecated `MemoryRange::from_parts()` call was
removed, since that causes UB without being marked as unsafe.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-09-12 10:07:38 +08:00
Vihaan Jim
41126ec57b Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-08-29 11:29:39 -04:00
bunnie
53469a68d0 publish package updates, sync to release tag 2023-08-08 14:35:49 +08:00
bunnie
b127cd093f bump version pins for change to xous-rs 2023-08-03 13:29:39 +08:00
Vihaan Jim
218e783053 Merge branch 'main' of https://github.com/betrusted-io/xous-core 2023-07-26 15:13:59 -04:00
bunnie
51278451a0 update version pins to pull in cramium target 2023-07-19 21:07:56 +08:00
bunnie
ca14ed78d2 fix renode build 2023-07-18 13:58:14 +08:00
bunnie
3c13516d57 kernel integrations for cramium 2023-07-17 18:49:21 +08:00
Sean Cross
e7cb72c478 kernel: services: remove unneeded muts
With Rust 1.71.0, mut detection has changed slightly, and it is more
aggressive about warning when things do not need to be mutable.

Remove these from the `services` file.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:28:21 +08:00
Sean Cross
cb32b31e18 kernel: support debugging interrupt handlers
SUpport debugging when interrupt handlers go awry, such as when they
blow out their own stack.

Do this by creating a dummy sentinal of 255 for interrupt handlers.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:26:15 +08:00
Sean Cross
85055052fd kernel: allow debugging panics in interrupt handlers
When an interrupt handler panics, restore the system and allow it to
continue. This will help to debug IRQ handlers that panic for one reason
or another, such as infinite recursion.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:22:47 +08:00
Vihaan Jim
dc9411669c Correctly set process.inner on riscv
This changes the process.inner.pid to the correct PID. Before, it was
simply 1. This lead to problems, for example when sending messages
where an assert checks to make sure that the current PID and the
process PID are the same. Now, you can send messages from a new process.
2023-07-04 15:22:44 -04:00
bunnie
4ac979f0ab update pins, again 2023-07-04 11:20:12 +08:00
bunnie
c9f8f2681b update version pins 2023-07-04 11:09:13 +08:00
bunnie
952ba18fba commit vesrion pin bumps 2023-06-16 01:30:18 +08:00
bunnie
fbe3cb2a3d bump package numbers to absorb PR #388 2023-05-28 15:58:11 +08:00
bunnie
a244b204cc
Merge pull request #388 from Foundation-Devices/syscall-virt-to-phys-pid
Add virt_to_phys_pid syscall
2023-05-28 15:52:57 +08:00
eupn
05d7f6a286
Add virt_to_phys_pid syscall
This syscall allows to obtain a physical address from a mapping of a specific process
2023-05-23 19:43:53 +04:00
bunnie
5a2df4432c technical debt: cleanup UTRA package
- make the "base" field no longer public. It is accessible, but only
through an `unsafe` method, because, it is unsafe.
- add accessors to offest/mask fields. Because, it's not at all
unsafe to access these, and it can be useful for bit-ops that are
not part of the generic set of UTRA.
- add Arc to AtomicCSR, and require `std` for AtomicCSR types.
This should not break anything, I checked inside @foundation-devices
keyOS and they don't seem to be using AtomicCSR anywhere.

The Arc makes it a bit safer to clone the AtomicCSR base pointer
and share it between threads, but it will have an impact on performance.
The USB stack (which requires AtomicCSR) was regression testing and the
impact seems minimal.

Recall that the main purpose of AtomicCSR is to provide a CSR accessor
that does not require a mutable reference to the base object. This
can make certain Rust idioms a bit cleaner. We wrap the base accessor
in Arc+Atomic to try and improve the safety of throwing the borrow
checker under the bus, but it's still not perfect because hardware
mutable state can have side-effects within hardware itself that cannot
be modeled or checked by Rust's borrow checker.
2023-05-23 18:11:24 +08:00
Sean Cross
b0ecc26002 kernel: gdb: batch 2- and 4-byte accesses
Instead of always doing bytewise accesses, support 2- and 4-byte access.
Additionally, recognize when multiple 4-byte reads are required.

Note that an additional optimization may be made here in the future to
prevent having to check every address, but this is left for a future
optimization.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-05-11 15:13:03 +08:00
Sean Cross
55d27cbf1b kernel: riscv: use SUM bit for debug visibility
Instead of remapping the page to allow the kernel to access a process'
memory, simply set the SUM bit. This makes it no longer an error for the
kernel to access userspace.

Keep setting the `W` bit when we poke, to allow for updating program
memory with breakpoints.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-05-11 15:11:17 +08:00
bunnie
697d44de3d bump version pins to absorb changes to svd2utra etc. 2023-05-03 23:11:12 +08:00
Jean-Pierre De Jesus DIAZ
66df563313
kernel: update rand to 0.8
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-05-02 12:50:56 +02:00
bunnie
8a574f937f bump for xous-rs version pin update 2023-04-27 22:18:30 +08:00
bunnie
fb710592b0 harmonize scripts around xpack distro (goodbye sifive) 2023-04-27 22:09:08 +08:00
Sean Cross
97da54437e kernel: allow debug of crashed processes
When a process crashes, report this in the kernel console and offer to
attach a debugger.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-20 13:06:02 +08:00
bunnie
cbbeaa27ad prevent overwriting current process ID in case of double-interrupt
this is part of #361, per @xobs
2023-04-12 23:14:09 +08:00
bunnie
849c136b90 bump versions because API crate changed 2023-04-12 23:02:30 +08:00
bunnie
b471b604d0 add option to print panics to screen on certain kernel panic events 2023-04-10 16:11:37 +08:00
bunnie
344dd5094b make the LCD panic handler Precursor-specific 2023-04-10 15:41:59 +08:00
bunnie
2903de5b7b
Merge pull request #363 from betrusted-io/lcdpanic
kernel: initial lcdpanic implementation
2023-04-10 15:31:02 +08:00
Sean Cross
31235c2547 kernel: initial lcdpanic implementation
Panic to the LCD when the kernel panics.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-10 14:42:59 +08:00
bunnie
cb875cf54e various fixes to gdb-stub
these are from @xobs via issue #361
2023-04-09 22:15:57 +08:00
Sean Cross
dbf28fbd61 kernel: use correct fake interrupt cause
Previously, we were creating a fake interrupt that was a "user software
interrupt". Update this to be a "supervisor external interrupt" to fix
hardware resume.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-09 15:31:06 +08:00
bunnie
8357ab31a5 bump all pins because utralib got updated 2023-04-09 00:48:35 +08:00
bunnie
9c94d6b4c0 bump versions because xous-rs API changed for gdb-stub 2023-04-08 23:49:24 +08:00
Sean Cross
6016f951ef kernel: gdb: unpause process on disconnect
Resume the debugged process when the debugger disconnects.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 14:34:13 +08:00
Sean Cross
916a0bde42 kernel: fixup gdb guardrails
The riscv target requires stepi to be implemented, which we now do.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 11:23:35 +08:00
Sean Cross
7c2ffbb34e kernel: implement gdb server
The gdb server runs on an additional serial port and provides
process-level debugging to the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
3469c292ec kernel: riscv: fixup exception debug handling
Debug handling was not correct, and didn't work at all. Additionally,
interrupt masking didn't work.

Fix these problems.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
eb33af53e0 kernel: gdb: break features into individual files
Since gdbstub is able to do this, break individual features into their
own files.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
fd71993b68 kernel: gdb: begin ext implementation
Implement the basics required to get "extended mode" working. This is
waiting on upstream to fix issues, but should allow us to attach to
processes once it works.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
ec97b3cdcf kernel: throw error when debugging invalid process
When debugging an invalid process (e.g. not yet run, terminated, etc.)
return an error rather than silently continuing.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
7b36f33ef9 kernel: gdbuart: disable IRQs during destruction
Disable IRQs during destruction, but only if constructed with
`GdbUart::new()`. This allows characters to buffer when the GDB bridge
is destroyed while avoiding the double-free error we were getting from
creating a new UART in the IRQ handler.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
a34733e5e9 kernel: basic version of gdb serevr
This adds a basic gdb server. Currently, it is possible to list
processes and inspect memory and threads. It is not yet possible to
actually interact with code (e.g. no breakpoints and no single
stepping).

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:48:45 +08:00
Sean Cross
13029a76a2 kernel: initial gdb-stub reimplementation
Add an initial reimplementation of the gdb-stub using the gdbstub
backing crate.

This supports process enumeration and basic thread investigation.
Processes will pause when the debugger is inspecting them. Memory and
registers can be investigated. Threads can be listed and selected.

It does not yet support breakpoints.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:45:42 +08:00
Sean Cross
e48c108288 kernel: riscv: fix disable_irq when irqs are disabled
Previously, `disable_irq()` would unconditionally mask an interrupt in
the `sim` register. However, when interrupts are disabled this register
is zero, and we really should be updating `SIM_BACKING`.

Consult the state of the interrupt handler and update the appropriate
field as necessary.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:46 +08:00
Sean Cross
02065a6a0b kernel: make disable_irq() infallible
This function never failed. Make it infallible so that it matches the
same calling convention as `enable_irq()`

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:46 +08:00
Sean Cross
787d77fcbd kernel: implement FreeInterrupt
This syscall is the opposite of ClaimInterrupt.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-06 10:42:45 +08:00
eupn
90df83f885
kernel: revamp IRQ handling 2023-04-05 16:35:01 +04:00
bunnie
e469eba167 bump version for utralib patch 2023-04-04 02:13:02 +08:00
bunnie
704aaf98af bump versions for kernel interface changes 2023-03-22 02:48:55 +08:00
bunnie
488a220d43
fix URL to public URL
didn't know i could just edit this directly in GH!
2023-03-22 01:05:10 +08:00
eupn
723a730231
kernel: fix warnings 2023-03-14 19:01:11 +04:00
eupn
e2d34d364c
kernel: always print when process is terminated 2023-03-14 18:48:45 +04:00
eupn
1634243f63
kernel: fix compile errors 2023-03-14 18:48:15 +04:00
eupn
7f5656445a
kernel: change some println!s to klog!s
Even when the print-debug feature isn't turned on, println! macro is still able to output some critical non-debug info to the console such as panics, process crashes and violations, etc. Debugging messages are printed with klog! macro that's disabled when debug-print feature is not set.
2023-03-14 18:47:57 +04:00
eupn
89a1447df4
kernel: checkout arm assembly binary 2023-03-14 18:41:45 +04:00
eupn
a42366b6cf
kernel: add arm to asm scripts 2023-03-14 18:41:33 +04:00
eupn
618392ca52
kernel: add arm features and deps to Cargo.toml 2023-03-14 18:39:19 +04:00
eupn
10bffc55b6
kernel: update build script to pick arch specific linker and asm binary 2023-03-14 18:37:40 +04:00
eupn
434e865a45
kernel: add sama5d2 uart workaround 2023-03-14 18:36:41 +04:00
eupn
0953812dfc
kernel: hide hw specific details in process init 2023-03-14 18:35:12 +04:00
eupn
3451d106f9
kernel: update debug and shell modules 2023-03-14 18:32:52 +04:00
eupn
38a02f9dbb
kernel: split precursor and sama5d2 platform modules 2023-03-14 18:30:07 +04:00
eupn
2ecd91b3c5
kernel: split arm and riscv arch modules 2023-03-14 18:28:49 +04:00
bunnie
303f595d6f bump versions to cleanup renode.rs sync issue 2023-03-14 16:34:53 +08:00
bunnie
82e3aa322f bump toml files in prep for publish 2023-03-08 03:54:37 +08:00
bunnie
73aa6c3b14 cleanup hosted mode warning 2023-02-15 20:35:32 +08:00
bunnie
6563ad174e bump revision 2023-02-15 20:35:16 +08:00
bunnie
fced4608b6 bump kernel package rev 2023-02-15 20:26:30 +08:00
bunnie
08ae66a264 fix: #320
this commit adds the facilities to extract eh_frame[_header]
sections and pass it to each process.

A bump is required to `std` to extract the passed parameters.
2023-02-15 19:55:08 +08:00
bunnie
80f031b7e7 bump kernel version 2023-02-12 12:58:42 +08:00
bunnie
4a2234f539 XIP works with some processes, but not others
it works with e.g. shellchat, but not vault.

still scratching my head on what's gone wrong -- it's
crashing in the pre-boot, which means something is not
mapped right for some case that wasn't caught in the
earlier testing.
2023-02-11 01:42:04 +08:00
bunnie
053bc8a06f bump kernel rev 2023-02-03 00:12:57 +08:00
Sean Cross
dc097e32d8 kernel: fix atomic operations
Atomic operations were previously broken. RISC-V breaks atomic
operations into multiple instructions, and there is some state kept
between those instructions. This state is not visible, and is internal
to the processor.

We were ignoring this state, which resulted in inconsistencies
throughout the system. The following sequence was possible:

1. A thread loads a value, and obtains the `reservation set`
2. A context switch happens on the following instruction
3. A different thread loads the value, modifies it, and continues
4. A third thread (or a different process) loads a value and obtains the
   `reservation set`
5. The original thread runs, sees the `reservation set` is held, and
   updates the value, clobbering what the second thread did in #3

A workaround for this is to perform a dummy `sc` as part of the context
switch. This invalidates any atomic operations that may be pending.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-02 23:10:12 +08:00
bunnie
8b7876360f bump kernel package version 2023-02-01 22:45:37 +08:00
Sean Cross
043365ac82 kernel: re-add set_last_thread
git somehow dropped this function during the merge, which would have
made things very sad.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 20:45:43 +08:00
Sean Cross
c7f5ad25b1 kernel: syscall: fix restoring thread id
The previous patch didn't properly restore thread IDs when switching
contexts -- there were spots where we missed things, and spots where we
were double-borrowing.

Fix these corner cases.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 20:43:45 +08:00
bunnie
680ddd1c58
Revert "Give servers their full quantum" 2023-02-01 14:08:16 +08:00
bunnie
119296ed5b
Merge pull request #314 from betrusted-io/messages-late-return
Give servers their full quantum
2023-02-01 13:46:01 +08:00
Sean Cross
63e6deae53 kernel: save current thread at context switch
Note the current thread in the original process when its quantum
expires. This will allow us to clean up after ourselves when a context
switch occurs, and will help to prevent thread starvation.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 10:46:25 +08:00
Sean Cross
4ec43363f5 kernel: don't always context-switch on message return
Currently, returning a Message (e.g. a Scalar1, Scalar2, or
MemoryMessage) always results in a context switch from the server to the
client. This is what makes these syscalls cheaper.

However, this results in process starvation. For example, if three
processes send a message to a server, then the server will only be able
to respond to one of those messages at a time. This works well with a
lightly-loaded system, but quickly falls apart when many threads are
running.

Keep track of which process and thread were originally switched to as
part of the `SwitchTo` call. If the Server is responding to a message
and owns the current quantum, don't immediately switch to the Client
thread.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-01 10:19:07 +08:00
bunnie
cc97f157e4 bump kernel rev for publication 2023-01-31 16:10:53 +08:00
Sean Cross
1303e6416d kernel: fixup current_thread==0 on resume
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>
2023-01-31 16:01:35 +08:00
Sean Cross
abb1455fe6 fix previous commit
Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-31 15:51:31 +08:00
bunnie
d5b5a83445
Merge pull request #311 from betrusted-io/unify-kernel-scalar-return
Unify kernel scalar return
2023-01-31 15:48:59 +08:00
bunnie
9256e7cc09 bump versions to absorb xous-names fix 2023-01-31 15:07:32 +08:00
Sean Cross
778e217de8 kernel: unify scalar return calls
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>
2023-01-31 14:46:38 +08:00
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
84368c3f3a bump versions for publication 2023-01-31 02:18:12 +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
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
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
bunnie
232a4b6c6c bump xous version 2023-01-18 00:02:46 +08:00
bunnie
b275660a71 add an "endcap" to the kernel region
This works around https://github.com/SpinalHDL/VexRiscv/issues/296
2023-01-17 23:07:05 +08:00
bunnie
3417046e7b cleanup memset command a bit more
- we don't need a general memset call -- just a zero page call
- use native rust semantics to embody the call. some alignment checking is
done on the arguments on the way in and out that seem worth it
- the unrolled loop doesn't pay off because we're at the limit of
write bandwidth on the CPU at this point. we would need write-back
caches to gain more performance through unrolling.
2023-01-17 23:05:20 +08:00
bunnie
7be4a88a9b fix scheduler bug (credit: @xobs)
@xobs found a scheduler bug that would trigger a runnable process
search every time a scalar message returned. This fixes the problem,
causing the quantum to go back to the caller as intended.

Improves performance on the syscall by about 40%.
2023-01-17 02:11:48 +08:00
bunnie
aa48476937 Unroll loop for initializing memory in kernel
This also changes the initialization method from using `u8`
to `u32`.

The loop is unrolled to one iteration per cache line.
2023-01-17 02:10:46 +08:00
bunnie
bb5d7b3adf bump versions to absorb hosted mode fix 2023-01-05 14:07:24 +08:00
bunnie
64fa83cec4
Merge pull request #290 from betrusted-io/reply-and-receive-next-syscall
Fix ReplyAndReceiveNext for hosted mode
2023-01-05 13:56:24 +08:00
Sean Cross
3593d715c1 kernel: fix memorymessages with ReplyAndReceiveNext
Fix a segfault that occurred when using ReplyAndReceiveNext on hosted
mode. This now properly passes memory messages back to the client.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-01-05 11:56:15 +08:00
bunnie
36398810dd bump version numbers to absorb new syscalls 2022-12-30 15:24:36 +08:00
Sean Cross
3218bde2b4 kernel: implement reply_and_receive_next
Implement `ReplyAndReceiveNext` as a syscall. This will reply to a
message, pull the next message out of the queue, and then re-queue the
server to run. This should make servers much more responsive.

This patch has been tested on both hosted and native modes.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-30 11:07:04 +08:00
Sean Cross
ab0c7d3b32 kernel: server: check buf is some when returning mem
Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:03:39 +08:00
Sean Cross
46f340324d kernel: rename Message -> MessageEnvelope
This syncs with the latest changes to `xous-rs`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:02:57 +08:00
Sean Cross
911ddb60fc kernel: debug: fix klog on baremetal
klog() refers to an outdated `.uart` struct, which has since been
renamed to `.serial`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-12-29 21:01:27 +08:00
bunnie
5370ce396d bump all revs due to SoC artifact update 2022-12-12 16:07:20 +08:00
bunnie
1d1b3a35b7 commit version bump 2022-11-26 10:00:44 +08:00
bunnie
aa9977cc58 bump all the things because we changed utralib again 2022-11-17 22:13:40 +08:00
bunnie
dabbfd6c35 bump all the things to absorb the SoC change 2022-11-17 19:39:18 +08:00
bunnie
30583bdf07 bump versions with xous change 2022-11-06 03:48:12 +08:00
Sean Cross
da5647539f kernel: syscall: add support for return_scalar5
Add kernel support for returning 5 scalars.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-11-05 18:39:54 +08:00
bunnie
0c52a7a3ff the merge requested pulled multiple other crate versions backwards
this fixes it, hopefully.
2022-11-03 01:58:36 +08:00
bunnie
6332bf1c90
Merge branch 'main' into driver-refactor 2022-11-03 01:53:23 +08:00
bunnie
80094aef1e I see what's happening. The PR originator versions are very out of date.
hopefully this fixes the issue.
2022-11-03 01:49:28 +08:00
bunnie
bbb7e279cd bump kernel version (this time with feeling) 2022-11-03 01:42:59 +08:00
bunnie
ba46c6b04a bump kernel version 2022-11-03 01:41:24 +08:00
Jean-Pierre De Jesus DIAZ
d8807e6cea
kernel: Move rand driver to platform module.
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-11-02 14:36:41 +01:00
Jean-Pierre De Jesus DIAZ
b334e5bc31
kernel: Split debug shell and uart driver.
I've added a `platform` module to store all platform specific code, (not
architecture specific) as some platforms will require custom drivers, e.g.
for debug output and for the random number generation code.  The platform
code is in charge of mapping any peripherals needed to work, also to
initialize any other parts of the kernel that require drivers, for example
the debug shell.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-11-02 14:30:31 +01:00
Tom Marble
9689b3bc07
Removes VS Code artifacts
Also updates .gitignore to prevent adding IDE (VS Code, Emacs) artifacts

Signed-off-by: Tom Marble <tmarble@info9.net>
2022-10-28 11:23:56 -05:00
bunnie
f01b2a871c add some vscode stuff i guess to the release 2022-10-28 18:12:07 +08:00
bunnie
f17e02460f bump kernel revision 2022-10-28 18:02:52 +08:00
Sean Cross
c17a6d3786 kernel: make SYSTEM_SERVICES unmangled
This symbol will be viewed by external tools.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-28 17:38:25 +08:00
bunnie
ba28dd8795 bump to absorb utralib straggler configs 2022-10-28 15:11:17 +08:00
bunnie
dfb10ed7f2 bump crate numbers to publish lang-fr change into xous-rs 2022-10-28 14:01:09 +08:00
bunnie
cc873919f5 fix dangling kernel dep 2022-10-25 23:08:50 +08:00
bunnie
0ee9ec1d80 bump version numbers for crate publication 2022-10-25 22:38:58 +08:00
Jean-Pierre De Jesus DIAZ
f5176ea380
Remove xous-rs unused features
The rationale is that xous-rs should have only architecture
specific code, e.g.: riscv, arm, x86, etc. To make other
crates that depend on it not specify the features.

This could be useful when using xous-rs with `libstd`
for example.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-10-25 13:29:15 +02:00
bunnie
d331d405ee bump version numbers for publication 2022-10-25 17:23:40 +08:00
bunnie
805a7d528c flip back to using remote references 2022-10-20 16:30:06 +08:00
bunnie
8e05925cfa somehow the transition to local paths got missed in the merge 2022-10-18 00:39:01 +08:00
bunnie
0584ad2f2c switch to local paths to see if this helps the build 2022-10-18 00:26:56 +08:00
bunnie
4b368d71db bump versions of crates 2022-10-15 01:31:54 +08:00
bunnie
63a87ca1bc bump all the versions 2022-10-14 16:54:43 +08:00
bunnie
ff30131f43 absorb more fixes into the kernel 2022-10-13 04:08:56 +08:00
bunnie
51752aac9d
Merge pull request #239 from Foundation-Devices/baremetal
Use CARGO_CFG_TARGET_OS in build scripts.
2022-10-12 12:56:17 -07:00
bunnie
3503965f98 bump versions to absorb xous-rs changes 2022-10-13 03:41:16 +08:00
Jean-Pierre De Jesus DIAZ
955fbc8788
xous: Use CARGO_CFG_TARGET_OS in build scripts.
This allows for a more reliable detection of target_os configuration
in build scripts. The target is inconsistent between some architectures,
notably armv7a is `armv7a-none-eabi` skipping the `unknown` (the vendor,
I guess) part. This happen with some of the unrelated Cortex-M targets
present, and others may also be.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2022-10-12 19:03:46 +02:00
bunnie
94aa4b62b1 forgot to bump kernel version 2022-10-10 03:09:27 +08:00
bunnie
02b80425f5 bump xous-rs to absorb change in language specification 2022-10-10 03:07:44 +08:00
bunnie
3bca9de2a0 bump version numbers for xous-kernel patch
this fixes tests in CI
2022-10-05 23:51:35 +08:00
bunnie
969f93b001 cross-repo update versions from xous-rs bump 2022-10-05 18:32:44 +08:00
bunnie
5c6dc80249 xous-rs change bumps kernel rev 2022-10-05 17:33:25 +08:00
bunnie
d699ddf998 also move utralib change into kernel, update cargo.lock 2022-10-02 02:21:27 +08:00
bunnie
df96605531 update utralib reference 2022-09-29 22:22:33 +08:00
bunnie
96300db925 add license to kernel Cargo.toml 2022-09-27 18:43:39 +08:00
bunnie
c9f3d6a3d5 bump utralib ref in kernel so it works with the renode target 2022-09-27 18:32:04 +08:00
bunnie
ab940e18db fixup warnings 2022-09-27 17:27:21 +08:00
bunnie
755556611c prep kernel for packaging
- strip out gdb-stub. Per xobs, the feature never worked, and it
depends upon a branch of a git repo which is not allowed by crates.io
Since the feature hasn't been developed, and crates.io will not
allow even an optional feature that points to a git repo, the feature
was stripped out.

- rename "kernel" to "xous-kernel", so that we can live in a crates.io
package namespace that is specific to Xous.

still have to figure out the riscv package issue.
2022-09-27 17:02:20 +08:00
bunnie
57673052bf pass the v2p dependency onto xous-rs when it's activated in the kernel 2022-09-15 19:17:00 +08:00
bunnie
ea37ce2ea1 add feature gate on v2p per xobs' request 2022-09-15 14:06:07 +08:00
bunnie
6d9848c239 add virt_to_phys syscall
this will help speed up performance profiling as we can
resolve the physical address of the performance buffer allocated
in RAM and use a USB command to read it out, instead of streaming
it over serial.
2022-09-14 18:09:13 +08:00
Sean Cross
c9d5074dd2 kernel: riscv: use pointers for pagetable entries
Instead of passing a constructed mutable ref from the pagetable entry,
pass a raw pointer and use `read_volatile()` / `write_volatile(x)` on
this pointer.

This should remove a little bit of UB from the kernel.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:46:54 +08:00
Sean Cross
426fe4b91f kernel: riscv: don't crash when mapping invalid memory
Previously, the kernel would dutifully try to map memory that was in the
kernel space. It did this by investigating the kernel memory offset,
which immediately causes a double-fault.

Check to make sure a userspace process is not trying to map kernel
memory before checking the valid page.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:45:08 +08:00
Sean Cross
dcc964c3c1 kernel: riscv: use klog for memory exception printing
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-30 19:44:06 +08:00
Sean Cross
748d4ce87d Merge remote-tracking branch 'origin/main' into libstd-fs 2022-06-27 09:14:04 +08:00
Sean Cross
581603b205 kernel: services: fix compile error when debugging enabled
Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-26 16:45:41 +08:00
Sean Cross
08958745ba kernel: implement AdjustProcessLimit syscall
Implement the syscall to adjust a process' limit. Currently this
only supports adjusting the heap maximum and the heap size.

In order to adjust a limit, you must first present the current limit.
This can be obtained by requesting a bogus value. The current limit is
returned as part of the result.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-24 00:09:35 +08:00
bunnie
6793f9c5da return non-0 heap size in case of increaseheap of 0
this allows hosted mode to work, as it always reports a 0
heap size.
2022-06-17 02:00:52 +08:00
bunnie
7456158fa9 remove custom ditherpunk flag from kernel
we can now do per-process stack size adjustment
2022-06-16 03:39:25 +08:00
Sean Cross
c6c9a26bf9 kernel: syscall: return heap size for DecreaseHeap
Return the heap size and offset when decreasing the heap. Additionally,
return the heap size when increasing the heap by 0 bytes.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-15 12:35:34 +08:00
bunnie
c687f7dc02 add a kernel feature flag so we can adjust stack size for ditherpunk
Don't want to make the stack size adjustment across the board
because it's helpful for managing/checking bloat as it happens.
2022-06-14 17:08:32 +08:00
bunnie
e32ea4d3f5 fix #174 2022-06-10 21:36:53 +08:00
Sean Cross
a1474b3e40
Merge pull request #166 from codemaster138/patch-1
chore: fix typo in build.rs
2022-06-10 19:42:39 +08:00
bunnie
2f096c1435 remove kernel Cargo.lock file
This is no longer  used since we moved to a monorepo. This also
removes some stale dependencies.
2022-06-07 14:10:54 +08:00
bunnie
aad8391a3e remove stale crossbeam-utils entry from Cargo.lock
unused lock dependency refers to a vulnerable version of
crossbeam-utils.
2022-06-07 14:06:01 +08:00
bunnie
09a968ef09 remove debug-here dependency
this contains a dependency to `failure` two levels down that has a critical
vulnerability. Unfortunately no new versions of debug-here have been
published in a while. It's no longer used, so just stripping it out
altogether.
2022-06-07 14:00:25 +08:00
Sean Cross
8edf03a243 kernel: fix warning in hosted mode
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 11:18:43 +08:00
Sean Cross
75e855cc4d hosted: fix hosted mode after CreateProcess addition
Hosted mode spawns processes very differently, and this difference was
not reflected after changes were made to native mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-30 13:41:05 +08:00
Sean Cross
a241d89b5b kernel: ignore "ppid unused" warning for now
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:41:13 +08:00
Sean Cross
4250d5bb10 kernel: re-disable verbose kernel messages
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:39:45 +08:00
Sean Cross
9aa83bbfb5 kernel: unmap child process pages after setup
Unmap the pages from the child process after we're done setting them up.
This ensures they're not still aliased by our process, despite being
marked as "owned" by the other process.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 19:38:22 +08:00
Sean Cross
a2e57195ba kernel: implement CreateProcess for riscv
Implement a functioning CreateProcess syscall on riscv. This call
creates a server in the child process, and connects the server to the
parent. The parent can communicate with the child process using this
server.

The Server ID is passed as four `u32` values to the entrypoint function.
This can be reassembled into something that can then be passed to the
`ReceiveMessage` syscall.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-29 18:47:37 +08:00
Sean Cross
2e69ae8a12 spawn: compiles, but does not work yet
Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-28 05:10:48 +08:00
Jake
ac8b3acbd7
chore: fix ypo in build.rs 2022-05-26 17:53:33 +02:00
Sean Cross
d8eb7be352 process: finish implementing ProcessStartup as return
We now us `ProcessStartup` as the return type. This builds in tset
mode, hosted mode, and RISC-V mode.

Process Startup is still not implemented for RISC-V mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-28 22:43:42 -04:00
Sean Cross
6d294c97c5 kernel: print connection count on per-process output
Signed-off-by: Sean Cross <sean@xobs.io>
2022-04-05 15:11:47 +08:00
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
Aaron Bieber
6f98940189 Switch to using env to find the path to bash.
Systems like OpenBSD and NixOS have bash in different locations. This
allows the various scripts to be run on those systems.
2022-03-28 16:43:47 -06: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
a4a7f4af69 fix hosted build 2022-01-18 00:32:12 +08:00
bunnie
e8e389552f add map generation to the loaders 2022-01-17 00:04:03 +08:00
Sean Cross
7cd86b4fcf Merge branch 'main' of github.com:betrusted-io/xous-core into kernel-monorepo
Signed-off-by: Sean Cross <sean@xobs.io>
2022-01-14 15:33:10 +08:00
Sean Cross
35af35381a kernel: integrate kernel into main monorepo
This moves the kernel into the main monorepo, allowing it to share
packages with the rest of the system. This change will allow us to
reduce the number of rebuilds that take place, as well as reducing disk
usage.

Note that the loader is still an indepenent project, and the integration
of that into the monorepo is pending.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-01-14 15:31:36 +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
b3788a54af clarify the dependency policy 2022-01-10 16:50:10 +08:00
bunnie
995915ed4e nail down a couple more dependencies, and add a policy note to Cargo.toml
Each Cargo.toml now includes a comment which remnids maintainers
of the dependency policy for Xous (that is, nail down every dependency
to the minor number).
2022-01-10 15:54:27 +08:00
bunnie
d06d58b132 harmonize rand crate to 0.7.4 (version used by ed25519-dalek) 2022-01-10 15:03:23 +08:00
bunnie
4819703d20 trim unnecessary sha3 dependency 2022-01-10 14:59:41 +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
0ae6d1460a kernel: update version of gdbserver
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-25 16:05:56 +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