Much of the hosted machinery requires the ability to access memory on
syscalls. This feature was overlooked in the previous implementation of
ReplyAndReceiveNext, which caused it to not properly return memory.
Implement the ability to call `.memory()` on ReplyAndReceiveNext
messages.
Note that this requires the use of a sentinal value in the
previously-unused `valid` field.
Signed-off-by: Sean Cross <sean@xobs.io>
This call is used to return values while simultaneously listening for
new messages.
The -legacy suffix is used to disambiguate scalar values, so we know
whether to send Scalar1, Scalar2, or Scalar5 messages.
Signed-off-by: Sean Cross <sean@xobs.io>
This reflects the fact that up until now, the `Message` struct has
merely been the envelope that surrounds the message. It does not contain
any actual Message contents.
Signed-off-by: Sean Cross <sean@xobs.io>
With the addition of scalar5, existing api calls must be updated to take
advantage of it. This will allow `send_message()` to return a `scalar5`.
Signed-off-by: Sean Cross <sean@xobs.io>
Add syscall and return definitions for Scalar5, as well as
ReturnScalar5. This will enable us to pass up to five scalars as a
return from a blockingscalar call.
Signed-off-by: Sean Cross <sean@xobs.io>
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>
Look at `target_os` to determine whether to enter "hosted" mode or not.
If `target_os` is "xous", then the Xous standard library should default
to using builtin Rust libstd features.
If it is "xous", then we should instead use our arch-specific
implementations.
This enables third-party programs to directly use the `xous` crate
without specifying feature flags.
Signed-off-by: Sean Cross <sean@xobs.io>
the Vex has a custom flush instruction, after contacting
charles he recommends maybe adding some nops to make sure it
completes (maybe hardware bug? unclear. we're about to find out.)
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>
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.
The downsides are:
- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.
- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
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.
The ServerID return type was placed in the middle of the results list,
which caused results 8-15 to be shifted by one to become results 9-15,
with result 8 being swapped with result 15.
This fixes this offset.
Signed-off-by: Sean Cross <sean@xobs.io>
This syscal will be used to adjust various process limits. Currently
it only contains the ability to adjust the heap size and maximum.
Signed-off-by: Sean Cross <sean@xobs.io>
Previously, we only handled messages that were forwarded. With this
patch, we also handle memory messages that were returned.
This fixes#165
Signed-off-by: Sean Cross <sean@xobs.io>
This removes nearly all of the dependencies from `xous-rs`, making it
mostly self-contained.
There is one remaining dependency tree which is `xous-macros`. This is a
legacy feature from before a time we had main(). Attempts will be made
to remove it as well.
Signed-off-by: Sean Cross <sean@xobs.io>
The `xous-rs` library is used in many places, and should have as few
dependencies as possible. Remove these as dependencies.
Signed-off-by: Sean Cross <sean@xobs.io>
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>
Messages should be able to be forwarded from one Server to another. This
is a wrapper around the machinery that would do that.
Signed-off-by: Sean Cross <sean@xobs.io>
Allow setting a message's ID by adding a `set_id(&mut self, ...)`
function. This can be used when regifting a message.
Signed-off-by: Sean Cross <sean@xobs.io>
Use a `Vec<u8>` as a backing for memory across the entire project.
Previously we used `Vec<u8>` as a backing for MemoryMessages and used
`alloc` for all other messages. This unifies that to always use
`Vec<u8>`.
I'd prefer if we used `alloc` instead, however that has not been working
and I'm not sure why. Standardize on this for now and look into why
later.
Signed-off-by: Sean Cross <sean@xobs.io>
The `Messages` types were getting hairy, and `definitions.rs` was really
long. Trim it down by moving types into their own files.
Signed-off-by: Sean Cross <sean@xobs.io>
Keyboard setting is "the one and only" exception to user settings
that are saved without encryption. This is because you need your
keyboard layout to be set in order for you to type your password.
Thus, this needed a bit of a special-case to handle its storage record.
We decided to lop off 1 page from the loader and have it store
the keyboard layout code.
Let's hope we can have the discipline to really just store that
one word of information and not later be like "gee wally, you have
a whoooole 4092 unused bytes of space we can cram unencrypted
user settings in, sure would be a waste to not put those use those".
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.
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).
these are secondary attack surfaces -- code that isn't directly
in the kernel, but involved in the manipulation, handling, grooming
and preparation of source and binary files
Add a function to modify the pointer of a MemoryRange. This is used by
`hosted` mode in order to modify memory pointers when we receive them
from the remote client.
Signed-off-by: Sean Cross <sean@xobs.io>
This completely redoes the client-side of syscalls such that there is a
lot less lock contention. Processes now properly sleep rather than
spinning, unless they're waiting for a response due to a blocked server,
which rarely happens in practice.
Signed-off-by: Sean Cross <sean@xobs.io>
When running tests, `processes-as-threads` gets enabled. Look for this
feature flag to determine if we need to use that architecture.
Note that this change requires `resolver v2` to be enabled.
Signed-off-by: Sean Cross <sean@xobs.io>
The test module uses this feature to avoid having to spawn external
processes. Make this a feature flag since it doesn't make sense for any
other target.
Signed-off-by: Sean Cross <sean@xobs.io>
The `test` arch works with TLS and allows for multiple servers and
processes per "process".
This is a special case, and warrants its own arch.
Signed-off-by: Sean Cross <sean@xobs.io>
This has been tested end-to-end. We now have exception handler support.
There is a potential issue when passing messages to our own process in
an exception handler. This will need to be investigated.
Signed-off-by: Sean Cross <sean@xobs.io>
If a MemoryRange is defined as immutable, don't allow `as_mut_slice()`
to be called. This is an API-breaking change.
Signed-off-by: Sean Cross <sean@xobs.io>
- you can only "patch" regions of memory. caller provides a slice
to the region of data they are patching, so that patches can be
computed by the lib-side code of the server.
- erasing is done with a "patch" with all 0xff's as the write data.
a sequence of pure 0xff for a page does not actually cause a write,
the condition is detected and the write is skipped after an erase.
- patches attempt to be somewhat intelligent and not re-write unchnaged
data, or erase blocks that don't need udpating. However, if a user
submits a "sparse patch" with just a couple bytes modified in a
megabyte region they can expect bad performance. Ideally, in that
scenario, each of the smaller modifications are submitted as
individual calls to the patch function, instead of regurgitating
all the data and hoping that hthe patch function does some intelligent
diffing to be as light-fingered as possible about updating the flash.
In other words, the onus is on the calling server to format
patches intelligently. The patch server does only the simplest,
safest optimizations. You don't want to be shuttling megabytes of
redundant data anyways between servers for many other reasons....!
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>
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>
Add functions to obtain various slices from a `MemoryRange`. These
functions are safe because we know that the memory in the range is
valid, and we know the size of the type.
Signed-off-by: Sean Cross <sean@xobs.io>
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>