Use PTE_WRITECOMB for PTEs if you're manually building a mapping.

Reinstall your kernel headers.

Signed-off-by: Barret Rhoden <[email protected]>
---
 kern/arch/riscv/ros/mmu.h | 2 ++
 kern/arch/x86/ros/mmu64.h | 1 +
 kern/include/mm.h         | 1 +
 kern/src/mm.c             | 5 +++++
 4 files changed, 9 insertions(+)

diff --git a/kern/arch/riscv/ros/mmu.h b/kern/arch/riscv/ros/mmu.h
index 9bdcaabb520f..e52100b87f07 100644
--- a/kern/arch/riscv/ros/mmu.h
+++ b/kern/arch/riscv/ros/mmu.h
@@ -98,7 +98,9 @@
 #define PTE_SR   0x200 // Supervisor Write permission
 #define PTE_PERM (PTE_SR | PTE_SW | PTE_SX | PTE_UR | PTE_UW | PTE_UX)
 #define PTE_PPN_SHIFT 13
+#warning "Review RISCV PTE_modes, like NOCACHE/WRITECOMB"
 #define PTE_NOCACHE    0 // PTE bits to turn off caching, if possible
+#define PTE_WRITECOMB  0 // PTE bits to turn on write-combining, if possible
 
 // commly used access modes
 
diff --git a/kern/arch/x86/ros/mmu64.h b/kern/arch/x86/ros/mmu64.h
index 9490401f5e9a..66d54e132a6f 100644
--- a/kern/arch/x86/ros/mmu64.h
+++ b/kern/arch/x86/ros/mmu64.h
@@ -277,6 +277,7 @@ typedef struct x86_pgdir {
 #define PTE_G                  0x100   /* Global Page */
 #define __PTE_JPAT             0x800   /* Jumbo PAT */
 #define PTE_NOCACHE            (__PTE_PWT | __PTE_PCD)
+#define PTE_WRITECOMB  (__PTE_PCD)
 
 /* Permissions fields and common access modes.  These should be read as 'just
  * kernel or user too' and 'RO or RW'.  USER_RO means read-only for everyone. 
*/
diff --git a/kern/include/mm.h b/kern/include/mm.h
index ef70f997caab..4ac5949e39d2 100644
--- a/kern/include/mm.h
+++ b/kern/include/mm.h
@@ -84,4 +84,5 @@ int unmap_vmap_segment(uintptr_t vaddr, unsigned long 
num_pages);
 /* Helper wrappers, since no one will probably call the *_segment funcs */
 uintptr_t vmap_pmem(uintptr_t paddr, size_t nr_bytes);
 uintptr_t vmap_pmem_nocache(uintptr_t paddr, size_t nr_bytes);
+uintptr_t vmap_pmem_writecomb(uintptr_t paddr, size_t nr_bytes);
 int vunmap_vmem(uintptr_t vaddr, size_t nr_bytes);
diff --git a/kern/src/mm.c b/kern/src/mm.c
index 7b7e54292da9..e7355b52c23a 100644
--- a/kern/src/mm.c
+++ b/kern/src/mm.c
@@ -1222,6 +1222,11 @@ uintptr_t vmap_pmem_nocache(uintptr_t paddr, size_t 
nr_bytes)
        return vmap_pmem_flags(paddr, nr_bytes, PTE_NOCACHE);
 }
 
+uintptr_t vmap_pmem_writecomb(uintptr_t paddr, size_t nr_bytes)
+{
+       return vmap_pmem_flags(paddr, nr_bytes, PTE_WRITECOMB);
+}
+
 int vunmap_vmem(uintptr_t vaddr, size_t nr_bytes)
 {
        unsigned long nr_pages = ROUNDUP(nr_bytes, PGSIZE) >> PGSHIFT;
-- 
2.7.0.rc3.207.g0ac5344

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to