OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [arch/] [arm/] [v5/] [mm.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * ARM v5-specific virtual memory details
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#ifndef __V5_MM_H__
7
#define __V5_MM_H__
8
 
9
/* ARM specific definitions */
10
#define VIRT_MEM_START                  0
11
#define VIRT_MEM_END                    0xFFFFFFFF
12
#define SECTION_SIZE                    SZ_1MB
13
#define SECTION_MASK                    (SECTION_SIZE - 1)
14
#define SECTION_ALIGN_MASK              (~SECTION_MASK)
15
#define SECTION_BITS                    20
16
#define ARM_PAGE_SIZE                   SZ_4K
17
#define ARM_PAGE_MASK                   0xFFF
18
#define ARM_PAGE_BITS                   12
19
 
20
#define PGD_SIZE                                SZ_4K * 4
21
#define PGD_ENTRY_TOTAL                         SZ_4K
22
 
23
#define PMD_SIZE                                SZ_1K
24
#define PMD_ENTRY_TOTAL                         256
25
#define PMD_MAP_SIZE                            SZ_1MB
26
#define PMD_ALIGN_MASK                          (~(PMD_SIZE - 1))
27
#define PMD_TYPE_MASK                           0x3
28
#define PMD_TYPE_FAULT                          0
29
#define PMD_TYPE_PMD                            1
30
#define PMD_TYPE_SECTION                        2
31
 
32
#define PTE_TYPE_MASK                           0x3
33
#define PTE_TYPE_FAULT                          0
34
#define PTE_TYPE_LARGE                          1
35
#define PTE_TYPE_SMALL                          2
36
#define PTE_TYPE_TINY                           3
37
 
38
/* Permission field offsets */
39
#define SECTION_AP0                             10
40
 
41
/*
42
 * These are indices into arrays with pgd_t or pmd_t sized elements,
43
 * therefore the index must be divided by appropriate element size
44
 */
45
#define PGD_INDEX(x)            (((((unsigned long)(x)) >> 18) \
46
                                  & 0x3FFC) / sizeof(pmd_t))
47
 
48
/*
49
 * Strip out the page offset in this
50
 * megabyte from a total of 256 pages.
51
 */
52
#define PMD_INDEX(x)            (((((unsigned long)(x)) >> 10) \
53
                                  & 0x3FC) / sizeof (pte_t))
54
 
55
 
56
/* We need this as print-early.S is including this file */
57
#ifndef __ASSEMBLY__
58
 
59
/* Type-checkable page table elements */
60
typedef u32 pmd_t;
61
typedef u32 pte_t;
62
 
63
/* Page global directory made up of pgd_t entries */
64
typedef struct pgd_table {
65
        pmd_t entry[PGD_ENTRY_TOTAL];
66
} pgd_table_t;
67
 
68
/* Page middle directory made up of pmd_t entries */
69
typedef struct pmd_table {
70
        pte_t entry[PMD_ENTRY_TOTAL];
71
} pmd_table_t;
72
 
73
/* Applies for both small and large pages */
74
#define PAGE_AP0                                4
75
#define PAGE_AP1                                6
76
#define PAGE_AP2                                8
77
#define PAGE_AP3                                10
78
 
79
/* Permission values with rom and sys bits ignored */
80
#define SVC_RW_USR_NONE                         1
81
#define SVC_RW_USR_RO                           2
82
#define SVC_RW_USR_RW                           3
83
 
84
#define PTE_PROT_MASK                           (0xFF << 4)
85
 
86
#define CACHEABILITY                            3
87
#define BUFFERABILITY                           2
88
#define cacheable                               (1 << CACHEABILITY)
89
#define bufferable                              (1 << BUFFERABILITY)
90
#define uncacheable                             0
91
#define unbufferable                            0
92
 
93
/* Helper macros for common cases */
94
#define __MAP_USR_RW    (cacheable | bufferable | (SVC_RW_USR_RW << PAGE_AP0)           \
95
                        | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2)     \
96
                        | (SVC_RW_USR_RW << PAGE_AP3))
97
#define __MAP_USR_RO    (cacheable | bufferable | (SVC_RW_USR_RO << PAGE_AP0)           \
98
                        | (SVC_RW_USR_RO << PAGE_AP1) | (SVC_RW_USR_RO << PAGE_AP2)     \
99
                        | (SVC_RW_USR_RO << PAGE_AP3))
100
#define __MAP_KERN_RW   (cacheable | bufferable | (SVC_RW_USR_NONE << PAGE_AP0)         \
101
                        | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \
102
                        | (SVC_RW_USR_NONE << PAGE_AP3))
103
#define __MAP_KERN_IO   (uncacheable | unbufferable | (SVC_RW_USR_NONE << PAGE_AP0)     \
104
                        | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \
105
                        | (SVC_RW_USR_NONE << PAGE_AP3))
106
#define __MAP_USR_IO    (uncacheable | unbufferable | (SVC_RW_USR_RW << PAGE_AP0)       \
107
                        | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2)     \
108
                        | (SVC_RW_USR_RW << PAGE_AP3))
109
 
110
/* There is no execute bit in ARMv5, so we ignore it */
111
#define __MAP_USR_RWX   __MAP_USR_RW
112
#define __MAP_USR_RX    __MAP_USR_RO
113
#define __MAP_KERN_RWX  __MAP_KERN_RW
114
#define __MAP_KERN_RX   __MAP_KERN_RW   /* We always have kernel RW */
115
#define __MAP_FAULT     0
116
 
117
void add_section_mapping_init(unsigned int paddr, unsigned int vaddr,
118
                              unsigned int size, unsigned int flags);
119
 
120
void remove_section_mapping(unsigned long vaddr);
121
 
122
extern pgd_table_t init_pgd;
123
 
124
void arch_update_utcb(unsigned long utcb_address);
125
void system_identify(void);
126
 
127
#endif /* __ASSEMBLY__ */
128
#endif /* __V5_MM_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.