mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
pddb: rework PddbBuf ordering to be non-packed
The new ordering remains the same size, but is no longer `#[repr(packed)]`. This allows it to be `#[repr(align(4096))]` which means we can get away with using a stack page for this struct instead of allocating a new object every time. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1388da7680
commit
8cd04c3415
1 changed files with 16 additions and 9 deletions
|
|
@ -142,12 +142,14 @@ pub(crate) enum PollOp {
|
||||||
|
|
||||||
pub type ApiToken = [u32; 3];
|
pub type ApiToken = [u32; 3];
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct PddbBasisList {
|
pub struct PddbBasisList {
|
||||||
/// the first 63 that fit in the list -- generally we anticipate not more than a few being open at a time, so this should be enough.
|
/// the first 63 that fit in the list -- generally we anticipate not more than a few being open at a time, so this should be enough.
|
||||||
pub list: [xous_ipc::String::<BASIS_NAME_LEN>; 63],
|
pub list: [xous_ipc::String::<BASIS_NAME_LEN>; 63],
|
||||||
/// total number of basis open. Should be <= 63, but we allow it to be larger to indicate cases where this structure wasn't big enough.
|
/// total number of basis open. Should be <= 63, but we allow it to be larger to indicate cases where this structure wasn't big enough.
|
||||||
pub num: u32,
|
pub num: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub enum PddbRequestCode {
|
pub enum PddbRequestCode {
|
||||||
Create = 0,
|
Create = 0,
|
||||||
|
|
@ -222,26 +224,31 @@ pub(crate) enum PddbRetcode {
|
||||||
InternalError = 5,
|
InternalError = 5,
|
||||||
DiskFull = 6,
|
DiskFull = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// PddbBuf is a C-representation of a page of memory that's used
|
/// PddbBuf is a C-representation of a page of memory that's used
|
||||||
/// to shuttle data for streaming channels. It must be exactly one
|
/// to shuttle data for streaming channels. It must be exactly one
|
||||||
/// page in size, with some overhead specific to the PDDB book-keeping
|
/// page in size, with some overhead specific to the PDDB book-keeping
|
||||||
/// at the top, and the remainder available for shuttling data.
|
/// at the top, and the remainder available for shuttling data.
|
||||||
///
|
#[repr(C, align(4096))]
|
||||||
/// It does not use rkyv, as the blanket implementation of that tends to
|
|
||||||
/// incur too many extra copies an/or zeroing operations.
|
|
||||||
#[repr(C, packed)]
|
|
||||||
pub(crate) struct PddbBuf {
|
pub(crate) struct PddbBuf {
|
||||||
/// api token for the given buffer
|
/// api token for the given buffer
|
||||||
pub(crate) token: ApiToken,
|
pub(crate) token: ApiToken,
|
||||||
/// point in the key stream. 64-bit for future-compatibility; but, can't be larger than 32 bits on a 32-bit target.
|
|
||||||
pub(crate) position: u64,
|
|
||||||
/// length of the data field
|
|
||||||
pub(crate) len: u16,
|
|
||||||
/// a field reserved for the return code
|
/// a field reserved for the return code
|
||||||
pub(crate) retcode: PddbRetcode,
|
pub(crate) retcode: PddbRetcode,
|
||||||
pub(crate) reserved: u8,
|
reserved: u8,
|
||||||
|
/// length of the data field
|
||||||
|
pub(crate) len: u16,
|
||||||
|
/// point in the key stream. 64-bit for future-compatibility; but, can't be larger than 32 bits on a 32-bit target.
|
||||||
|
pub(crate) position: u64,
|
||||||
pub(crate) data: [u8; 4072],
|
pub(crate) data: [u8; 4072],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
/// Ensure that the `PddbBuf` struct is exactly one page big
|
||||||
|
const fn _assert_pddbbuf_is_4096_bytes() {
|
||||||
|
unsafe { core::mem::transmute::<_, PddbBuf>([0u8; 4096]); }
|
||||||
|
}
|
||||||
|
|
||||||
impl PddbBuf {
|
impl PddbBuf {
|
||||||
pub(crate) fn from_slice_mut(slice: &mut [u8]) -> &mut PddbBuf {
|
pub(crate) fn from_slice_mut(slice: &mut [u8]) -> &mut PddbBuf {
|
||||||
// this transforms the slice [u8] into a PddbBuf ref.
|
// this transforms the slice [u8] into a PddbBuf ref.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue