My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pagetable.h
Go to the documentation of this file.
1 /*
2  * OpenVirtualization:
3  * For additional details and support contact developer@sierraware.com.
4  * Additional documentation can be found at www.openvirtualization.org
5  *
6  * Copyright (C) 2010-2014 SierraWare
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23 #ifndef __ARMV8_INC_PAGETABLE_H__
24 #define __ARMV8_INC_PAGETABLE_H__
25 
26 #include <sw_types.h>
27 #include <sw_board.h>
28 #include <ptf.h>
29 
30 /* Select page size and address size configuration */
31 
32 #if defined ARMV8_PAGE4K_ADDR39BITS
33 #include <pt_p4k_a39.h>
34 #elif defined ARMV8_PAGE64K_ADDR42BITS
35 #include <pt_p64k_a42.h>
36 #endif
37 
38 #define PAGE_MASK (PAGE_SIZE - 1)
39 
40 
41 /*========ARMV8 Page table format related definitions ========== */
42 
43 /* Attr field */
44 /* Cacheable, Outer Inner Writeback Memory*/
45 #define ATTR_MEMORY 0x0
46 /* Device nGnRnE*/
47 #define ATTR_DEVICE_STRONG 0x1
48 
49 /* AP field */
51 #define AP_PRIV_RW_USR_NO 0x0
52 
53 #define AP_PRIV_RW_USR_RW 0x1
54 
55 #define AP_PRIV_RO_USR_NO 0x2
56 
57 #define AP_PRIV_RO_USR_RO 0x3
58 
59 #define AP_RW 0x1
60 #define AP_RO 0x3
61 
62 /* XN, UXN */
63 #define NOEXEC 0x1UL
64 #define EXEC 0x0UL
65 
66 
67 #define PT_ENTRIES (PAGE_SIZE >> 3)
68 #define PAGEMAP_LEVEL 3
69 
70 #define PTE_TYPE_INVALID 0x00
71 #define PTE_TYPE_BLOCK 0x01
72 #define PTE_TYPE_PAGE 0x03
73 #define PTE_TYPE_TABLE 0x03
74 
75 #define LEVEL_OFFSET_MASK(x) \
76  (LEVEL0_OFFSET_MASK >> (x * LEVEL_OFFSET_BITS))
77 #define LEVEL_OFFSET_SHIFT(x) \
78  ((4 - x) * LEVEL_OFFSET_BITS)
79 
80 
81 /* Attributes
82  * ----------
83  * Index 0 - Normal memory outer writeback, non transient, RA, WA(0xff)
84  * Index 1 - Device nGnRnE (0x00)
85  *
86 */
87 #define MEM_ATTRIBUTES_MAP 0x00000000000000ff
88 
89 #define TABLE_ATTR 0x0
90 
91 #define ACCESS_FLAG 1
92 
93 #define PT_ATTR_SHIFT 2
94 #define PT_NS_SHIFT 5
95 #define PT_AP_SHIFT 6
96 #define PT_AF_SHIFT 10
97 #define PT_PXN_SHIFT 53
98 #define PT_UXN_SHIFT 54
99 #define PT_XN_SHIFT 54
100 
101 
102 /*========End of Page table format related definitions ========== */
103 
104 
105 /* Boot Memory attributes */
106 #if defined __KERNEL_EL1__
107 #define BA_MEMORY 0x0000000000000400
108 #else
109 #define BA_MEMORY 0x0000000000000440
110 #define BA_DEVICE 0x0000000000000441
111 #endif
112 
113 /* Pages for Bootstrap pagetable */
114 #define IDENT_MAP 0
115 #define LIN_MAP 1
116 #define DEV_MAP 2
117 
118 #define PT_STAGE_1 0
119 #define PT_STAGE_2 1
120 
121 /* Static page pool */
122 #define STATIC_PT_PAGES 32
123 
124 #ifndef __ASSEMBLY__
125 
126 #define kva_to_kpa(x) \
127  (((x) - KERN_VA_BASE) + KERN_PA_BASE)
128 
129 #define kpa_to_kva(x) \
130  (((x) - KERN_PA_BASE) + KERN_VA_BASE)
131 
132 struct ptable {
133  sw_u64_t pt_base;
134  int pt_type;
135 };
136 
137 typedef unsigned long (*ptp_alloc_t)(void);
138 
145 
151 unsigned long static_pt_page_alloc(void);
152 
153 #endif
154 
155 #endif /* __ARMV8_INC_PAGETABLE_H__ */
unsigned long(* ptp_alloc_t)(void)
Definition: pagetable.h:137
void pt_page_allocator_init(ptp_alloc_t)
Initialize ptable page allocator function.
Definition: pagetable.c:94
Definition: page_table.h:174
unsigned long static_pt_page_alloc(void)
static pool page allocator
Definition: pagetable.c:108
sw_u64_t pt_base
Definition: pagetable.h:133
int pt_type
Definition: page_table.h:176