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