提交读请求 / Submit a read request.
160{
162 {
164 }
165
166 if (!TryClaimIdle())
167 {
169 }
170
171 const bool is_block = op.
type == ReadOperation::OperationType::BLOCK;
172
173 if (data.
size_ != 0U)
174 {
175 ASSERT_FROM_CALLBACK(data.
addr_ !=
nullptr, in_isr);
177 {
178 ReleaseClaimed(in_isr);
180 }
181 }
182
183 if (HasEnough(queue_data_->
Size(), data.
size_))
184 {
185 if (data.
size_ != 0U)
186 {
187 [[maybe_unused]] const auto pop_batch_result =
189 DEV_ASSERT_FROM_CALLBACK(pop_batch_result ==
ErrorCode::OK, in_isr);
190 }
191
192 Request completed{data, op};
193 ReleaseClaimed(in_isr);
194 if (data.
size_ != 0U)
195 {
197 }
198 if (completed.op.type != ReadOperation::OperationType::BLOCK)
199 {
201 }
203 }
204
205 info_ = Request{data, op};
207
208 for (;;)
209 {
210 uint32_t observed = state_.load(std::memory_order_acquire);
211 DEV_ASSERT_FROM_CALLBACK(GetPhase(observed) == Phase::CLAIMED, in_isr);
212
213 if (HasEvent(observed))
214 {
215 if (!state_.compare_exchange_weak(observed, static_cast<uint32_t>(Phase::CLAIMED),
216 std::memory_order_acq_rel,
217 std::memory_order_acquire))
218 {
219 continue;
220 }
221
222 if (HasEnough(queue_data_->
Size(), data.
size_))
223 {
224 if (info_.op.
type == ReadOperation::OperationType::BLOCK)
225 {
226 CompleteClaimedBlock(in_isr);
227 return WaitForBlock(op);
228 }
229 CompleteClaimedRead(in_isr);
231 }
232 continue;
233 }
234
235 uint32_t expected = observed;
236 if (state_.compare_exchange_weak(expected, static_cast<uint32_t>(Phase::PENDING),
237 std::memory_order_acq_rel,
238 std::memory_order_acquire))
239 {
240 break;
241 }
242 }
243
244 return is_block ? WaitForBlock(op) :
ErrorCode::
OK;
245}
void MarkAsRunning()
标记轮询操作正在执行 / Mark a polling operation as running.
OperationType type
当前通知方式 / Current notification mode.
size_t size_
数据字节数 / Data size in bytes
void * addr_
数据起始地址 / Data start address
size_t Capacity() const
获取接收队列容量 / Get the RX queue capacity.
size_t Size() const
获取当前已用元素数 / Get the current element count
ErrorCode PopBatch(Data *data, size_t size)
批量弹出多个 payload / Pop multiple payloads from the queue.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ SIZE_ERR
尺寸错误 / Size error