Kernel: Map DMA and PCI MMIO as uncached
This commit is contained in:
parent
bb1738db8c
commit
9bc02c81f8
|
@ -369,13 +369,12 @@ namespace Kernel
|
||||||
if (flags & Flags::Reserved)
|
if (flags & Flags::Reserved)
|
||||||
extra_flags |= Flags::Reserved;
|
extra_flags |= Flags::Reserved;
|
||||||
|
|
||||||
if (s_has_pat)
|
if (memory_type == MemoryType::Uncached)
|
||||||
{
|
extra_flags |= (1ull << 4);
|
||||||
if (memory_type == MemoryType::WriteCombining)
|
if (s_has_pat && memory_type == MemoryType::WriteCombining)
|
||||||
extra_flags |= (1ull << 7);
|
extra_flags |= (1ull << 7);
|
||||||
if (memory_type == MemoryType::WriteThrough)
|
if (s_has_pat && memory_type == MemoryType::WriteThrough)
|
||||||
extra_flags |= (1ull << 7) | (1ull << 3);
|
extra_flags |= (1ull << 7) | (1ull << 3);
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: we add present here, since it has to be available in higher level structures
|
// NOTE: we add present here, since it has to be available in higher level structures
|
||||||
flags_t uwr_flags = (flags & (Flags::UserSupervisor | Flags::ReadWrite)) | Flags::Present;
|
flags_t uwr_flags = (flags & (Flags::UserSupervisor | Flags::ReadWrite)) | Flags::Present;
|
||||||
|
|
|
@ -417,6 +417,8 @@ namespace Kernel
|
||||||
if (flags & Flags::Reserved)
|
if (flags & Flags::Reserved)
|
||||||
extra_flags |= Flags::Reserved;
|
extra_flags |= Flags::Reserved;
|
||||||
|
|
||||||
|
if (memory_type == MemoryType::Uncached)
|
||||||
|
extra_flags |= (1ull << 4);
|
||||||
if (memory_type == MemoryType::WriteCombining)
|
if (memory_type == MemoryType::WriteCombining)
|
||||||
extra_flags |= (1ull << 7);
|
extra_flags |= (1ull << 7);
|
||||||
if (memory_type == MemoryType::WriteThrough)
|
if (memory_type == MemoryType::WriteThrough)
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Kernel
|
||||||
enum MemoryType
|
enum MemoryType
|
||||||
{
|
{
|
||||||
Normal,
|
Normal,
|
||||||
|
Uncached,
|
||||||
WriteCombining,
|
WriteCombining,
|
||||||
WriteThrough,
|
WriteThrough,
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Kernel
|
||||||
vaddr_guard.disable();
|
vaddr_guard.disable();
|
||||||
paddr_guard.disable();
|
paddr_guard.disable();
|
||||||
|
|
||||||
PageTable::kernel().map_range_at(paddr, vaddr, size, PageTable::Flags::ReadWrite | PageTable::Flags::Present);
|
PageTable::kernel().map_range_at(paddr, vaddr, size, PageTable::Flags::ReadWrite | PageTable::Flags::Present, PageTable::MemoryType::Uncached);
|
||||||
|
|
||||||
return BAN::UniqPtr<DMARegion>::adopt(region_ptr);
|
return BAN::UniqPtr<DMARegion>::adopt(region_ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ namespace Kernel::PCI
|
||||||
{
|
{
|
||||||
vaddr_t vaddr = PageTable::kernel().reserve_free_page(KERNEL_OFFSET);
|
vaddr_t vaddr = PageTable::kernel().reserve_free_page(KERNEL_OFFSET);
|
||||||
ASSERT(vaddr);
|
ASSERT(vaddr);
|
||||||
PageTable::kernel().map_page_at(pcie_paddr, vaddr, PageTable::Flags::ReadWrite | PageTable::Flags::Present);
|
PageTable::kernel().map_page_at(pcie_paddr, vaddr, PageTable::Flags::ReadWrite | PageTable::Flags::Present, PageTable::MemoryType::Uncached);
|
||||||
m_mmio_config = vaddr;
|
m_mmio_config = vaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue