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

Method Submit

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

* @brief 将描述符链提交到 Available Ring * * 将描述符链的头部索引放入 Available Ring,使其对设备可见。 * 调用此方法后,调用者应使用内存屏障确保 idx 更新对设备可见, * 然后通过 Transport::NotifyQueue() 通知设备。 * * @param head 描述符链头部索引(必须为有效的已分配描述符) * * @note 调用者必须在调用此方法前确保描述符写入已完成 * @note 调用者必须在调用此方法后通知设备(如 Transport::NotifyQueue()) * * @see cpu_io::Wmb() 用于确保 ring 写入在 idx 更新之前对设备可见 * * @warning 非线程安全:多个线程同时调用可能导致竞态条件

Source from the content-addressed store, hash-verified

378 * @see virtio-v1.2#2.7.13 Supplying Buffers to The Device
379 */
380 auto Submit(uint16_t head) -> void {
381 uint16_t idx = avail_->idx;
382 avail_->ring[idx % queue_size_] = head;
383
384 // 写屏障:确保 ring 写入在 idx 更新之前对设备可见
385 cpu_io::Wmb();
386
387 avail_->idx = idx + 1;
388 }
389
390 /**
391 * @brief 检查 Used Ring 中是否有已完成的缓冲区

Callers

nothing calls this directly

Calls 1

WmbFunction · 0.85

Tested by

no test coverage detected