* <!-- description --> * @brief This function allocates read/write virtual memory from the * kernel. This memory is physically contiguous. The resulting * pointer is at least 4k aligned, so use this function sparingly * as it will always allocate at least one page. Use * platform_free_contiguous() to release this memory. * * @note This function must zero the allocated me
| 121 | * Returns a nullptr on failure. |
| 122 | */ |
| 123 | NODISCARD void * |
| 124 | platform_alloc_contiguous(uint64_t const size) NOEXCEPT |
| 125 | { |
| 126 | void *mut_ret; |
| 127 | |
| 128 | if (0 == size) { |
| 129 | bferror("invalid number of bytes (i.e., size)"); |
| 130 | return NULLPTR; |
| 131 | } |
| 132 | |
| 133 | mut_ret = kmalloc(size, GFP_KERNEL); |
| 134 | if (NULLPTR == mut_ret) { |
| 135 | bferror("kmalloc failed"); |
| 136 | return NULLPTR; |
| 137 | } |
| 138 | |
| 139 | return memset(mut_ret, 0, size); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * <!-- description --> |