• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __MMU_H
2 #define __MMU_H
3 
4 #ifdef CONFIG_METAG_USER_TCM
5 #include <linux/list.h>
6 #endif
7 
8 #ifdef CONFIG_HUGETLB_PAGE
9 #include <asm/page.h>
10 #endif
11 
12 typedef struct {
13 	/* Software pgd base pointer used for Meta 1.x MMU. */
14 	unsigned long pgd_base;
15 #ifdef CONFIG_METAG_USER_TCM
16 	struct list_head tcm;
17 #endif
18 #ifdef CONFIG_HUGETLB_PAGE
19 #if HPAGE_SHIFT < HUGEPT_SHIFT
20 	/* last partially filled huge page table address */
21 	unsigned long part_huge;
22 #endif
23 #endif
24 } mm_context_t;
25 
26 /* Given a virtual address, return the pte for the top level 4meg entry
27  * that maps that address.
28  * Returns 0 (an empty pte) if that range is not mapped.
29  */
30 unsigned long mmu_read_first_level_page(unsigned long vaddr);
31 
32 /* Given a linear (virtual) address, return the second level 4k pte
33  * that maps that address.  Returns 0 if the address is not mapped.
34  */
35 unsigned long mmu_read_second_level_page(unsigned long vaddr);
36 
37 /* Get the virtual base address of the MMU */
38 unsigned long mmu_get_base(void);
39 
40 /* Initialize the MMU. */
41 void mmu_init(unsigned long mem_end);
42 
43 #ifdef CONFIG_METAG_META21_MMU
44 /*
45  * For cpu "cpu" calculate and return the address of the
46  * MMCU_TnLOCAL_TABLE_PHYS0 if running in local-space or
47  * MMCU_TnGLOBAL_TABLE_PHYS0 if running in global-space.
48  */
mmu_phys0_addr(unsigned int cpu)49 static inline unsigned long mmu_phys0_addr(unsigned int cpu)
50 {
51 	unsigned long phys0;
52 
53 	phys0 = (MMCU_T0LOCAL_TABLE_PHYS0 +
54 		(MMCU_TnX_TABLE_PHYSX_STRIDE * cpu)) +
55 		(MMCU_TXG_TABLE_PHYSX_OFFSET * is_global_space(PAGE_OFFSET));
56 
57 	return phys0;
58 }
59 
60 /*
61  * For cpu "cpu" calculate and return the address of the
62  * MMCU_TnLOCAL_TABLE_PHYS1 if running in local-space or
63  * MMCU_TnGLOBAL_TABLE_PHYS1 if running in global-space.
64  */
mmu_phys1_addr(unsigned int cpu)65 static inline unsigned long mmu_phys1_addr(unsigned int cpu)
66 {
67 	unsigned long phys1;
68 
69 	phys1 = (MMCU_T0LOCAL_TABLE_PHYS1 +
70 		(MMCU_TnX_TABLE_PHYSX_STRIDE * cpu)) +
71 		(MMCU_TXG_TABLE_PHYSX_OFFSET * is_global_space(PAGE_OFFSET));
72 
73 	return phys1;
74 }
75 #endif /* CONFIG_METAG_META21_MMU */
76 
77 #endif
78