Commit graph

299 commits

Author SHA1 Message Date
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