13 assert(size > 0 &&
"IoBuffer size must be greater than 0");
14 assert((alignment & (alignment - 1)) == 0 &&
15 "IoBuffer alignment must be a power of 2");
17 auto* data =
static_cast<uint8_t*
>(
aligned_alloc(alignment, size));
18 assert(data !=
nullptr &&
"IoBuffer aligned_alloc failed");
25 "IoBuffer invariant violated: data_ and size_ must be consistent");
30 other.data_ =
nullptr;
35 assert(
this != &other &&
"Self-move assignment is not allowed");
37 if (data_ !=
nullptr) {
42 other.data_ =
nullptr;
59 .phys = v2p(
reinterpret_cast<uintptr_t
>(data_)),
auto GetBuffer() const -> std::span< const uint8_t >
获取缓冲区数据与大小 (只读)
auto ToDmaRegion(VirtToPhysFunc v2p=IdentityVirtToPhys) const -> DmaRegion
创建此缓冲区的 DmaRegion 视图
auto operator=(const IoBuffer &) -> IoBuffer &=delete
auto IsValid() const -> bool
检查缓冲区是否有效
auto(*)(uintptr_t virt) -> uintptr_t VirtToPhysFunc
虚拟地址到物理地址转换回调类型
void aligned_free(void *ptr)
void * aligned_alloc(size_t alignment, size_t size)
void * virt
虚拟(CPU 可访问)基地址