SimpleKernel 1.17.0
Loading...
Searching...
No Matches
misc.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <cstddef>
8#include <cstdint>
9
10namespace virtio {
11
20[[nodiscard]] constexpr auto AlignUp(size_t value, size_t align) -> size_t {
21 return (value + align - 1) & ~(align - 1);
22}
23
32[[nodiscard]] constexpr auto IsPowerOfTwo(size_t value) -> bool {
33 return value != 0 && (value & (value - 1)) == 0;
34}
35
43struct IoVec {
45 uintptr_t phys_addr;
47 size_t len;
48};
49
50} // namespace virtio
Definition defs.h:9
constexpr auto IsPowerOfTwo(size_t value) -> bool
检查值是否为 2 的幂
Definition misc.hpp:32
constexpr auto AlignUp(size_t value, size_t align) -> size_t
将值向上对齐到指定边界
Definition misc.hpp:20
Scatter-Gather IO 物理内存向量
Definition misc.hpp:43
size_t len
长度(字节)
Definition misc.hpp:47
uintptr_t phys_addr
物理地址(DMA 地址)
Definition misc.hpp:45