From 93dabb523b1604ad64471bcf3d174e3dd6bed74b Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Wed, 4 Sep 2024 21:28:37 +0800 Subject: [PATCH] feat: uapi: update endpoint info --- kernel/src/objects/cap.rs | 1 - kernel/src/objects/endpoint.rs | 1 + uapi/src/cap.rs | 25 ++++++++++--------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/kernel/src/objects/cap.rs b/kernel/src/objects/cap.rs index 30bcfc0..240d499 100644 --- a/kernel/src/objects/cap.rs +++ b/kernel/src/objects/cap.rs @@ -62,7 +62,6 @@ impl Debug for CapEntry { ObjectType::Table => write!(f, "{:?}", TableCap::try_from(self)), ObjectType::TCB => write!(f, "{:?}", TcbCap::try_from(self)), ObjectType::Untyped => write!(f, "{:?}", UntypedCap::try_from(self)), - _ => write!(f, "UnknownCap"), } } } diff --git a/kernel/src/objects/endpoint.rs b/kernel/src/objects/endpoint.rs index 43844e5..083d82f 100644 --- a/kernel/src/objects/endpoint.rs +++ b/kernel/src/objects/endpoint.rs @@ -24,6 +24,7 @@ pub struct EndpointObject { } const_assert!(usize::BITS as usize >= IRQ_NUM); +const_assert!(core::mem::size_of::() <= ObjectType::Endpoint.size(0)); impl KernelObject for EndpointObject { const OBJ_TYPE: ObjectType = ObjectType::Endpoint; diff --git a/uapi/src/cap.rs b/uapi/src/cap.rs index 9f64ef2..cf7de3d 100644 --- a/uapi/src/cap.rs +++ b/uapi/src/cap.rs @@ -1,15 +1,12 @@ #[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimitive, ToPrimitive)] pub enum ObjectType { - Null = 0, - CNode = 1, - TCB = 2, - Endpoint = 3, - Reply = 4, - Notification = 5, - Frame = 6, - Table = 7, - Interrupt = 8, - Untyped = 9, + Null = 0, + CNode = 1, + TCB = 2, + Endpoint = 3, + Frame = 4, + Table = 5, + Untyped = 6, } impl Default for ObjectType { @@ -19,8 +16,9 @@ impl Default for ObjectType { } impl ObjectType { - const CNODE_BITS: usize = 6; // 48 bytes + const CNODE_BITS: usize = 5; // 32 bytes const TCB_BITS: usize = 10; // 672 bytes + const ENDPOINT_BITS: usize = 6; // 40 bytes pub const fn size(&self, user_obj_bits: usize) -> usize { 1 << self.bits(user_obj_bits) @@ -32,12 +30,9 @@ impl ObjectType { ObjectType::Null => 0, ObjectType::CNode => Self::CNODE_BITS + user_obj_bits, ObjectType::TCB => Self::TCB_BITS, - ObjectType::Endpoint => 0, // TODO: fill it! - ObjectType::Reply => 0, // TODO: fill it! - ObjectType::Notification => 0, // TODO: fill it! + ObjectType::Endpoint => Self::ENDPOINT_BITS, ObjectType::Frame => user_obj_bits, ObjectType::Table => user_obj_bits, // arch dependent page table size - ObjectType::Interrupt => 0, // TODO: fill it! ObjectType::Untyped => user_obj_bits, } }