feat: uapi: update endpoint info

This commit is contained in:
Paul Pan 2024-09-04 21:28:37 +08:00
parent 86dbca7ef5
commit 93dabb523b
3 changed files with 11 additions and 16 deletions

View File

@ -62,7 +62,6 @@ impl Debug for CapEntry {
ObjectType::Table => write!(f, "{:?}", TableCap::try_from(self)), ObjectType::Table => write!(f, "{:?}", TableCap::try_from(self)),
ObjectType::TCB => write!(f, "{:?}", TcbCap::try_from(self)), ObjectType::TCB => write!(f, "{:?}", TcbCap::try_from(self)),
ObjectType::Untyped => write!(f, "{:?}", UntypedCap::try_from(self)), ObjectType::Untyped => write!(f, "{:?}", UntypedCap::try_from(self)),
_ => write!(f, "UnknownCap"),
} }
} }
} }

View File

@ -24,6 +24,7 @@ pub struct EndpointObject {
} }
const_assert!(usize::BITS as usize >= IRQ_NUM); const_assert!(usize::BITS as usize >= IRQ_NUM);
const_assert!(core::mem::size_of::<EndpointObject>() <= ObjectType::Endpoint.size(0));
impl KernelObject for EndpointObject { impl KernelObject for EndpointObject {
const OBJ_TYPE: ObjectType = ObjectType::Endpoint; const OBJ_TYPE: ObjectType = ObjectType::Endpoint;

View File

@ -1,15 +1,12 @@
#[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimitive, ToPrimitive)] #[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimitive, ToPrimitive)]
pub enum ObjectType { pub enum ObjectType {
Null = 0, Null = 0,
CNode = 1, CNode = 1,
TCB = 2, TCB = 2,
Endpoint = 3, Endpoint = 3,
Reply = 4, Frame = 4,
Notification = 5, Table = 5,
Frame = 6, Untyped = 6,
Table = 7,
Interrupt = 8,
Untyped = 9,
} }
impl Default for ObjectType { impl Default for ObjectType {
@ -19,8 +16,9 @@ impl Default for ObjectType {
} }
impl 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 TCB_BITS: usize = 10; // 672 bytes
const ENDPOINT_BITS: usize = 6; // 40 bytes
pub const fn size(&self, user_obj_bits: usize) -> usize { pub const fn size(&self, user_obj_bits: usize) -> usize {
1 << self.bits(user_obj_bits) 1 << self.bits(user_obj_bits)
@ -32,12 +30,9 @@ impl ObjectType {
ObjectType::Null => 0, ObjectType::Null => 0,
ObjectType::CNode => Self::CNODE_BITS + user_obj_bits, ObjectType::CNode => Self::CNODE_BITS + user_obj_bits,
ObjectType::TCB => Self::TCB_BITS, ObjectType::TCB => Self::TCB_BITS,
ObjectType::Endpoint => 0, // TODO: fill it! ObjectType::Endpoint => Self::ENDPOINT_BITS,
ObjectType::Reply => 0, // TODO: fill it!
ObjectType::Notification => 0, // TODO: fill it!
ObjectType::Frame => user_obj_bits, ObjectType::Frame => user_obj_bits,
ObjectType::Table => user_obj_bits, // arch dependent page table size ObjectType::Table => user_obj_bits, // arch dependent page table size
ObjectType::Interrupt => 0, // TODO: fill it!
ObjectType::Untyped => user_obj_bits, ObjectType::Untyped => user_obj_bits,
} }
} }