Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hubpack instead of ssmarshal for kipc #694

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions doc/kipc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ or has a very malformatted body, the kernel will deliver a fault to your task
and move on to the next highest priority runnable code.

Messages sent to the kernel, and responses sent back, are formatted using the
`ssmarshal` crate via `serde`. Messages and responses are currently defined as
`hubpack` crate via `serde`. Messages and responses are currently defined as
Rust structs, simply because we haven't had a need to write a supervisor task in
C so far. We may wish to formalize this later, but, this is expedient for now.
Remember when reading the request/response types that it is the `ssmarshal`
Remember when reading the request/response types that it is the `hubpack`
serialized form, and not the in-memory layout of the struct, that is exchanged
with the kernel.

Expand Down
13 changes: 7 additions & 6 deletions sys/kern/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ edition = "2018"

[dependencies]
abi = {path = "../abi"}
zerocopy = "0.6.1"
byteorder = { version = "1.3.4", default-features = false }
bitflags = "1.2.1"
byteorder = { version = "1.3.4", default-features = false }
cfg-if = "1"
cortex-m = {version = "0.7", features = ["inline-asm"]}
hubpack = { git = "https://github.com/cbiffle/hubpack" }
phash = { path = "../../lib/phash" }
serde = { version = "1.0.114", default-features = false }
ssmarshal = { version = "1.0.0", default-features = false }
unwrap-lite = { path = "../../lib/unwrap-lite" }
phash = { path = "../../lib/phash" }
zerocopy = "0.6.1"

[build-dependencies]
build-util = {path = "../../build/util"}
serde = "1"
ron = "0.7"
serde = "1"

abi = {path = "../abi"}
build-util = {path = "../../build/util"}
phash-gen = {path = "../../build/phash-gen"}

[lib]
Expand Down
6 changes: 3 additions & 3 deletions sys/kern/src/kipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn deserialize_message<T>(
where
T: for<'de> serde::Deserialize<'de>,
{
let (msg, _) = ssmarshal::deserialize(task.try_read(&message)?)
let (msg, _) = hubpack::deserialize(task.try_read(&message)?)
.map_err(|_| UsageError::BadKernelMessage)?;
Ok(msg)
}
Expand All @@ -52,9 +52,9 @@ fn serialize_response<T>(
where
T: serde::Serialize,
{
match ssmarshal::serialize(task.try_write(&mut buf)?, val) {
match hubpack::serialize(task.try_write(&mut buf)?, val) {
Ok(size) => Ok(size),
Err(ssmarshal::Error::EndOfStream) => {
Err(hubpack::Error::Truncated) => {
// The client provided a response buffer that is too small. We
// actually tolerate this, and report back the size of a buffer that
// *would have* worked. It's up to the caller to notice.
Expand Down
10 changes: 5 additions & 5 deletions sys/userlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ log-null = []

[dependencies]
abi = {path = "../abi"}
armv6m-atomic-hack = {path = "../../lib/armv6m-atomic-hack"}
bstringify = "0.1.2"
cfg-if = "1"
hubpack = { git = "https://github.com/cbiffle/hubpack" }
num-traits = { version = "0.2.12", default-features = false }
paste = "1"
serde = { version = "1.0.114", default-features = false }
ssmarshal = { version = "1.0.0", default-features = false }
zerocopy = "0.6.1"
num-traits = { version = "0.2.12", default-features = false }
unwrap-lite = { path = "../../lib/unwrap-lite" }
cfg-if = "1"
armv6m-atomic-hack = {path = "../../lib/armv6m-atomic-hack"}
zerocopy = "0.6.1"

#
# In order to use macros as discriminants in enums that make use of derive
Expand Down
4 changes: 2 additions & 2 deletions sys/userlib/src/kipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub fn read_task_status(task: usize) -> abi::TaskState {
let (rc, len) =
sys_send(TaskId::KERNEL, 1, task.as_bytes(), &mut response, &[]);
assert_eq!(rc, 0);
ssmarshal::deserialize(&response[..len]).unwrap_lite().0
hubpack::deserialize(&response[..len]).unwrap_lite().0
}

pub fn restart_task(task: usize, start: bool) {
// Coerce `task` to a known size (Rust doesn't assume that usize == u32)
let msg = (task as u32, start);
let mut buf = [0; core::mem::size_of::<(u32, bool)>()];
ssmarshal::serialize(&mut buf, &msg).unwrap_lite();
hubpack::serialize(&mut buf, &msg).unwrap_lite();
let (rc, _len) = sys_send(TaskId::KERNEL, 2, &buf, &mut [], &[]);
assert_eq!(rc, 0);
}
Expand Down