arm:caching introduce _CACHED defines

Introduce ARM_VM_SECTION_CACHED and ARM_VM_PTE_CACHED to ensure we
are using the correct caching flags everywhere.
This commit is contained in:
Kees Jongenburger 2013-09-13 09:40:20 +02:00
parent b82f01ea69
commit 0f23130180
4 changed files with 18 additions and 9 deletions

View file

@ -48,6 +48,8 @@ arm/vm.h
#define ARM_VM_PTE_WB (ARM_VM_PTE_TEX2 | ARM_VM_PTE_TEX0 | ARM_VM_PTE_B) #define ARM_VM_PTE_WB (ARM_VM_PTE_TEX2 | ARM_VM_PTE_TEX0 | ARM_VM_PTE_B)
/* inner and outer write-through, no write-allocate */ /* inner and outer write-through, no write-allocate */
#define ARM_VM_PTE_WT (ARM_VM_PTE_TEX2 | ARM_VM_PTE_TEX1 | ARM_VM_PTE_C) #define ARM_VM_PTE_WT (ARM_VM_PTE_TEX2 | ARM_VM_PTE_TEX1 | ARM_VM_PTE_C)
#define ARM_VM_PTE_CACHED ARM_VM_PTE_WT
/* shareable device */ /* shareable device */
#define ARM_VM_PTE_DEVICE (ARM_VM_PTE_B) #define ARM_VM_PTE_DEVICE (ARM_VM_PTE_B)
@ -75,6 +77,8 @@ arm/vm.h
/* inner and outer write-through, no write-allocate */ /* inner and outer write-through, no write-allocate */
#define ARM_VM_SECTION_WT (ARM_VM_SECTION_TEX2 | ARM_VM_SECTION_TEX1 | ARM_VM_SECTION_C) #define ARM_VM_SECTION_WT (ARM_VM_SECTION_TEX2 | ARM_VM_SECTION_TEX1 | ARM_VM_SECTION_C)
/* shareable device */ /* shareable device */
#define ARM_VM_SECTION_CACHED ARM_VM_SECTION_WT
#define ARM_VM_SECTION_DEVICE (ARM_VM_SECTION_B) #define ARM_VM_SECTION_DEVICE (ARM_VM_SECTION_B)
/* Page directory specific flags. */ /* Page directory specific flags. */

View file

@ -176,7 +176,7 @@ int pg_mapkernel(void)
pagedir[pde] = (kern_phys & ARM_VM_SECTION_MASK) | ARM_VM_SECTION pagedir[pde] = (kern_phys & ARM_VM_SECTION_MASK) | ARM_VM_SECTION
| ARM_VM_SECTION_SUPER | ARM_VM_SECTION_SUPER
| ARM_VM_SECTION_DOMAIN | ARM_VM_SECTION_DOMAIN
| ARM_VM_SECTION_WT; | ARM_VM_SECTION_CACHED;
mapped += ARM_SECTION_SIZE; mapped += ARM_SECTION_SIZE;
kern_phys += ARM_SECTION_SIZE; kern_phys += ARM_SECTION_SIZE;
pde++; pde++;
@ -270,7 +270,7 @@ void pg_map(phys_bytes phys, vir_bytes vaddr, vir_bytes vaddr_end,
assert(pt); assert(pt);
pt[pte] = (source & ARM_VM_PTE_MASK) pt[pte] = (source & ARM_VM_PTE_MASK)
| ARM_VM_PAGETABLE | ARM_VM_PAGETABLE
| ARM_VM_PTE_WT | ARM_VM_PTE_CACHED
| ARM_VM_PTE_USER; | ARM_VM_PTE_USER;
vaddr += ARM_PAGE_SIZE; vaddr += ARM_PAGE_SIZE;
if(phys != PG_ALLOCATEME) if(phys != PG_ALLOCATEME)

View file

@ -301,7 +301,7 @@ void *vm_mappages(phys_bytes p, int pages)
if((r=pt_writemap(vmprocess, pt, loc, p, VM_PAGE_SIZE*pages, if((r=pt_writemap(vmprocess, pt, loc, p, VM_PAGE_SIZE*pages,
ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER | ARCH_VM_PTE_RW ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER | ARCH_VM_PTE_RW
#if defined(__arm__) #if defined(__arm__)
| ARM_VM_PTE_WT | ARM_VM_PTE_CACHED
#endif #endif
, 0)) != OK) { , 0)) != OK) {
printf("vm_mappages writemap failed\n"); printf("vm_mappages writemap failed\n");
@ -409,7 +409,8 @@ void vm_pagelock(void *vir, int lockflag)
#if defined(__arm__) #if defined(__arm__)
else else
flags |= ARCH_VM_PTE_RO; flags |= ARCH_VM_PTE_RO;
flags |= ARM_VM_PTE_WT ;
flags |= ARM_VM_PTE_CACHED ;
#endif #endif
/* Update flags. */ /* Update flags. */
@ -689,7 +690,7 @@ int pt_ptmap(struct vmproc *src_vmp, struct vmproc *dst_vmp)
#elif defined(__arm__) #elif defined(__arm__)
if((r=pt_writemap(dst_vmp, &dst_vmp->vm_pt, viraddr, physaddr, ARCH_PAGEDIR_SIZE, if((r=pt_writemap(dst_vmp, &dst_vmp->vm_pt, viraddr, physaddr, ARCH_PAGEDIR_SIZE,
ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER | ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER |
ARM_VM_PTE_WT , ARM_VM_PTE_CACHED ,
#endif #endif
WMF_OVERWRITE)) != OK) { WMF_OVERWRITE)) != OK) {
return r; return r;
@ -715,7 +716,7 @@ int pt_ptmap(struct vmproc *src_vmp, struct vmproc *dst_vmp)
if((r=pt_writemap(dst_vmp, &dst_vmp->vm_pt, viraddr, physaddr, VM_PAGE_SIZE, if((r=pt_writemap(dst_vmp, &dst_vmp->vm_pt, viraddr, physaddr, VM_PAGE_SIZE,
ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER | ARCH_VM_PTE_RW ARCH_VM_PTE_PRESENT | ARCH_VM_PTE_USER | ARCH_VM_PTE_RW
#ifdef __arm__ #ifdef __arm__
| ARM_VM_PTE_WT | ARM_VM_PTE_CACHED
#endif #endif
, ,
WMF_OVERWRITE)) != OK) { WMF_OVERWRITE)) != OK) {
@ -1193,6 +1194,7 @@ void pt_init(void)
#elif defined(__arm__) #elif defined(__arm__)
pdm->val = (ph & ARCH_VM_PDE_MASK) pdm->val = (ph & ARCH_VM_PDE_MASK)
| ARCH_VM_PDE_PRESENT | ARCH_VM_PDE_PRESENT
| ARM_VM_PTE_CACHED
| ARM_VM_PDE_DOMAIN; //LSC FIXME | ARM_VM_PDE_DOMAIN; //LSC FIXME
#endif #endif
} }
@ -1216,6 +1218,7 @@ void pt_init(void)
#elif defined(__arm__) #elif defined(__arm__)
if(sys_vmctl_get_pdbr(SELF, &myttbr) != OK) if(sys_vmctl_get_pdbr(SELF, &myttbr) != OK)
#endif #endif
panic("VM: sys_vmctl_get_pdbr failed"); panic("VM: sys_vmctl_get_pdbr failed");
#if defined(__i386__) #if defined(__i386__)
if(sys_vircopy(NONE, mypdbr, SELF, if(sys_vircopy(NONE, mypdbr, SELF,
@ -1334,7 +1337,7 @@ int pt_bind(pt_t *pt, struct vmproc *who)
#endif #endif
/* Tell kernel about new page table root. */ /* Tell kernel about new page table root. */
return sys_vmctl_set_addrspace(who->vm_endpoint, pt->pt_dir_phys, pdes); return sys_vmctl_set_addrspace(who->vm_endpoint, pt->pt_dir_phys , pdes);
} }
/*===========================================================================* /*===========================================================================*
@ -1377,7 +1380,7 @@ int pt_mapkernel(pt_t *pt)
pt->pt_dir[kern_pde] = (addr & ARM_VM_SECTION_MASK) pt->pt_dir[kern_pde] = (addr & ARM_VM_SECTION_MASK)
| ARM_VM_SECTION | ARM_VM_SECTION
| ARM_VM_SECTION_DOMAIN | ARM_VM_SECTION_DOMAIN
| ARM_VM_SECTION_WT | ARM_VM_SECTION_CACHED
| ARM_VM_SECTION_SUPER; | ARM_VM_SECTION_SUPER;
#endif #endif
kern_pde++; kern_pde++;

View file

@ -295,6 +295,8 @@ int minix_munmap(void * addr, size_t len)
int brk(void *addr) int brk(void *addr)
{ {
/* brk is a special case function to allow vm itself to
allocate memory in it's own (cacheable) HEAP */
vir_bytes target = roundup((vir_bytes)addr, VM_PAGE_SIZE), v; vir_bytes target = roundup((vir_bytes)addr, VM_PAGE_SIZE), v;
extern char _end; extern char _end;
extern char *_brksize; extern char *_brksize;
@ -312,7 +314,7 @@ int brk(void *addr)
| ARCH_VM_PTE_USER | ARCH_VM_PTE_USER
| ARCH_VM_PTE_RW | ARCH_VM_PTE_RW
#if defined(__arm__) #if defined(__arm__)
| ARM_VM_PTE_WB | ARM_VM_PTE_CACHED
#endif #endif
, 0) != OK) { , 0) != OK) {
free_mem(newpage, 1); free_mem(newpage, 1);