Kernel: Add a conversion method from KBuffer to UserOrKernelBuffer

This commit is contained in:
Liav A. 2024-07-20 05:26:04 +03:00 committed by Tim Schumacher
parent 03ae9fdb0a
commit 98160e33c4

View file

@ -18,6 +18,7 @@
#include <AK/Assertions.h>
#include <AK/StringView.h>
#include <Kernel/Library/StdLib.h> // For memcpy. FIXME: Make memcpy less expensive to access a declaration of in the Kernel.
#include <Kernel/Library/UserOrKernelBuffer.h>
#include <Kernel/Memory/MemoryManager.h>
namespace Kernel {
@ -38,6 +39,8 @@ public:
return buffer;
}
UserOrKernelBuffer as_kernel_buffer() { return UserOrKernelBuffer::for_kernel_buffer(data()); }
[[nodiscard]] u8* data() { return m_region->vaddr().as_ptr(); }
[[nodiscard]] u8 const* data() const { return m_region->vaddr().as_ptr(); }
[[nodiscard]] size_t size() const { return m_size; }