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

Method SubRegion

src/include/io_buffer.hpp:66–76  ·  view source on GitHub ↗

* @brief 在指定偏移处创建子区域 * * @param offset 相对于当前区域起始处的字节偏移 * @param len 子区域的字节长度 * @return 成功返回子区域,越界则返回错误 * * @pre offset + len <= size * @post 返回的区域与当前区域共享同一底层内存 */

Source from the content-addressed store, hash-verified

64 * @post 返回的区域与当前区域共享同一底层内存
65 */
66 [[nodiscard]] auto SubRegion(size_t offset, size_t len) const
67 -> Expected<DmaRegion> {
68 if (offset > size || len > size - offset) {
69 return std::unexpected(Error{ErrorCode::kInvalidArgument});
70 }
71 return DmaRegion{
72 .virt = static_cast<uint8_t*>(virt) + offset,
73 .phys = phys + offset,
74 .size = len,
75 };
76 }
77};
78
79/**

Callers 1

TESTFunction · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64