sel4/arch/riscv/
invocations.rs
1use crate::{
8 cap::*, cap_type, AbsoluteCPtr, Cap, CapRights, CapTypeForFrameObject, Error,
9 InvocationContext, Result, TranslationTableObjectType, VmAttributes,
10};
11
12impl<T: CapTypeForFrameObject, C: InvocationContext> Cap<T, C> {
13 pub fn frame_map(
15 self,
16 page_table: PageTable,
17 vaddr: usize,
18 rights: CapRights,
19 attrs: VmAttributes,
20 ) -> Result<()> {
21 Error::wrap(self.invoke(|cptr, ipc_buffer| {
22 ipc_buffer.inner_mut().seL4_RISCV_Page_Map(
23 cptr.bits(),
24 page_table.bits(),
25 vaddr.try_into().unwrap(),
26 rights.into_inner(),
27 attrs.into_inner(),
28 )
29 }))
30 }
31
32 pub fn frame_unmap(self) -> Result<()> {
34 Error::wrap(
35 self.invoke(|cptr, ipc_buffer| {
36 ipc_buffer.inner_mut().seL4_RISCV_Page_Unmap(cptr.bits())
37 }),
38 )
39 }
40
41 pub fn frame_get_address(self) -> Result<usize> {
43 let ret = self.invoke(|cptr, ipc_buffer| {
44 ipc_buffer
45 .inner_mut()
46 .seL4_RISCV_Page_GetAddress(cptr.bits())
47 });
48 match Error::from_sys(ret.error) {
49 None => Ok(ret.paddr.try_into().unwrap()),
50 Some(err) => Err(err),
51 }
52 }
53}
54
55impl<C: InvocationContext> PageTable<C> {
56 pub fn page_table_map(self, vspace: PageTable, vaddr: usize, attr: VmAttributes) -> Result<()> {
57 Error::wrap(self.invoke(|cptr, ipc_buffer| {
58 ipc_buffer.inner_mut().seL4_RISCV_PageTable_Map(
59 cptr.bits(),
60 vspace.bits(),
61 vaddr.try_into().unwrap(),
62 attr.into_inner(),
63 )
64 }))
65 }
66}
67
68impl<C: InvocationContext> UnspecifiedIntermediateTranslationTable<C> {
69 pub fn generic_intermediate_translation_table_map(
70 self,
71 ty: TranslationTableObjectType,
72 vspace: VSpace,
73 vaddr: usize,
74 attr: VmAttributes,
75 ) -> Result<()> {
76 match ty {
77 TranslationTableObjectType::PageTable => self
78 .cast::<cap_type::PageTable>()
79 .page_table_map(vspace, vaddr, attr),
80 }
81 }
82}
83
84impl<C: InvocationContext> AsidControl<C> {
85 pub fn asid_control_make_pool(self, untyped: Untyped, dst: &AbsoluteCPtr) -> Result<()> {
87 Error::wrap(self.invoke(|cptr, ipc_buffer| {
88 ipc_buffer.inner_mut().seL4_RISCV_ASIDControl_MakePool(
89 cptr.bits(),
90 untyped.bits(),
91 dst.root().bits(),
92 dst.path().bits(),
93 dst.path().depth_for_kernel(),
94 )
95 }))
96 }
97}
98
99impl<C: InvocationContext> AsidPool<C> {
100 pub fn asid_pool_assign(self, vspace: PageTable) -> Result<()> {
102 Error::wrap(self.invoke(|cptr, ipc_buffer| {
103 ipc_buffer
104 .inner_mut()
105 .seL4_RISCV_ASIDPool_Assign(cptr.bits(), vspace.bits())
106 }))
107 }
108}