mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
Kernel: Allow naming KBuffers
This commit is contained in:
parent
2309029cb4
commit
0a282e0a02
1 changed files with 10 additions and 10 deletions
|
@ -43,16 +43,16 @@
|
||||||
|
|
||||||
class KBufferImpl : public RefCounted<KBufferImpl> {
|
class KBufferImpl : public RefCounted<KBufferImpl> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<KBufferImpl> create_with_size(size_t size, u8 access)
|
static NonnullRefPtr<KBufferImpl> create_with_size(size_t size, u8 access, const char* name)
|
||||||
{
|
{
|
||||||
auto region = MM.allocate_kernel_region(PAGE_ROUND_UP(size), "KBuffer", access, false, false);
|
auto region = MM.allocate_kernel_region(PAGE_ROUND_UP(size), name, access, false, false);
|
||||||
ASSERT(region);
|
ASSERT(region);
|
||||||
return adopt(*new KBufferImpl(region.release_nonnull(), size));
|
return adopt(*new KBufferImpl(region.release_nonnull(), size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static NonnullRefPtr<KBufferImpl> copy(const void* data, size_t size, u8 access)
|
static NonnullRefPtr<KBufferImpl> copy(const void* data, size_t size, u8 access, const char* name)
|
||||||
{
|
{
|
||||||
auto buffer = create_with_size(size, access);
|
auto buffer = create_with_size(size, access, name);
|
||||||
memcpy(buffer->data(), data, size);
|
memcpy(buffer->data(), data, size);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ private:
|
||||||
|
|
||||||
class KBuffer {
|
class KBuffer {
|
||||||
public:
|
public:
|
||||||
static KBuffer create_with_size(size_t size, u8 access = Region::Access::Read | Region::Access::Write)
|
static KBuffer create_with_size(size_t size, u8 access = Region::Access::Read | Region::Access::Write, const char* name = "KBuffer")
|
||||||
{
|
{
|
||||||
return KBuffer(KBufferImpl::create_with_size(size, access));
|
return KBuffer(KBufferImpl::create_with_size(size, access, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
static KBuffer copy(const void* data, size_t size, u8 access = Region::Access::Read | Region::Access::Write)
|
static KBuffer copy(const void* data, size_t size, u8 access = Region::Access::Read | Region::Access::Write, const char* name = "KBuffer")
|
||||||
{
|
{
|
||||||
return KBuffer(KBufferImpl::copy(data, size, access));
|
return KBuffer(KBufferImpl::copy(data, size, access, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* data() { return m_impl->data(); }
|
u8* data() { return m_impl->data(); }
|
||||||
|
@ -100,8 +100,8 @@ public:
|
||||||
|
|
||||||
const KBufferImpl& impl() const { return m_impl; }
|
const KBufferImpl& impl() const { return m_impl; }
|
||||||
|
|
||||||
KBuffer(const ByteBuffer& buffer, u8 access = Region::Access::Read | Region::Access::Write)
|
KBuffer(const ByteBuffer& buffer, u8 access = Region::Access::Read | Region::Access::Write, const char* name = "KBuffer")
|
||||||
: m_impl(KBufferImpl::copy(buffer.data(), buffer.size(), access))
|
: m_impl(KBufferImpl::copy(buffer.data(), buffer.size(), access, name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue