mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
finalize rkyv 0.4.1 refactor
This commit is contained in:
parent
8fbd900a4c
commit
ea8b208a15
20 changed files with 203 additions and 172 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
|
@ -83,7 +83,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
"rkyv 0.3.1",
|
"rkyv 0.4.1",
|
||||||
"utralib",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
"xous-names",
|
"xous-names",
|
||||||
|
|
@ -654,7 +654,7 @@ dependencies = [
|
||||||
"heapless",
|
"heapless",
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
"rkyv 0.3.1",
|
"rkyv 0.4.1",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"utralib",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
|
|
@ -1155,7 +1155,7 @@ dependencies = [
|
||||||
"llio",
|
"llio",
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
"rkyv 0.3.1",
|
"rkyv 0.4.1",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"utralib",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
|
|
|
||||||
85
kernel/Cargo.lock
generated
85
kernel/Cargo.lock
generated
|
|
@ -218,26 +218,6 @@ version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
|
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hash32"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hash32-derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ebc0efbd154a17cddc3616d83faef479c0076d871a2143c157b310cc7ca799a2"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.3.8",
|
|
||||||
"quote 0.5.2",
|
|
||||||
"syn 0.13.11",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.17"
|
version = "0.1.17"
|
||||||
|
|
@ -330,22 +310,13 @@ version = "0.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid 0.1.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
|
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.1",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -363,9 +334,9 @@ version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7bcd6232fa7d7fcd15703da5c07c9f10d203ee4fdf6ecf6d7ac5056db78089a3"
|
checksum = "7bcd6232fa7d7fcd15703da5c07c9f10d203ee4fdf6ecf6d7ac5056db78089a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.19",
|
"proc-macro2",
|
||||||
"quote 1.0.7",
|
"quote",
|
||||||
"syn 1.0.38",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -377,22 +348,13 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.3.8",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.19",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -473,9 +435,9 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95a169f6bc5a81033e86ed39d0f4150e2608160b73d2b93c6e8e6a3efa873f14"
|
checksum = "95a169f6bc5a81033e86ed39d0f4150e2608160b73d2b93c6e8e6a3efa873f14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.19",
|
"proc-macro2",
|
||||||
"quote 1.0.7",
|
"quote",
|
||||||
"syn 1.0.38",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -542,26 +504,15 @@ dependencies = [
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "0.13.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.3.8",
|
|
||||||
"quote 0.5.2",
|
|
||||||
"unicode-xid 0.1.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.38"
|
version = "1.0.38"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
|
checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.19",
|
"proc-macro2",
|
||||||
"quote 1.0.7",
|
"quote",
|
||||||
"unicode-xid 0.2.1",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -585,12 +536,6 @@ version = "0.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
@ -653,8 +598,6 @@ name = "xous"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"hash32",
|
|
||||||
"hash32-derive",
|
|
||||||
"hex",
|
"hex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"rkyv",
|
"rkyv",
|
||||||
|
|
@ -665,8 +608,8 @@ dependencies = [
|
||||||
name = "xous-macros"
|
name = "xous-macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.19",
|
"proc-macro2",
|
||||||
"quote 1.0.7",
|
"quote",
|
||||||
"rand",
|
"rand",
|
||||||
"syn 1.0.38",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,15 @@ description = "Benchmark target for Xous"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
xous = { path = "../../xous-rs" }
|
xous = { path = "../../xous-rs" }
|
||||||
rkyv = { version = "0.3.1", default_features = false }
|
|
||||||
xous-names = { path = "../xous-names" }
|
xous-names = { path = "../xous-names" }
|
||||||
log-server = { path = "../log-server" }
|
log-server = { path = "../log-server" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
|
[dependencies.rkyv]
|
||||||
|
version = "0.4.1"
|
||||||
|
default-features = false
|
||||||
|
features = ["const_generics"]
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utralib = { path = "../../utralib"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pub mod api;
|
||||||
use api::*;
|
use api::*;
|
||||||
|
|
||||||
use xous::{CID, send_message};
|
use xous::{CID, send_message};
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
|
|
||||||
pub fn test_scalar(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
pub fn test_scalar(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
||||||
let response = send_message(cid, api::Opcode::TestScalar(testvar).into())?;
|
let response = send_message(cid, api::Opcode::TestScalar(testvar).into())?;
|
||||||
|
|
@ -20,8 +21,9 @@ pub fn test_memory(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
||||||
reg.challenge[0] = testvar;
|
reg.challenge[0] = testvar;
|
||||||
|
|
||||||
let reg_opcode = api::Opcode::TestMemory(reg);
|
let reg_opcode = api::Opcode::TestMemory(reg);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(®_opcode).expect("couldn't archive test structure");
|
|
||||||
|
let pos = writer.serialize_value(®_opcode).expect("couldn't archive test structure");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
xous_buffer.lend_mut(cid, pos as u32).expect("test failure");
|
xous_buffer.lend_mut(cid, pos as u32).expect("test failure");
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ use log::{error, info};
|
||||||
use rkyv::archived_value_mut;
|
use rkyv::archived_value_mut;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
use rkyv::{Serialize, Deserialize};
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
|
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
|
|
@ -44,8 +45,8 @@ fn xmain() -> ! {
|
||||||
ret.challenge[0] = reg.challenge[0] + 1;
|
ret.challenge[0] = reg.challenge[0] + 1;
|
||||||
|
|
||||||
let retop = Opcode::TestMemory(ret);
|
let retop = Opcode::TestMemory(ret);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let pos = writer.archive(&retop).expect("couldn't archive return value");
|
let pos = writer.serialize_value(&retop).expect("couldn't archive return value");
|
||||||
unsafe{ rkyv::archived_value::<api::Opcode>(writer.into_inner().as_ref(), pos) };
|
unsafe{ rkyv::archived_value::<api::Opcode>(writer.into_inner().as_ref(), pos) };
|
||||||
}
|
}
|
||||||
_ => panic!("Invalid response from server -- corruption occurred"),
|
_ => panic!("Invalid response from server -- corruption occurred"),
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ pub mod api;
|
||||||
use api::*;
|
use api::*;
|
||||||
|
|
||||||
use xous::send_message;
|
use xous::send_message;
|
||||||
use rkyv::Write;
|
use rkyv::Deserialize;
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
use rkyv::ser::Serializer;
|
||||||
use graphics_server::api::{TextOp, TextView};
|
use graphics_server::api::{TextOp, TextView};
|
||||||
|
|
||||||
use graphics_server::api::{Point, Gid, Line, Rectangle, Circle, RoundedRectangle};
|
use graphics_server::api::{Point, Gid, Line, Rectangle, Circle, RoundedRectangle};
|
||||||
|
|
@ -34,8 +34,9 @@ pub fn powerdown_request(gam_cid: xous::CID) -> Result<bool, xous::Error> {
|
||||||
pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
tv.set_op(TextOp::Render);
|
tv.set_op(TextOp::Render);
|
||||||
let rkyv_tv = api::Opcode::RenderTextView(*tv);
|
let rkyv_tv = api::Opcode::RenderTextView(*tv);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive textview");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_tv).expect("GAM_API: couldn't archive textview");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: RenderTextView operation failure");
|
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: RenderTextView operation failure");
|
||||||
|
|
@ -43,7 +44,7 @@ pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::
|
||||||
// recover the mutable values and mirror the ones we care about back into our local structure
|
// recover the mutable values and mirror the ones we care about back into our local structure
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::RenderTextView(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::RenderTextView(result) = returned {
|
||||||
let tvr: TextView = result.deserialize();
|
let tvr: TextView = result.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -60,8 +61,9 @@ pub fn draw_line(gam_cid: xous::CID, gid: Gid, line: Line) -> Result<(), xous::E
|
||||||
canvas: gid,
|
canvas: gid,
|
||||||
obj: GamObjectType::Line(line),
|
obj: GamObjectType::Line(line),
|
||||||
});
|
});
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -72,8 +74,9 @@ pub fn draw_rectangle(gam_cid: xous::CID, gid: Gid, rect: Rectangle) -> Result<(
|
||||||
canvas: gid,
|
canvas: gid,
|
||||||
obj: GamObjectType::Rect(rect),
|
obj: GamObjectType::Rect(rect),
|
||||||
});
|
});
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -84,8 +87,9 @@ pub fn draw_rouded_rectangle(gam_cid: xous::CID, gid: Gid, rr: RoundedRectangle)
|
||||||
canvas: gid,
|
canvas: gid,
|
||||||
obj: GamObjectType::RoundRect(rr),
|
obj: GamObjectType::RoundRect(rr),
|
||||||
});
|
});
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -96,8 +100,9 @@ pub fn draw_circle(gam_cid: xous::CID, gid: Gid, circ: Circle) -> Result<(), xou
|
||||||
canvas: gid,
|
canvas: gid,
|
||||||
obj: GamObjectType::Circ(circ),
|
obj: GamObjectType::Circ(circ),
|
||||||
});
|
});
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -119,15 +124,16 @@ pub fn get_canvas_bounds(gam_cid: xous::CID, gid: Gid) -> Result<Point, xous::Er
|
||||||
|
|
||||||
pub fn set_canvas_bounds_request(gam_cid: xous::CID, req: &mut SetCanvasBoundsRequest) -> Result<(), xous::Error> {
|
pub fn set_canvas_bounds_request(gam_cid: xous::CID, req: &mut SetCanvasBoundsRequest) -> Result<(), xous::Error> {
|
||||||
let rkyv = api::Opcode::SetCanvasBounds((*req).clone());
|
let rkyv = api::Opcode::SetCanvasBounds((*req).clone());
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv).expect("GAM_API: couldn't archive SetCanvasBounds");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv).expect("GAM_API: couldn't archive SetCanvasBounds");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: SetCanvasBounds operation failure");
|
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: SetCanvasBounds operation failure");
|
||||||
|
|
||||||
// recover the mutable values and mirror the ones we care about back into our local structure
|
// recover the mutable values and mirror the ones we care about back into our local structure
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::SetCanvasBounds(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::SetCanvasBounds(result) = returned {
|
||||||
let ret: SetCanvasBoundsRequest = result.deserialize();
|
let ret: SetCanvasBoundsRequest = result.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
req.granted = ret.granted;
|
req.granted = ret.granted;
|
||||||
} else {
|
} else {
|
||||||
panic!("GAM_API: set_canvas_bounds_request view got a return value from the server that isn't expected or handled");
|
panic!("GAM_API: set_canvas_bounds_request view got a return value from the server that isn't expected or handled");
|
||||||
|
|
@ -145,15 +151,16 @@ pub fn request_content_canvas(gam_cid: xous::CID, requestor_name: &str) -> Resul
|
||||||
};
|
};
|
||||||
let rkyv = api::Opcode::RequestContentCanvas(req);
|
let rkyv = api::Opcode::RequestContentCanvas(req);
|
||||||
|
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv).expect("GAM_API: couldn't archive RequestContentCanvas");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv).expect("GAM_API: couldn't archive RequestContentCanvas");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: RequestContentCanvas operation failure");
|
xous_buffer.lend_mut(gam_cid, pos as u32).expect("GAM_API: RequestContentCanvas operation failure");
|
||||||
|
|
||||||
// recover the mutable values and mirror the ones we care about back into our local structure
|
// recover the mutable values and mirror the ones we care about back into our local structure
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::RequestContentCanvas(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::RequestContentCanvas(result) = returned {
|
||||||
let ret: ContentCanvasRequest = result.deserialize();
|
let ret: ContentCanvasRequest = result.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
Ok(ret.canvas)
|
Ok(ret.canvas)
|
||||||
} else {
|
} else {
|
||||||
log::error!("GAM_API: request_content_canvas got a return value from the server that isn't expected or handled");
|
log::error!("GAM_API: request_content_canvas got a return value from the server that isn't expected or handled");
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ use core::convert::TryFrom;
|
||||||
use heapless::FnvIndexMap;
|
use heapless::FnvIndexMap;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
|
|
||||||
use rkyv::{Unarchive, archived_value, archived_value_mut};
|
use rkyv::{archived_value, archived_value_mut};
|
||||||
|
use rkyv::Deserialize;
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -291,7 +293,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<api::Opcode>::RenderTextView(rtv) => {
|
rkyv::Archived::<api::Opcode>::RenderTextView(rtv) => {
|
||||||
let mut tv = rtv.deserialize();
|
let mut tv = rtv.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("GAM: rendertextview {:?}", tv);}
|
if debug1{info!("GAM: rendertextview {:?}", tv);}
|
||||||
match tv.get_op() {
|
match tv.get_op() {
|
||||||
TextOp::Nop => (),
|
TextOp::Nop => (),
|
||||||
|
|
@ -322,9 +324,8 @@ fn xmain() -> ! {
|
||||||
tv.bounds_computed = tv_clone.bounds_computed;
|
tv.bounds_computed = tv_clone.bounds_computed;
|
||||||
|
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
writer.serialize_value(&api::Opcode::RenderTextView(tv)).expect("GAM: couldn't re-archive return value");
|
||||||
writer.archive(&api::Opcode::RenderTextView(tv)).expect("GAM: couldn't re-archive return value");
|
|
||||||
canvas.do_drawn().expect("GAM: couldn't set canvas to drawn");
|
canvas.do_drawn().expect("GAM: couldn't set canvas to drawn");
|
||||||
} else {
|
} else {
|
||||||
info!("GAM: attempt to draw TextView on non-drawable canvas. Not fatal, but request ignored.");
|
info!("GAM: attempt to draw TextView on non-drawable canvas. Not fatal, but request ignored.");
|
||||||
|
|
@ -337,7 +338,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
rkyv::Archived::<api::Opcode>::SetCanvasBounds(rcb) => {
|
rkyv::Archived::<api::Opcode>::SetCanvasBounds(rcb) => {
|
||||||
let mut cb: SetCanvasBoundsRequest = rcb.deserialize();
|
let mut cb: SetCanvasBoundsRequest = rcb.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("GAM: SetCanvasBoundsRequest {:?}", cb);}
|
if debug1{info!("GAM: SetCanvasBoundsRequest {:?}", cb);}
|
||||||
// ASSUME:
|
// ASSUME:
|
||||||
// very few canvases allow dynamic resizing, so we special case these
|
// very few canvases allow dynamic resizing, so we special case these
|
||||||
|
|
@ -353,12 +354,11 @@ fn xmain() -> ! {
|
||||||
cb.granted = None;
|
cb.granted = None;
|
||||||
}
|
}
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
writer.serialize_value(&api::Opcode::SetCanvasBounds(cb)).expect("GAM: SetCanvasBoundsRequest couldn't re-archive return value");
|
||||||
writer.archive(&api::Opcode::SetCanvasBounds(cb)).expect("GAM: SetCanvasBoundsRequest couldn't re-archive return value");
|
|
||||||
},
|
},
|
||||||
rkyv::Archived::<api::Opcode>::RequestContentCanvas(rcc) => {
|
rkyv::Archived::<api::Opcode>::RequestContentCanvas(rcc) => {
|
||||||
let mut req: ContentCanvasRequest = rcc.deserialize();
|
let mut req: ContentCanvasRequest = rcc.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("GAM: RequestContentCanvas {:?}", req);}
|
if debug1{info!("GAM: RequestContentCanvas {:?}", req);}
|
||||||
// for now, we do nothing with the incoming gid value; but, in the future, we can use it
|
// for now, we do nothing with the incoming gid value; but, in the future, we can use it
|
||||||
// as an authentication token perhaps to control access
|
// as an authentication token perhaps to control access
|
||||||
|
|
@ -373,9 +373,8 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
req.canvas = chatlayout.content;
|
req.canvas = chatlayout.content;
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
writer.serialize_value(&api::Opcode::RequestContentCanvas(req)).expect("GAM: RequestContentCanvas couldn't re-archive return value");
|
||||||
writer.archive(&api::Opcode::RequestContentCanvas(req)).expect("GAM: RequestContentCanvas couldn't re-archive return value");
|
|
||||||
},
|
},
|
||||||
_ => panic!("GAM: invalid mutable borrow message"),
|
_ => panic!("GAM: invalid mutable borrow message"),
|
||||||
};
|
};
|
||||||
|
|
@ -387,7 +386,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<api::Opcode>::RenderObject(rtv) => {
|
rkyv::Archived::<api::Opcode>::RenderObject(rtv) => {
|
||||||
let obj: GamObject = rtv.deserialize();
|
let obj: GamObject = rtv.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("GAM: renderobject {:?}", obj);}
|
if debug1{info!("GAM: renderobject {:?}", obj);}
|
||||||
if let Some(canvas) = canvases.get_mut(&obj.canvas) {
|
if let Some(canvas) = canvases.get_mut(&obj.canvas) {
|
||||||
// first, figure out if we should even be drawing to this canvas.
|
// first, figure out if we should even be drawing to this canvas.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ pub use blitstr::{ClipRect, Cursor, GlyphStyle};
|
||||||
use xous::String;
|
use xous::String;
|
||||||
pub mod op;
|
pub mod op;
|
||||||
|
|
||||||
use xous::{send_message, CID};
|
use xous::{send_message, CID, XousDeserializer};
|
||||||
|
use rkyv::Deserialize;
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
pub fn draw_line(cid: CID, line: Line) -> Result<(), xous::Error> {
|
pub fn draw_line(cid: CID, line: Line) -> Result<(), xous::Error> {
|
||||||
|
|
@ -134,13 +135,13 @@ pub fn draw_textview(cid: CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
|
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::DrawTextView(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::DrawTextView(result) = returned {
|
||||||
let tvr: TextView = result.deserialize();
|
let tvr: TextView = result.deserialize(&mut XousDeserializer).expect("draw_textview couldn't deserialize result");
|
||||||
//log::info!("draw_textview: got cursor of {:?}, bounds of {:?}", tvr.cursor, tvr.bounds_computed);
|
//log::info!("draw_textview: got cursor of {:?}, bounds of {:?}", tvr.cursor, tvr.bounds_computed);
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let tvr = returned.deserialize();
|
let tvr = returned.deserialize(&mut XousDeserializer).expect("draw_textview couldn't deserialize result");
|
||||||
log::info!("draw_textview saw an unhandled return type of {:?}", tvr);
|
log::info!("draw_textview saw an unhandled return type of {:?}", tvr);
|
||||||
Err(xous::Error::InternalError)
|
Err(xous::Error::InternalError)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ mod api;
|
||||||
use api::{Opcode, ClipObject, ClipObjectType};
|
use api::{Opcode, ClipObject, ClipObjectType};
|
||||||
|
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use rkyv::{archived_value, Unarchive, archived_value_mut};
|
use rkyv::{archived_value, archived_value_mut};
|
||||||
|
use rkyv::Deserialize;
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
|
|
||||||
mod backend;
|
mod backend;
|
||||||
use backend::XousDisplay;
|
use backend::XousDisplay;
|
||||||
|
|
@ -107,7 +109,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<api::Opcode>::String(rkyv_s) => {
|
rkyv::Archived::<api::Opcode>::String(rkyv_s) => {
|
||||||
let s: xous::String<4096> = rkyv_s.deserialize();
|
let s: xous::String<4096> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
//info!("GFX: unarchived string: {:?}", s);
|
//info!("GFX: unarchived string: {:?}", s);
|
||||||
blitstr::paint_str(
|
blitstr::paint_str(
|
||||||
display.native_buffer(),
|
display.native_buffer(),
|
||||||
|
|
@ -123,7 +125,7 @@ fn xmain() -> ! {
|
||||||
//info!("GFX: string painted");
|
//info!("GFX: string painted");
|
||||||
},
|
},
|
||||||
rkyv::Archived::<api::Opcode>::StringXor(rkyv_s) => {
|
rkyv::Archived::<api::Opcode>::StringXor(rkyv_s) => {
|
||||||
let s: xous::String<4096> = rkyv_s.deserialize();
|
let s: xous::String<4096> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
blitstr::paint_str(
|
blitstr::paint_str(
|
||||||
display.native_buffer(),
|
display.native_buffer(),
|
||||||
current_string_clip.into(),
|
current_string_clip.into(),
|
||||||
|
|
@ -137,7 +139,7 @@ fn xmain() -> ! {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
rkyv::Archived::<api::Opcode>::DrawClipObject(rco) => {
|
rkyv::Archived::<api::Opcode>::DrawClipObject(rco) => {
|
||||||
let obj: ClipObject = rco.deserialize();
|
let obj: ClipObject = rco.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("GFX: DrawClipObject {:?}", obj);}
|
if debug1{info!("GFX: DrawClipObject {:?}", obj);}
|
||||||
match obj.obj {
|
match obj.obj {
|
||||||
ClipObjectType::Line(line) => {
|
ClipObjectType::Line(line) => {
|
||||||
|
|
@ -164,7 +166,7 @@ fn xmain() -> ! {
|
||||||
let debugtv: bool = false;
|
let debugtv: bool = false;
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<api::Opcode>::DrawTextView(rtv) => {
|
rkyv::Archived::<api::Opcode>::DrawTextView(rtv) => {
|
||||||
let mut tv = rtv.deserialize();
|
let mut tv = rtv.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
|
|
||||||
if tv.clip_rect.is_none() { continue } // if no clipping rectangle is specified, nothing to draw
|
if tv.clip_rect.is_none() { continue } // if no clipping rectangle is specified, nothing to draw
|
||||||
let clip_rect = tv.clip_rect.unwrap(); // this is the clipping rectangle of the canvas
|
let clip_rect = tv.clip_rect.unwrap(); // this is the clipping rectangle of the canvas
|
||||||
|
|
@ -367,9 +369,8 @@ fn xmain() -> ! {
|
||||||
if debugtv{info!("GFX(TV): returning cursor of {:?}", tv.cursor);}
|
if debugtv{info!("GFX(TV): returning cursor of {:?}", tv.cursor);}
|
||||||
|
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
writer.serialize_value(&api::Opcode::DrawTextView(tv)).expect("GFX: couldn't re-archive return value");
|
||||||
writer.archive(&api::Opcode::DrawTextView(tv)).expect("GFX: couldn't re-archive return value");
|
|
||||||
},
|
},
|
||||||
_ => panic!("GFX: invalid mutable borrow message"),
|
_ => panic!("GFX: invalid mutable borrow message"),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use blitstr_ref as blitstr;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use ime_plugin_api::{PredictionTriggers, PredictionPlugin, PredictionApi};
|
use ime_plugin_api::{PredictionTriggers, PredictionPlugin, PredictionApi};
|
||||||
|
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
use rkyv::Deserialize;
|
||||||
use rkyv::archived_value;
|
use rkyv::archived_value;
|
||||||
|
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
|
|
@ -621,14 +621,14 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<ImefOpcode>::SetPredictionServer(rkyv_s) => {
|
rkyv::Archived::<ImefOpcode>::SetPredictionServer(rkyv_s) => {
|
||||||
let s: xous::String<256> = rkyv_s.deserialize();
|
let s: xous::String<256> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
match xous_names::request_connection(s.as_str().expect("IMEF: SetPrediction received malformed server name")) {
|
match xous_names::request_connection(s.as_str().expect("IMEF: SetPrediction received malformed server name")) {
|
||||||
Ok(pc) => tracker.set_predictor(ime_plugin_api::PredictionPlugin {connection: Some(pc)}),
|
Ok(pc) => tracker.set_predictor(ime_plugin_api::PredictionPlugin {connection: Some(pc)}),
|
||||||
_ => error!("IMEF: can't find predictive engine {}, retaining existing one.", s.as_str().expect("IMEF: SetPrediction received malformed server name")),
|
_ => error!("IMEF: can't find predictive engine {}, retaining existing one.", s.as_str().expect("IMEF: SetPrediction received malformed server name")),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rkyv::Archived::<ImefOpcode>::RegisterListener(registration) => {
|
rkyv::Archived::<ImefOpcode>::RegisterListener(registration) => {
|
||||||
let s: xous::String<256> = registration.deserialize();
|
let s: xous::String<256> = registration.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if dbglistener{info!("IMEF: registering listener {:?}", s);}
|
if dbglistener{info!("IMEF: registering listener {:?}", s);}
|
||||||
// note second copy down below, this is put in early-init because we're likely to get these requests early on
|
// note second copy down below, this is put in early-init because we're likely to get these requests early on
|
||||||
let cid = xous_names::request_connection_blocking(s.as_str().expect("IMEF: can't decode RegisterListener string"))
|
let cid = xous_names::request_connection_blocking(s.as_str().expect("IMEF: can't decode RegisterListener string"))
|
||||||
|
|
@ -677,14 +677,14 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<ImefOpcode>::SetPredictionServer(rkyv_s) => {
|
rkyv::Archived::<ImefOpcode>::SetPredictionServer(rkyv_s) => {
|
||||||
let s: xous::String<256> = rkyv_s.deserialize();
|
let s: xous::String<256> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
match xous_names::request_connection(s.as_str().expect("IMEF: SetPrediction received malformed server name")) {
|
match xous_names::request_connection(s.as_str().expect("IMEF: SetPrediction received malformed server name")) {
|
||||||
Ok(pc) => tracker.set_predictor(ime_plugin_api::PredictionPlugin {connection: Some(pc)}),
|
Ok(pc) => tracker.set_predictor(ime_plugin_api::PredictionPlugin {connection: Some(pc)}),
|
||||||
_ => error!("IMEF: can't find predictive engine {}, retaining existing one.", s.as_str().expect("IMEF: SetPrediction received malformed server name")),
|
_ => error!("IMEF: can't find predictive engine {}, retaining existing one.", s.as_str().expect("IMEF: SetPrediction received malformed server name")),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rkyv::Archived::<ImefOpcode>::RegisterListener(registration) => {
|
rkyv::Archived::<ImefOpcode>::RegisterListener(registration) => {
|
||||||
let s: xous::String<256> = registration.deserialize();
|
let s: xous::String<256> = registration.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if dbglistener{info!("IMEF: registering listener {:?}", s);}
|
if dbglistener{info!("IMEF: registering listener {:?}", s);}
|
||||||
// note first copy above, put in early-init because we're likely to get these requests early on
|
// note first copy above, put in early-init because we're likely to get these requests early on
|
||||||
let cid = xous_names::request_connection_blocking(s.as_str().expect("IMEF: can't decode RegisterListener string"))
|
let cid = xous_names::request_connection_blocking(s.as_str().expect("IMEF: can't decode RegisterListener string"))
|
||||||
|
|
@ -700,10 +700,11 @@ fn xmain() -> ! {
|
||||||
if let Some(line) = tracker.update(keys).expect("IMEF: couldn't update input tracker with latest key presses") {
|
if let Some(line) = tracker.update(keys).expect("IMEF: couldn't update input tracker with latest key presses") {
|
||||||
if dbglistener{info!("IMEF: sending listeners {:?}", line);}
|
if dbglistener{info!("IMEF: sending listeners {:?}", line);}
|
||||||
for &conn in listeners.iter() {
|
for &conn in listeners.iter() {
|
||||||
use rkyv::Write;
|
|
||||||
let op = ImefOpcode::GotInputLine(line);
|
let op = ImefOpcode::GotInputLine(line);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&op).expect("IMEF: couldn't archive line for sending");
|
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
|
let pos = writer.serialize_value(&op).expect("IMEF: couldn't archive line for sending");
|
||||||
if dbglistener{info!("IMEF: sending to conn {:?}", conn);}
|
if dbglistener{info!("IMEF: sending to conn {:?}", conn);}
|
||||||
writer.into_inner().lend(conn, pos as u32).expect("IMEF: couldn't send input line to listener");
|
writer.into_inner().lend(conn, pos as u32).expect("IMEF: couldn't send input line to listener");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use xous::{Message, ScalarMessage, String, CID};
|
use xous::{Message, ScalarMessage, String, CID};
|
||||||
use graphics_server::Gid;
|
use graphics_server::Gid;
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub struct Prediction {
|
pub struct Prediction {
|
||||||
|
|
@ -137,12 +138,12 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_input(&self, s: String<4000>) -> Result<(), xous::Error> {
|
fn set_input(&self, s: String<4000>) -> Result<(), xous::Error> {
|
||||||
use rkyv::Write;
|
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
let rkyv_input = Opcode::Input(s);
|
let rkyv_input = Opcode::Input(s);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_input).expect("IME|API: couldn't archive input string");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_input).expect("IME|API: couldn't archive input string");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
xous_buffer.lend(cid, pos as u32).expect("IME|API: set_input operation failure");
|
xous_buffer.lend(cid, pos as u32).expect("IME|API: set_input operation failure");
|
||||||
|
|
@ -153,12 +154,12 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn feedback_picked(&self, s: String<4000>) -> Result<(), xous::Error> {
|
fn feedback_picked(&self, s: String<4000>) -> Result<(), xous::Error> {
|
||||||
use rkyv::Write;
|
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
let rkyv_picked = Opcode::Picked(s);
|
let rkyv_picked = Opcode::Picked(s);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_picked).expect("IME|API: couldn't archive picked string");
|
|
||||||
|
let pos = writer.serialize_value(&rkyv_picked).expect("IME|API: couldn't archive picked string");
|
||||||
let xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
xous_buffer.lend(cid, pos as u32).expect("IME|API: feedback_picked operation failure");
|
xous_buffer.lend(cid, pos as u32).expect("IME|API: feedback_picked operation failure");
|
||||||
|
|
@ -169,8 +170,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_prediction(&self, index: u32) -> Result<Option<xous::String<4000>>, xous::Error> {
|
fn get_prediction(&self, index: u32) -> Result<Option<xous::String<4000>>, xous::Error> {
|
||||||
use rkyv::Write;
|
use rkyv::Deserialize;
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
|
||||||
let debug1 = false;
|
let debug1 = false;
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
|
|
@ -181,8 +181,9 @@ impl PredictionApi for PredictionPlugin {
|
||||||
valid: false,
|
valid: false,
|
||||||
};
|
};
|
||||||
let pred_op = Opcode::Prediction(prediction);
|
let pred_op = Opcode::Prediction(prediction);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&pred_op).expect("IME|API: couldn't archive prediction request");
|
|
||||||
|
let pos = writer.serialize_value(&pred_op).expect("IME|API: couldn't archive prediction request");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
if debug1{log::info!("IME|API: lending Prediction with pos {}", pos);}
|
if debug1{log::info!("IME|API: lending Prediction with pos {}", pos);}
|
||||||
|
|
||||||
|
|
@ -191,7 +192,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
if debug1{log::info!("IME|API: returned from get_prediction");}
|
if debug1{log::info!("IME|API: returned from get_prediction");}
|
||||||
let returned = unsafe { rkyv::archived_value::<Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<Opcode>::Prediction(result) = returned {
|
if let rkyv::Archived::<Opcode>::Prediction(result) = returned {
|
||||||
let pred_r: Prediction = result.deserialize();
|
let pred_r: Prediction = result.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{log::info!("IME|API: got {:?}", pred_r);}
|
if debug1{log::info!("IME|API: got {:?}", pred_r);}
|
||||||
if pred_r.valid {
|
if pred_r.valid {
|
||||||
let mut ret = xous::String::<4000>::new();
|
let mut ret = xous::String::<4000>::new();
|
||||||
|
|
@ -202,7 +203,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let r = returned.deserialize();
|
let r = returned.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
log::error!("IME: API get_prediction returned an invalid result {:?}", r);
|
log::error!("IME: API get_prediction returned an invalid result {:?}", r);
|
||||||
Err(xous::Error::InvalidString)
|
Err(xous::Error::InvalidString)
|
||||||
}
|
}
|
||||||
|
|
@ -306,9 +307,9 @@ impl ImeFrontEndApi for ImeFrontEnd {
|
||||||
write!(server, "{}", servername).expect("IMEF: couldn't write set_predictor server name");
|
write!(server, "{}", servername).expect("IMEF: couldn't write set_predictor server name");
|
||||||
let ime_op = ImefOpcode::SetPredictionServer(server);
|
let ime_op = ImefOpcode::SetPredictionServer(server);
|
||||||
|
|
||||||
use rkyv::Write as ArchiveWrite;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
|
||||||
let pos = writer.archive(&ime_op).expect("IMEF: couldn't archive SetPredictionServer");
|
let pos = writer.serialize_value(&ime_op).expect("IMEF: couldn't archive SetPredictionServer");
|
||||||
writer.into_inner().lend(cid, pos as u32).expect("IMEF: SetPredictionServer request failure");
|
writer.into_inner().lend(cid, pos as u32).expect("IMEF: SetPredictionServer request failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|
@ -324,9 +325,9 @@ impl ImeFrontEndApi for ImeFrontEnd {
|
||||||
write!(server, "{}", servername).expect("IMEF: couldn't write set_predictor server name");
|
write!(server, "{}", servername).expect("IMEF: couldn't write set_predictor server name");
|
||||||
let ime_op = ImefOpcode::RegisterListener(server);
|
let ime_op = ImefOpcode::RegisterListener(server);
|
||||||
|
|
||||||
use rkyv::Write as ArchiveWrite;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(xous::XousBuffer::new(4096));
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
|
||||||
let pos = writer.archive(&ime_op).expect("IMEF: couldn't archive SetPredictionServer");
|
let pos = writer.serialize_value(&ime_op).expect("IMEF: couldn't archive SetPredictionServer");
|
||||||
writer.into_inner().lend(cid, pos as u32).expect("IMEF: SetPredicitonServer request failure");
|
writer.into_inner().lend(cid, pos as u32).expect("IMEF: SetPredicitonServer request failure");
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ use log::{error, info};
|
||||||
use heapless::spsc::Queue;
|
use heapless::spsc::Queue;
|
||||||
use heapless::consts::U4;
|
use heapless::consts::U4;
|
||||||
|
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
use rkyv::Deserialize;
|
||||||
|
use rkyv::ser::Serializer;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use rkyv::{archived_value, archived_value_mut};
|
use rkyv::{archived_value, archived_value_mut};
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ fn xmain() -> ! {
|
||||||
// the picked results
|
// the picked results
|
||||||
},
|
},
|
||||||
rkyv::Archived::<Opcode>::Picked(rkyv_s) => {
|
rkyv::Archived::<Opcode>::Picked(rkyv_s) => {
|
||||||
let s: xous::String<4000> = rkyv_s.deserialize();
|
let s: xous::String<4000> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
let mut local_s: xous::String<64> = xous::String::new();
|
let mut local_s: xous::String<64> = xous::String::new();
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
write!(local_s, "{:32}", s).expect("IME_SH: overflowed history variable");
|
write!(local_s, "{:32}", s).expect("IME_SH: overflowed history variable");
|
||||||
|
|
@ -79,7 +80,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<Opcode>::Prediction(pred_r) => {
|
rkyv::Archived::<Opcode>::Prediction(pred_r) => {
|
||||||
let mut prediction: Prediction = pred_r.deserialize();
|
let mut prediction: Prediction = pred_r.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
if debug1{info!("IME_SH: querying prediction index {}", prediction.index);}
|
if debug1{info!("IME_SH: querying prediction index {}", prediction.index);}
|
||||||
if debug1{info!("IME_SH: {:?}", prediction);}
|
if debug1{info!("IME_SH: {:?}", prediction);}
|
||||||
if history.len() > 0 && ((prediction.index as usize) < history.len()) {
|
if history.len() > 0 && ((prediction.index as usize) < history.len()) {
|
||||||
|
|
@ -131,10 +132,9 @@ fn xmain() -> ! {
|
||||||
if debug1{info!("IME_SH: returning index {} string {:?}", prediction.index, prediction.string);}
|
if debug1{info!("IME_SH: returning index {} string {:?}", prediction.index, prediction.string);}
|
||||||
|
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
|
||||||
let ret_op = Opcode::Prediction(prediction);
|
let ret_op = Opcode::Prediction(prediction);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let _pos = writer.archive(&ret_op).expect("IME_SH: Prediction query couldn't re-archive return value");
|
let _pos = writer.serialize_value(&ret_op).expect("IME_SH: Prediction query couldn't re-archive return value");
|
||||||
if debug1{info!("IME_SH: archived with pos {}", _pos);}
|
if debug1{info!("IME_SH: archived with pos {}", _pos);}
|
||||||
},
|
},
|
||||||
_ => error!("IME_SH: Got invalid MutableBorrow")
|
_ => error!("IME_SH: Got invalid MutableBorrow")
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ log-server = { path = "../log-server" }
|
||||||
ticktimer-server = { path = "../ticktimer-server" }
|
ticktimer-server = { path = "../ticktimer-server" }
|
||||||
xous-names = { path = "../xous-names" }
|
xous-names = { path = "../xous-names" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rkyv = { version = "0.3.1", default_features = false }
|
|
||||||
|
[dependencies.rkyv]
|
||||||
|
version = "0.4.1"
|
||||||
|
default-features = false
|
||||||
|
features = ["const_generics"]
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utralib = { path = "../../utralib"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@
|
||||||
/// are calling these functions inside a different process.
|
/// are calling these functions inside a different process.
|
||||||
pub mod api;
|
pub mod api;
|
||||||
use api::*;
|
use api::*;
|
||||||
|
use rkyv::Deserialize;
|
||||||
|
|
||||||
use xous::{send_message, CID};
|
use xous::{send_message, CID, XousDeserializer};
|
||||||
|
|
||||||
// used by the LLIO to send a response to other servers
|
// used by the LLIO to send a response to other servers
|
||||||
pub fn send_i2c_response(cid: CID, transaction: I2cTransaction) -> Result<(), xous::Error> {
|
pub fn send_i2c_response(cid: CID, transaction: I2cTransaction) -> Result<(), xous::Error> {
|
||||||
|
|
@ -28,13 +29,13 @@ pub fn send_i2c_request(cid: CID, transaction: I2cTransaction) -> Result<I2cStat
|
||||||
use rkyv::ser::Serializer;
|
use rkyv::ser::Serializer;
|
||||||
writer.serialize_value(&op).expect("LLIO_API: couldn't archive I2cTxRx")
|
writer.serialize_value(&op).expect("LLIO_API: couldn't archive I2cTxRx")
|
||||||
};
|
};
|
||||||
let buf = writer.into_inner();
|
let mut buf = writer.into_inner();
|
||||||
|
|
||||||
buf.lend_mut(cid, pos as u32).expect("LLIO_API: I2cTxRx operation failure");
|
buf.lend_mut(cid, pos as u32).expect("LLIO_API: I2cTxRx operation failure");
|
||||||
|
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(buf.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(buf.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::I2cTxRx(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::I2cTxRx(result) = returned {
|
||||||
let transaction = result.deserialise();
|
let transaction = result.deserialize(&mut XousDeserializer).expect("LLIO_API: Can't deserialize result in send_i2c_request");
|
||||||
Ok(transaction.status())
|
Ok(transaction.status())
|
||||||
} else {
|
} else {
|
||||||
log::info!("send_i2c_request saw an unhandled return type of {:?}", buf);
|
log::info!("send_i2c_request saw an unhandled return type of {:?}", buf);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ use i2c::*;
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use rkyv::archived_value;
|
use rkyv::archived_value;
|
||||||
use rkyv::Unarchive;
|
use rkyv::ser::Serializer;
|
||||||
|
use rkyv::Deserialize;
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
|
||||||
|
|
@ -597,15 +598,16 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<Opcode>::I2cTxRx(rkyv_i2c) => {
|
rkyv::Archived::<Opcode>::I2cTxRx(rkyv_i2c) => {
|
||||||
let mut i2c_txrx: I2cTransaction = rkyv_i2c.deserialize();
|
let mut i2c_txrx: I2cTransaction = rkyv_i2c.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
|
|
||||||
let status = i2c_machine.initiate(i2c_txrx);
|
let status = i2c_machine.initiate(i2c_txrx);
|
||||||
|
|
||||||
i2c_txrx.status = status;
|
i2c_txrx.status = status;
|
||||||
// pack our data back into the buffer to return
|
// pack our data back into the buffer to return
|
||||||
use rkyv::Write;
|
let mut writer = rkyv::ser::serializers::BufferSerializer::new(buf);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(buf);
|
let pos = writer
|
||||||
writer.archive(&Opcode::I2cTxRx(i2c_txrx)).expect("LLIO: couldn't re-archive return value to I2cTxRx");
|
.serialize_value(&Opcode::I2cTxRx(i2c_txrx))
|
||||||
|
.expect("LLIO: couldn't archive self");
|
||||||
},
|
},
|
||||||
_ => panic!("LLIO: invalid MutableBorrow memory message")
|
_ => panic!("LLIO: invalid MutableBorrow memory message")
|
||||||
};
|
};
|
||||||
|
|
@ -617,7 +619,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<api::Opcode>::I2cSubscribe(registration) => {
|
rkyv::Archived::<api::Opcode>::I2cSubscribe(registration) => {
|
||||||
let reg: xous::String::<64> = registration.unarchive();
|
let reg: xous::String::<64> = registration.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
let cid = xous_names::request_connection_blocking(reg.to_str()).expect("KBD: can't connect to requested listener for reporting events");
|
let cid = xous_names::request_connection_blocking(reg.to_str()).expect("KBD: can't connect to requested listener for reporting events");
|
||||||
i2c_machine.register_listener(cid).expect("LLIO: probably ran out of slots for I2C event reporting");
|
i2c_machine.register_listener(cid).expect("LLIO: probably ran out of slots for I2C event reporting");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,13 @@ graphics-server = {path="../graphics-server"}
|
||||||
ime-plugin-api = {path="../ime-plugin-api"}
|
ime-plugin-api = {path="../ime-plugin-api"}
|
||||||
content-plugin-api = {path="../content-plugin-api"} # all content canvas providers must provide this API
|
content-plugin-api = {path="../content-plugin-api"} # all content canvas providers must provide this API
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rkyv = { version = "0.3.1", default_features = false }
|
|
||||||
com={path="../com"}
|
com={path="../com"}
|
||||||
llio={path="../llio"}
|
llio={path="../llio"}
|
||||||
|
|
||||||
|
[dependencies.rkyv]
|
||||||
|
version = "0.4.1"
|
||||||
|
default-features = false
|
||||||
|
features = ["const_generics"]
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utralib = { path = "../../utralib"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use log::{error, info};
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
use rkyv::Serialize, rkyv::Deserialize;
|
use rkyv::Deserialize;
|
||||||
use rkyv::archived_value;
|
use rkyv::archived_value;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
match &*value {
|
match &*value {
|
||||||
rkyv::Archived::<ime_plugin_api::ImefOpcode>::GotInputLine(rkyv_s) => {
|
rkyv::Archived::<ime_plugin_api::ImefOpcode>::GotInputLine(rkyv_s) => {
|
||||||
let s: xous::String<4000> = rkyv_s.deserialize();
|
let s: xous::String<4000> = rkyv_s.deserialize(&mut xous::XousDeserializer).unwrap();
|
||||||
repl.input(s.as_str().expect("SHCH: couldn't convert incoming string")).expect("SHCH: REPL couldn't accept input string");
|
repl.input(s.as_str().expect("SHCH: couldn't convert incoming string")).expect("SHCH: REPL couldn't accept input string");
|
||||||
update_repl = true; // set a flag, instead of calling here, so message can drop and calling server is released
|
update_repl = true; // set a flag, instead of calling here, so message can drop and calling server is released
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use xous::CID;
|
use xous::CID;
|
||||||
|
use hash32::{Hash, Hasher};
|
||||||
|
|
||||||
// bottom 16 bits are reserved for structure re-use by other servers
|
// bottom 16 bits are reserved for structure re-use by other servers
|
||||||
pub const ID_REGISTER_NAME: u32 = 0x1_0000;
|
pub const ID_REGISTER_NAME: u32 = 0x1_0000;
|
||||||
|
|
@ -86,6 +87,52 @@ impl XousServerName {
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
pub fn new() -> XousServerName {
|
||||||
|
XousServerName {
|
||||||
|
value: [0; 64],
|
||||||
|
length: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_str(src: &str) -> XousServerName {
|
||||||
|
let mut s = Self::new();
|
||||||
|
// Copy the string into our backing store.
|
||||||
|
for (&src_byte, dest_byte) in src.as_bytes().iter().zip(&mut s.value) {
|
||||||
|
*dest_byte = src_byte;
|
||||||
|
}
|
||||||
|
// Set the string length to the length of the passed-in String,
|
||||||
|
// or the maximum possible length. Which ever is smaller.
|
||||||
|
s.length = s.value.len().min(src.as_bytes().len()) as u32;
|
||||||
|
|
||||||
|
// If the string is not valid, set its length to 0.
|
||||||
|
if s.as_str().is_err() {
|
||||||
|
s.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_bytes(&self) -> [u8; 64] {
|
||||||
|
self.value
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_str(&self) -> core::result::Result<&str, core::str::Utf8Error> {
|
||||||
|
core::str::from_utf8(&self.value[0..self.length as usize])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
self.length as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.length == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clear the contents and set the length to 0
|
||||||
|
pub fn clear(&mut self) {
|
||||||
|
self.length = 0;
|
||||||
|
self.value = [0; 64];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow using the `write!()` macro to write into a `&XousServerName`
|
// Allow using the `write!()` macro to write into a `&XousServerName`
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
extern crate hash32_derive;
|
extern crate hash32_derive;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
|
use api::*;
|
||||||
use xous::buffer;
|
use xous::buffer;
|
||||||
|
|
||||||
// use heapless::String;
|
// use heapless::String;
|
||||||
|
|
@ -44,7 +45,7 @@ fn xmain() -> ! {
|
||||||
};
|
};
|
||||||
let new_value = match &*value {
|
let new_value = match &*value {
|
||||||
rkyv::Archived::<api::Request>::Register(registration_name) => {
|
rkyv::Archived::<api::Request>::Register(registration_name) => {
|
||||||
let name = xous::String::<64>::from_str(registration_name.as_str());
|
let name = XousServerName::from_str(registration_name.as_str());
|
||||||
if debug1{info!("NS: registration request for '{}'", name);}
|
if debug1{info!("NS: registration request for '{}'", name);}
|
||||||
if !name_table.contains_key(&name) {
|
if !name_table.contains_key(&name) {
|
||||||
let new_sid =
|
let new_sid =
|
||||||
|
|
@ -70,7 +71,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rkyv::Archived::<api::Request>::Lookup(lookup_name) => {
|
rkyv::Archived::<api::Request>::Lookup(lookup_name) => {
|
||||||
let name = xous::String::<64>::from_str(lookup_name.as_str());
|
let name = XousServerName::from_str(lookup_name.as_str());
|
||||||
if debug1{info!("NS: Lookup request for '{}'", name);}
|
if debug1{info!("NS: Lookup request for '{}'", name);}
|
||||||
if let Some(server_sid) = name_table.get(&name) {
|
if let Some(server_sid) = name_table.get(&name) {
|
||||||
let sender_pid = envelope
|
let sender_pid = envelope
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,12 @@ impl<S: rkyv::ser::Serializer + ?Sized, const N: usize> rkyv::Serialize<S> for S
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
use rkyv::Fallible;
|
||||||
|
impl<D: Fallible + ?Sized, const N: usize> rkyv::Deserialize<String<N>, D> for ArchivedString {
|
||||||
|
fn deserialize(&self, _deserializer: &mut D) -> core::result::Result<String<N>, D::Error> {
|
||||||
|
Ok(String::<N>::from_str(self.as_str()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<const N: usize> PartialEq for String<N> {
|
impl<const N: usize> PartialEq for String<N> {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
|
@ -283,3 +289,10 @@ impl<const N: usize> PartialEq for String<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const N: usize> Eq for String<N> {}
|
impl<const N: usize> Eq for String<N> {}
|
||||||
|
|
||||||
|
// a "no-op" deserializer for in-place data, required for rkyv 0.4.1
|
||||||
|
// perhaps in rkyv 0.5 this will go away, see https://github.com/djkoloski/rkyv/issues/67
|
||||||
|
pub struct XousDeserializer;
|
||||||
|
impl rkyv::Fallible for XousDeserializer {
|
||||||
|
type Error = crate::Error;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue