MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / to_values

Method to_values

kernel/src/message.rs:85–136  ·  view source on GitHub ↗

Convert a Message into values which will be returned to user code by the receive or send_receive syscalls. Includes moving Rendezvous and memory chunks into the receiving process' handles and page tables, calling give_rendezvous() and give_memory_chunk() methods. Note: No error return type because errors are indicated to the receiver in the values.

(
        &self,
        thread: &Thread
    )

Source from the content-addressed store, hash-verified

83 /// Note: No error return type because errors are indicated to the
84 /// receiver in the values.
85 pub fn to_values(
86 &self,
87 thread: &Thread
88 ) -> (u64, u64, u64, u64) {
89 match self {
90 Message::Short(data1, data2, data3) => (0, *data1, *data2, *data3),
91 Message::Long(data1, data2, data3) => {
92 let mut ctrl: u64 = 0; // No error
93
94 let value2 = match data2 {
95 MessageData::Value(value) => *value,
96 MessageData::Rendezvous(rdv) => {
97 ctrl |= MESSAGE_DATA2_RDV | MESSAGE_LONG;
98 thread.give_rendezvous(rdv.clone()) as u64
99 }
100 MessageData::Memory(physaddr) => {
101 match thread.give_memory_chunk(*physaddr) {
102 Ok(virtaddr) => {
103 ctrl |= MESSAGE_DATA2_MEM | MESSAGE_LONG;
104 virtaddr.as_u64()
105 }
106 Err(error_code) => {
107 ctrl |= MESSAGE_DATA2_ERR | MESSAGE_LONG;
108 error_code as u64
109 }
110 }
111 }
112 };
113
114 let value3 = match data3 {
115 MessageData::Value(value) => *value,
116 MessageData::Rendezvous(rdv) => {
117 ctrl |= MESSAGE_DATA3_RDV | MESSAGE_LONG;
118 thread.give_rendezvous(rdv.clone()) as u64
119 }
120 MessageData::Memory(physaddr) => {
121 match thread.give_memory_chunk(*physaddr) {
122 Ok(virtaddr) => {
123 ctrl |= MESSAGE_DATA3_MEM | MESSAGE_LONG;
124 virtaddr.as_u64()
125 }
126 Err(error_code) => {
127 ctrl |= MESSAGE_DATA3_ERR | MESSAGE_LONG;
128 error_code as u64
129 }
130 }
131 }
132 };
133 (ctrl, *data1, value2, value3)
134 }
135 }
136 }
137
138 /// Take data passed via syscall and convert to
139 /// a kernel Message object.

Callers 1

return_error_messageMethod · 0.45

Calls 4

give_rendezvousMethod · 0.80
cloneMethod · 0.80
give_memory_chunkMethod · 0.80
as_u64Method · 0.45

Tested by

no test coverage detected