Sean Cross
11994d325b
kernel: test: add test for server_client_same_process
...
This is part of `multiple_contexts`, but it's nice to have an explicit
test for this functionality.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-16 10:22:26 +08:00
Sean Cross
1216963d24
rename contexts -> threads and spawn -> create
...
This ensures we're more consistent in naming for these constructs.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-16 10:17:46 +08:00
Sean Cross
ba7bb29ce2
kernel: don't block on full queue for Scalar/Move msgs
...
For Scalar and Move messages, the client does not need to block if the
server does not have any waiting messages. In this case, send an `Ok`
response.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-16 10:16:42 +08:00
Sean Cross
506d01fe4a
kernel: test: use server_address() to create fn as_process()
...
This allows us to spawn a new process and set the server address
transparently.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-16 10:04:50 +08:00
Sean Cross
fb32aab691
kernel: testing: move memory profiling into its own test
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-15 21:24:18 +08:00
Sean Cross
bf15ac08f4
kernel: tests: add memory measurement to test suite
...
This adds a feature to enable memory measurement, so we can determine if
we're leaking memory anywhere.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-15 17:08:05 +08:00
Sean Cross
e652150c6e
kernel: get multiple message passing working
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-15 16:09:42 +08:00
Sean Cross
0ffbaa369a
kernel: fix remaining warnings
...
This just silences them, which isn't great in the long run.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 15:16:51 +08:00
Sean Cross
b93abcc926
kernel: test: implement mutable borrow
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 15:10:25 +08:00
Sean Cross
d7006e675e
kernel: get send_borrow_message test working
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 12:11:57 +08:00
Sean Cross
964b6e0f46
kernel: disable more debug prints
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-14 10:08:49 +08:00
Sean Cross
05d1cf71dc
port: use kernel-assigned port number for tests
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 19:57:30 +08:00
Sean Cross
b388d2e1f4
kernel: use SocketAddr instead of &str
...
This is easier to copy around and seems to be more informative.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 19:45:29 +08:00
Sean Cross
8f74159674
rename ImmutableBorrow -> Borrow
...
THis is more in-line with Rust conventions.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 19:19:25 +08:00
Sean Cross
85c719643a
kernel: tests: factor out common connect code
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 19:15:51 +08:00
Sean Cross
05ccba9450
kernel: implement move test
...
We can now `Move` memory from one "process" to another.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 18:31:51 +08:00
Sean Cross
40ed6365e2
first memory message works
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-13 17:41:50 +08:00
Sean Cross
acf9b049f7
hosted: start working on memory-based message passing
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-12 11:18:26 +08:00
Sean Cross
e1a92e929c
kernel: replace more unimplemented!() with UnhandledSyscall
...
This should prevent pacnics when calling unhandled functions.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-04 11:58:18 +08:00
Sean Cross
acfe8e5076
kernel: fix pid termination
...
Previously, we were recycling PIDs when devices disconnected, however we
weren't cleaning up PIDs within the system-level table.
This now cleans up these entries.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-25 18:15:36 +08:00
Sean Cross
9f1b1e7ec8
kernel: tests: get both tests working
...
We now have two tests. These tests may be run either in parallel or in series.
If they are run in parallel, then they will each have their own thread
local storage, and each will initialize things from scratch.
If they are run in series, then the thread local storage will be reused
between the two processes.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-25 17:41:17 +08:00
Sean Cross
54a0db50b3
kernel: start using tls
...
This allows us to run multiple kernels in parallel.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-24 17:51:31 +08:00
Sean Cross
abcba48a2a
kernel: add tests
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-24 12:29:04 +08:00
Sean Cross
04faa898c7
hosted: cutting down on println messages
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-23 16:40:51 +08:00
Sean Cross
cbd8ec3a30
test: get message passing working
...
We are now able to pass messages around as part of a test.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-23 15:47:18 +08:00
Sean Cross
e9469991be
test: get initial test passing
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-23 14:42:01 +08:00
Sean Cross
b1a41978ba
shutdown: add shutdown syscall
...
This will be used during testing to shutdown the kernel once it's
finished.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-23 13:58:15 +08:00
Sean Cross
14bb1ac1e5
kernel: working on getting process termination functioning
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-22 17:42:24 +08:00
Sean Cross
9361055aec
kernel: work-in-progress for process termination
...
Processes can go away. This is initial work to support process
termination.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-18 11:39:46 +08:00
Sean Cross
2786ad697b
kernel: get scalar message passing working again
...
This gets basic scalar message passing working again. With this, the
following operations may be performed:
* Starting a server
* Connecting to a server
* Sending a scalar message
Care must be taken to not overflow a server's queue, particularly if
writers are faster than readers.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-16 16:34:49 +08:00
Sean Cross
723529ba20
wip: working on getting message passing working
...
The goal is to get a basic message passing engine working that will also
function as a device that works on real hardware.
This is still reworking it to function correctly on a desktop system.
Once that is working, it will be reworked to function once again on
hardware.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-15 18:13:10 +08:00
Sean Cross
21c46de60e
kernel: move to allow hosted init
...
This prepares for new calls to init SystemServices and the MemoryManager
so that they can be initialized with something other than a
KernelArguments struct.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-03 18:28:22 +08:00
Sean Cross
17ae34a1c1
kernel: begin actor refactor
...
This refactors the kernel so that it *can* run on baremetal, but it can
also run as part of a full system.
This will aid in developing, and ensure that a minimum amount of unsafe
code is present within the kernel.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-03 15:34:55 +08:00
Sean Cross
d4db20e516
kernel: add preemptive multitasking
...
This is still a work in progress, but we now can have multiple processes
running at once.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-06 15:52:07 +08:00
Sean Cross
a1c88b4ffd
kernel: remove old code at top of syscall::handle
...
This was pseudocode from back before we had a better idea of how
everything would be laid out.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-06 10:44:41 +08:00
Sean Cross
1f478925ce
kernel: return context on failure
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-06 10:43:26 +08:00
Sean Cross
fd5cc8a1f0
kernel: implement mutable borrows
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-03 14:23:49 +08:00
Sean Cross
48717d3870
kernel: return a MessageResult after sending a message
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-03 14:23:15 +08:00
Sean Cross
9c5cb3da32
kernel: properly share pages between processes
...
This improves page sharing. Permissions are retained during sharing,
and we should now be able to share multiple pages. Additionally, this
lays the groundwork for mutable sharing.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-03 12:28:44 +08:00
Sean Cross
ed977fd564
kernel: initial work to support lending pages
...
This lays groundwork to support lending pages from one process to
another, and to restore permissions when pages are handed back.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-02 17:40:14 +08:00
Sean Cross
bedb499edb
kernel: get immutable borrows working
...
We can now pass memory immutably between processes
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-01 17:27:59 +08:00
Sean Cross
d6f985c141
syscall: add call to return memory from a message
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-01 13:21:23 +08:00
Sean Cross
bdb8eac9ad
MemoryRange: move to using this struct for memory ranges
...
This is a combination of MemoryAddress and MemorySize. This is
guaranteed to be not null.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-01 10:28:36 +08:00
Sean Cross
a947d7fd79
kernel: clean up most warnings
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 18:37:19 +08:00
Sean Cross
b61f1518d0
kernel: syscall: implement UnmapMemory
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 18:37:08 +08:00
Sean Cross
abce9eb0c1
message::move: implement movable messages
...
This is the first implementation of message passing with moving memory.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-31 18:03:19 +08:00
Sean Cross
8c3f931445
messaging: first message passing example
...
THis commit allows us to pass Scalar messages between processes.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-30 16:07:58 +08:00
Sean Cross
f56b5e969d
server: use CtxID type instead of usize
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-30 12:35:50 +08:00
Sean Cross
9367905e6f
kernel: services: don't resume sleeping processes after irq
...
After an IRQ occurs, check to see if there are any available threads.
If there are none, put the process back to sleep.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 17:05:37 +08:00
Sean Cross
263e57d4aa
kernel: disable lots of debug output
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 16:59:46 +08:00
Sean Cross
6b729d9ebc
kernel: services: resume correct context after interrupt
...
We were resuming the wrong context after returning from an interrupt.
This resulted in us resuming context 3 more often than not.
This now properly banks the current process context prior to the switch.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 16:58:04 +08:00
Sean Cross
da2036a182
kernel: services: minor documentation improvements
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 16:22:17 +08:00
Sean Cross
cfe7c4a3bc
kernel: irq: take() previous process pair
...
This prevents us from continuously resuming the same task
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 16:21:46 +08:00
Sean Cross
beea92ddab
kernel: fix context id assignment
...
previously, we were assigning the trap context as a valid ID. This is
not valid, and causes many problems.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 15:58:59 +08:00
Sean Cross
dafec2bb89
kernel: make contexts first-class
...
Due to an initial misunderstanding of how the RISC-V is architected,
contexts were going to be an emergent property of the kernel.
However, after further consideration, contexts must now be baked into
the kernel. Switching between contexts can be handled by the scheduler,
but the kernel must keep track of processor registers.
Keep track of context IDs and ensure they are sane. With this patch,
interrupts work, as does basic context switching.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 12:30:29 +08:00
Sean Cross
2ba9f69015
kernel: fix build error in main.rs
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-25 14:09:17 +08:00
Sean Cross
a723fb6a02
kernel: reflow multiple files' comments
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-25 14:07:46 +08:00
Sean Cross
fa22d9bad8
kernel: fix isr context handling
...
We were loading both the context and the banked context, which resulted
in an invalid context being selected. This caused a cascading failure.
Load only the lower halfword in order to correctly enter the interrupt
context.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-24 15:24:19 +08:00
Sean Cross
fb01359821
server: fix Connect() call
...
This fixes the index in the Connect() call, so that clients can now
Connect to servers that exist.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-24 14:52:25 +08:00
Sean Cross
e298f125c9
kernel: rework server structures
...
They are now inverted and mvoed into their own file.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-24 14:13:11 +08:00
Sean Cross
484e21fd30
messaging: more work on transferring messages
...
Still need to work on passing messages.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 16:56:56 +08:00
Sean Cross
569a4196de
kernel: return a Result from syscall::handle
...
This will simplify error handling.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 14:07:54 +08:00
Sean Cross
f32596570f
services: don't map messaging region to userspace
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 12:59:48 +08:00
Sean Cross
fb69426f28
kernel: riscv: print "SYSTEM HALT" when halting system
...
This minor patch helps me remember that these errors are fatal.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 12:59:09 +08:00
Sean Cross
0be1b8b94c
kernel: mem: don't unilaterally hand memory to userspace
...
If it's needed for use in the kernel, don't hand it over.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 12:58:13 +08:00
Sean Cross
a31c4722fa
kernel: add space for message reply pointer
...
With this, we now have enough space to store the return context
information for when `message_reply()` is called.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-23 09:10:19 +08:00
Sean Cross
33162a1c1f
services: implement basics of ReceiveMessage
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-20 17:21:34 +08:00
Sean Cross
ae473b5aa7
kernel: broken commit: add server message polling
...
This [broken] commit starts to add message polling to the kernel, so a
server can use the MessageReceive call.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-19 17:25:12 +08:00
Sean Cross
04eb18e2fb
kernel: add Connect stub
...
It doesn't respond, but it prints a message now at least.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-19 08:54:52 +08:00
Sean Cross
ebe3efc097
kernel: properly zero out pages prior to handing them to userspace
...
Until now, we were relying on luck to ensure pages were zeroed.
However, now we properly zero pages in the kernel before handing them
off to userspace.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-17 11:35:38 +08:00
Sean Cross
85522602ea
kernel: silence warnings and remove excess prints
...
These prints were used to debug errors in the new process switching
architecture.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-16 19:03:10 +08:00
Sean Cross
022bedc8e3
kernel: refactor processes to support banking
...
We now have a concept of context banking. When an interrupt fires, the
process context is banked.
As part of this, process-level data is now stored in the page within the
process itself. This reduces memory consumption and allows us to have
features such as a hash within each process itself.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-16 18:22:59 +08:00
Sean Cross
fcdc0da19f
kernel: use upstream riscv crate
...
Now that this is published upstream, we can remove our dependency on a
particular git version.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-16 08:42:32 +08:00
Sean Cross
99d19866cf
kernel: mem: zero out memory as part of alloc()
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 22:11:57 +08:00
Sean Cross
db87a94960
kernel: services: add a page for the queue
...
Eventually this will be rolled into an existing page.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 22:06:22 +08:00
Sean Cross
77c07f0d79
mem: add map_page()
...
This shortcut function ensures a page is mapped.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 22:06:00 +08:00
Sean Cross
9a10f50ce1
kernel: services: keep track of current pid
...
Currently we use the ASID inside the MMU to figure out the current PID.
We should also keep track of what we think it is, for consistency.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 21:28:01 +08:00
Sean Cross
845cef3771
kernel: services: add servers to SYSTEM_SERVICES
...
This array will be used to keep track of what servers are running.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 16:58:15 +08:00
Sean Cross
9508201db9
xous-rs: add claim_interrupt wrapper
...
Rather than calling the raw function, add a wrapper for programs to use.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-14 15:41:44 +08:00
Sean Cross
7a3e038e6b
syscall: add intial CreateServer call
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-13 22:41:25 +08:00
Sean Cross
c2008e5fe8
syscall: implement map_memory wrapper
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-13 20:33:08 +08:00
Sean Cross
08e416c776
kernel: support omitting virtual address when mapping
...
This forms the basis for message passing.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-13 12:44:23 +08:00
Sean Cross
967464df93
kernel: mem: rename last memory address variable
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-13 09:52:53 +08:00
Sean Cross
fb3da7294c
mem: turn function comment into rustdoc
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-13 08:32:44 +08:00
Sean Cross
4bb3f6db68
Merge branch 'master' of github.com:betrusted-io/xous-core
2020-03-13 08:30:55 +08:00
Sean Cross
f0d4e44254
kernel: processtable: add "last_default_address"
...
This will be used to accelerate allocations for ranges.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 17:02:03 +08:00
Sean Cross
87676c0fc5
mem: start implementing find_virtual_address()
...
Right now it just returns the address, which is exactly what we had
before.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 17:01:40 +08:00
Sean Cross
c1b575507d
mem: better handling of memory alloc failures
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 16:51:14 +08:00
Sean Cross
36faa8354f
riscv: mem: silence warnings when print-debug is disabled
...
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 16:50:55 +08:00
Sean Cross
09890a2ca3
riscv: use upstream riscv module
...
Still pulling from git, as the version number hasn't been bumped yet.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-11 17:49:03 +08:00
Sean Cross
f50ec67553
initial commit
...
This pulls together many disparate repositories into one xous-core
repository.
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:13:05 +08:00