summaryrefslogtreecommitdiff
path: root/arch/metag/include/asm/mmu.h
blob: cab5a01c3dcb8ff89643fb9b0aa72411d73cfdb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __MMU_H
#define __MMU_H

#ifdef CONFIG_METAG_USER_TCM
#include <linux/list.h>
#endif

#ifdef CONFIG_HUGETLB_PAGE
#include <asm/page.h>
#endif

typedef struct {
	/* Software pgd base pointer used for Meta 1.x MMU. */
	unsigned long pgd_base;
#ifdef CONFIG_METAG_USER_TCM
	struct list_head tcm;
#endif
#ifdef CONFIG_HUGETLB_PAGE
#if HPAGE_SHIFT < HUGEPT_SHIFT
	/* last partially filled huge page table address */
	unsigned long part_huge;
#endif
#endif
} mm_context_t;

/* Given a virtual address, return the pte for the top level 4meg entry
 * that maps that address.
 * Returns 0 (an empty pte) if that range is not mapped.
 */
unsigned long mmu_read_first_level_page(unsigned long vaddr);

/* Given a linear (virtual) address, return the second level 4k pte
 * that maps that address.  Returns 0 if the address is not mapped.
 */
unsigned long mmu_read_second_level_page(unsigned long vaddr);

/* Get the virtual base address of the MMU */
unsigned long mmu_get_base(void);

/* Initialize the MMU. */
void mmu_init(unsigned long mem_end);

#ifdef CONFIG_METAG_META21_MMU
/*
 * For cpu "cpu" calculate and return the address of the
 * MMCU_TnLOCAL_TABLE_PHYS0 if running in local-space or
 * MMCU_TnGLOBAL_TABLE_PHYS0 if running in global-space.
 */
static inline unsigned long mmu_phys0_addr(unsigned int cpu)
{
	unsigned long phys0;

	phys0 = (MMCU_T0LOCAL_TABLE_PHYS0 +
		(MMCU_TnX_TABLE_PHYSX_STRIDE * cpu)) +
		(MMCU_TXG_TABLE_PHYSX_OFFSET * is_global_space(PAGE_OFFSET));

	return phys0;
}

/*
 * For cpu "cpu" calculate and return the address of the
 * MMCU_TnLOCAL_TABLE_PHYS1 if running in local-space or
 * MMCU_TnGLOBAL_TABLE_PHYS1 if running in global-space.
 */
static inline unsigned long mmu_phys1_addr(unsigned int cpu)
{
	unsigned long phys1;

	phys1 = (MMCU_T0LOCAL_TABLE_PHYS1 +
		(MMCU_TnX_TABLE_PHYSX_STRIDE * cpu)) +
		(MMCU_TXG_TABLE_PHYSX_OFFSET * is_global_space(PAGE_OFFSET));

	return phys1;
}
#endif /* CONFIG_METAG_META21_MMU */

#endif