mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
Kernel: Let's try disabling the CPU's page-level caching for framebuffers.
This commit is contained in:
parent
44e1a45b2a
commit
458706c4cf
2 changed files with 24 additions and 1 deletions
|
@ -483,6 +483,8 @@ void MemoryManager::remap_region_page(Region& region, unsigned page_index_in_reg
|
||||||
pte.set_writable(false);
|
pte.set_writable(false);
|
||||||
else
|
else
|
||||||
pte.set_writable(region.is_writable());
|
pte.set_writable(region.is_writable());
|
||||||
|
pte.set_cache_disabled(!region.vmo().m_allow_cpu_caching);
|
||||||
|
pte.set_write_through(!region.vmo().m_allow_cpu_caching);
|
||||||
pte.set_user_allowed(user_allowed);
|
pte.set_user_allowed(user_allowed);
|
||||||
region.page_directory()->flush(page_laddr);
|
region.page_directory()->flush(page_laddr);
|
||||||
#ifdef MM_DEBUG
|
#ifdef MM_DEBUG
|
||||||
|
@ -517,6 +519,8 @@ void MemoryManager::map_region_at_address(PageDirectory& page_directory, Region&
|
||||||
pte.set_writable(false);
|
pte.set_writable(false);
|
||||||
else
|
else
|
||||||
pte.set_writable(region.is_writable());
|
pte.set_writable(region.is_writable());
|
||||||
|
pte.set_cache_disabled(!region.vmo().m_allow_cpu_caching);
|
||||||
|
pte.set_write_through(!region.vmo().m_allow_cpu_caching);
|
||||||
} else {
|
} else {
|
||||||
pte.set_physical_page_base(0);
|
pte.set_physical_page_base(0);
|
||||||
pte.set_present(false);
|
pte.set_present(false);
|
||||||
|
@ -676,7 +680,9 @@ RetainPtr<VMObject> VMObject::create_anonymous(size_t size)
|
||||||
RetainPtr<VMObject> VMObject::create_framebuffer_wrapper(PhysicalAddress paddr, size_t size)
|
RetainPtr<VMObject> VMObject::create_framebuffer_wrapper(PhysicalAddress paddr, size_t size)
|
||||||
{
|
{
|
||||||
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
||||||
return adopt(*new VMObject(paddr, size));
|
auto vmo = adopt(*new VMObject(paddr, size));
|
||||||
|
vmo->m_allow_cpu_caching = false;
|
||||||
|
return vmo;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetainPtr<VMObject> VMObject::clone()
|
RetainPtr<VMObject> VMObject::clone()
|
||||||
|
|
|
@ -114,6 +114,7 @@ private:
|
||||||
bool m_anonymous { false };
|
bool m_anonymous { false };
|
||||||
off_t m_inode_offset { 0 };
|
off_t m_inode_offset { 0 };
|
||||||
size_t m_size { 0 };
|
size_t m_size { 0 };
|
||||||
|
bool m_allow_cpu_caching { true };
|
||||||
RetainPtr<Inode> m_inode;
|
RetainPtr<Inode> m_inode;
|
||||||
Vector<RetainPtr<PhysicalPage>> m_physical_pages;
|
Vector<RetainPtr<PhysicalPage>> m_physical_pages;
|
||||||
Lock m_paging_lock;
|
Lock m_paging_lock;
|
||||||
|
@ -292,6 +293,8 @@ private:
|
||||||
Present = 1 << 0,
|
Present = 1 << 0,
|
||||||
ReadWrite = 1 << 1,
|
ReadWrite = 1 << 1,
|
||||||
UserSupervisor = 1 << 2,
|
UserSupervisor = 1 << 2,
|
||||||
|
WriteThrough = 1 << 3,
|
||||||
|
CacheDisabled = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_present() const { return raw() & Present; }
|
bool is_present() const { return raw() & Present; }
|
||||||
|
@ -303,6 +306,12 @@ private:
|
||||||
bool is_writable() const { return raw() & ReadWrite; }
|
bool is_writable() const { return raw() & ReadWrite; }
|
||||||
void set_writable(bool b) { set_bit(ReadWrite, b); }
|
void set_writable(bool b) { set_bit(ReadWrite, b); }
|
||||||
|
|
||||||
|
bool is_write_through() const { return raw() & WriteThrough; }
|
||||||
|
void set_write_through(bool b) { set_bit(WriteThrough, b); }
|
||||||
|
|
||||||
|
bool is_cache_disabled() const { return raw() & CacheDisabled; }
|
||||||
|
void set_cache_disabled(bool b) { set_bit(CacheDisabled, b); }
|
||||||
|
|
||||||
void set_bit(byte bit, bool value)
|
void set_bit(byte bit, bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -331,6 +340,8 @@ private:
|
||||||
Present = 1 << 0,
|
Present = 1 << 0,
|
||||||
ReadWrite = 1 << 1,
|
ReadWrite = 1 << 1,
|
||||||
UserSupervisor = 1 << 2,
|
UserSupervisor = 1 << 2,
|
||||||
|
WriteThrough = 1 << 3,
|
||||||
|
CacheDisabled = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_present() const { return raw() & Present; }
|
bool is_present() const { return raw() & Present; }
|
||||||
|
@ -342,6 +353,12 @@ private:
|
||||||
bool is_writable() const { return raw() & ReadWrite; }
|
bool is_writable() const { return raw() & ReadWrite; }
|
||||||
void set_writable(bool b) { set_bit(ReadWrite, b); }
|
void set_writable(bool b) { set_bit(ReadWrite, b); }
|
||||||
|
|
||||||
|
bool is_write_through() const { return raw() & WriteThrough; }
|
||||||
|
void set_write_through(bool b) { set_bit(WriteThrough, b); }
|
||||||
|
|
||||||
|
bool is_cache_disabled() const { return raw() & CacheDisabled; }
|
||||||
|
void set_cache_disabled(bool b) { set_bit(CacheDisabled, b); }
|
||||||
|
|
||||||
void set_bit(byte bit, bool value)
|
void set_bit(byte bit, bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue