MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / PopUsed

Method PopUsed

src/device/virtio/virt_queue/split.hpp:417–430  ·  view source on GitHub ↗

* @brief 从 Used Ring 弹出一个已完成的元素 * * 从 Used Ring 中取出下一个设备已处理完成的缓冲区。 * 返回的 UsedElem 包含: * - id: 描述符链头索引(对应之前提交的 head) * - len: 设备写入的字节数(仅对 Device-writable 缓冲区有意义) * * @return 成功返回 UsedElem{id, len}; * 无可用元素时返回 ErrorCode::kNoUsedBuffers * * @warning 非线程安全:多个线程同时调用可能导致竞态条件 * @see virtio-v1.2#2.7.14 Receiving Used Buffers From The Device */

Source from the content-addressed store, hash-verified

415 * @see virtio-v1.2#2.7.14 Receiving Used Buffers From The Device
416 */
417 [[nodiscard]] auto PopUsed() -> Expected<UsedElem> {
418 if (!HasUsed()) {
419 return std::unexpected(Error{ErrorCode::kNoUsedBuffers});
420 }
421
422 uint16_t idx = last_used_idx_ % queue_size_;
423 UsedElem elem;
424 elem.id = used_->ring[idx].id;
425 elem.len = used_->ring[idx].len;
426
427 ++last_used_idx_;
428
429 return elem;
430 }
431
432 /**
433 * @brief 提交 Scatter-Gather 描述符链

Callers 2

ProcessCompletionsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected