voron

experimental ARM OS
git clone git://git.2f30.org/voron
Log | Files | Refs | README | LICENSE

mmu.h (1008B)


      1 #ifndef __MMU_H
      2 #define __MMU_H
      3 
      4 #define PAGE_SHIFT		12
      5 #define PAGE_SIZE		(1UL << PAGE_SHIFT)
      6 #define PAGE_MASK		(~(PAGE_SIZE - 1))
      7 #define PAGE_ALIGN(x)		(((x) + PAGE_SIZE - 1) & PAGE_MASK)
      8 
      9 #define L1_TYPE_MASK	3
     10 #define L1_FAULT	0
     11 #define L1_PAGE_TABLE	1
     12 #define L1_SECTION	2
     13 
     14 #define L2_TYPE_MASK	3
     15 #define L2_PAGE_FAULT	0
     16 #define L2_LARGE_PAGE	1
     17 #define L2_SMALL_PAGE	2
     18 #define L2_TINY_PAGE	3
     19 
     20 #define PT_AP0		(1 << 4)
     21 #define PT_AP1		(1 << 5)
     22 #define PT_AP2		(1 << 9)
     23 
     24 /* MMU access permissions
     25  * MMU_AP_X_Y
     26  * X = access permissions for PL1 or higher
     27  * Y = access permissions for PL0 (user mode)
     28  */
     29 typedef enum {
     30 	MMU_AP_RW_RW,
     31 	MMU_AP_RW_RO,
     32 	MMU_AP_RO_RO,
     33 	MMU_AP_RW_NONE,
     34 	MMU_AP_RO_NONE,
     35 	MMU_AP_NONE_NONE
     36 } mmu_ap_t;
     37 
     38 void mmu_init();
     39 void mmu_enable();
     40 void mmu_disable();
     41 int mmu_map_page(void *phys, void *virt, uint_t npages, mmu_ap_t perms);
     42 int kmmap(void *virt, uint_t npages, mmu_ap_t perms);
     43 uintptr_t virt_to_phys(void *virt);
     44 int virt_is_mapped(void *virt);
     45 
     46 #endif /* __MMU_H */