pte.h revision 1.1 1 1.1 matt /* $NetBSD: pte.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
2 1.1 matt
3 1.1 matt /*-
4 1.1 matt * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 1.1 matt * All rights reserved.
6 1.1 matt *
7 1.1 matt * This code is derived from software contributed to The NetBSD Foundation
8 1.1 matt * by Matt Thomas of 3am Software Foundry.
9 1.1 matt *
10 1.1 matt * Redistribution and use in source and binary forms, with or without
11 1.1 matt * modification, are permitted provided that the following conditions
12 1.1 matt * are met:
13 1.1 matt * 1. Redistributions of source code must retain the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer.
15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 matt * notice, this list of conditions and the following disclaimer in the
17 1.1 matt * documentation and/or other materials provided with the distribution.
18 1.1 matt *
19 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 matt * POSSIBILITY OF SUCH DAMAGE.
30 1.1 matt */
31 1.1 matt
32 1.1 matt #ifndef _AARCH64_PTE_H_
33 1.1 matt #define _AARCH64_PTE_H_
34 1.1 matt
35 1.1 matt #ifdef __aarch64__
36 1.1 matt
37 1.1 matt typedef unsigned long long pt_entry_t;
38 1.1 matt
39 1.1 matt #define LX_VALID __BIT(0)
40 1.1 matt #define LX_TYPE __BIT(1)
41 1.1 matt #define LX_TYPE_BLK __SHIFTOUT(0, LX_TYPE)
42 1.1 matt #define LX_TYPE_TBL __SHIFTOUT(1, LX_TYPE)
43 1.1 matt #define L3_TYPE_PAG __SHIFTOUT(1, LX_TYPE)
44 1.1 matt
45 1.1 matt #define L1_BLK_OS __BITS(58, 55)
46 1.1 matt #define L1_BLK_UXN __BIT(54)
47 1.1 matt #define L1_BLK_PXN __BIT(53)
48 1.1 matt #define L1_BLK_CONTIG __BIT(52)
49 1.1 matt #define L1_BLK_OA __BITS(47, 30) /* 1GB */
50 1.1 matt #define L1_BLK_NG __BIT(11) // Not Global
51 1.1 matt #define L1_BLK_AF __BIT(10) // Access Flag
52 1.1 matt #define L1_BLK_SH __BITS(9,8) // Shareability
53 1.1 matt #define L1_BLK_AP __BITS(7,6)
54 1.1 matt #define L1_BLK_NS __BIT(5)
55 1.1 matt #define L1_BLK_ATTR_INDX __BITS(4,2)
56 1.1 matt
57 1.1 matt #define LX_TBL_NLTA_4K __BITS(47, 12)
58 1.1 matt #define LX_TBL_NLTA_16K __BITS(47, 14)
59 1.1 matt #define LX_TBL_NLTA_64K __BITS(47, 16)
60 1.1 matt #define L1_TBL_NS_TABLE __BIT(63)
61 1.1 matt #define L1_TBL_AP_TABLE __BITS(62,61)
62 1.1 matt #define L1_TBL_XN_TABLE __BIT(60)
63 1.1 matt #define L1_TBL_PXN_TABLE __BIT(59)
64 1.1 matt
65 1.1 matt #define L2_BLKPAG_OS __BITS(58, 55)
66 1.1 matt #define L2_BLKPAG_UXN __BIT(54)
67 1.1 matt #define L2_BLKPAG_CONTIG __BIT(52)
68 1.1 matt #define L2_BLK_OA_4K __BITS(47, 21) // 2MB
69 1.1 matt #define L2_BLK_OA_16K __BITS(47, 25) // 32MB
70 1.1 matt #define L2_BLK_OA_64K __BITS(47, 29) // 512MB
71 1.1 matt #define L2_BLKPAG_AF __BIT(10) // Access Flag
72 1.1 matt #define L2_BLKPAG_SH __BITS(9,8) // Shareability
73 1.1 matt #define L2_BLKPAG_S2AP __BITS(7,6)
74 1.1 matt #define L2_BLKPAG_MEM_ATTR __BITS(5,2)
75 1.1 matt
76 1.1 matt #define L3_PAG_OA_4K __BITS(47, 12)
77 1.1 matt #define L3_PAG_OA_16K __BITS(47, 14)
78 1.1 matt #define L3_PAG_OA_64K __BITS(47, 16)
79 1.1 matt
80 1.1 matt #define TCR_TBI1 __BIT(38) // ignore Top Byte for TTBR1_EL1
81 1.1 matt #define TCR_TBI0 __BIT(37) // ignore Top Byte for TTBR0_EL1
82 1.1 matt #define TCR_AS64K __BIT(36) // Use 64K ASIDs
83 1.1 matt #define TCR_IPS __BITS(34,32) // Intermediate Phys Addr Size
84 1.1 matt #define TCR_IPS_256TB 5 // 48 bits (256 TB)
85 1.1 matt #define TCR_IPS_64TB 4 // 44 bits (16 TB)
86 1.1 matt #define TCR_IPS_4TB 3 // 42 bits ( 4 TB)
87 1.1 matt #define TCR_IPS_1TB 2 // 40 bits ( 1 TB)
88 1.1 matt #define TCR_IPS_64GB 1 // 36 bits (64 GB)
89 1.1 matt #define TCR_IPS_4GB 0 // 32 bits (4 GB)
90 1.1 matt #define TCR_TG1 __BITS(31,30) // Page Granule Size
91 1.1 matt #define TCR_PAGE_SIZE1(tcr) (1L << (__SHIFTOUT(tcr, TCR_TG1) * 2 + 10))
92 1.1 matt #define TCR_TG_4KB 1 // 4KB page size
93 1.1 matt #define TCR_TG_16KB 2 // 16KB page size
94 1.1 matt #define TCR_TG_64KB 3 // 64KB page size
95 1.1 matt #define TCR_SH1 __BITS(29,28)
96 1.1 matt #define TCR_SH_NONE 0
97 1.1 matt #define TCR_SH_OUTER 1
98 1.1 matt #define TCR_SH_INNER 2
99 1.1 matt #define TCR_ORGN1 __BITS(27,26)
100 1.1 matt #define TCR_XRGN_NC 0 // Non Cacheable
101 1.1 matt #define TCR_XRGN_WB_WA 1 // WriteBack WriteAllocate
102 1.1 matt #define TCR_XRGN_WT 0 // WriteThrough
103 1.1 matt #define TCR_XRGN_WB 0 // WriteBack
104 1.1 matt #define TCR_IRGN1 __BITS(25,24)
105 1.1 matt #define TCR_EPD1 __BIT(23) // Walk Disable for TTBR1_EL1
106 1.1 matt #define TCR_A1 __BIT(22) // ASID is in TTBR1_EL1
107 1.1 matt #define TCR_T1SZ __BITS(21,16) // Size offset for TTBR1_EL1
108 1.1 matt #define TCR_TG0 __BITS(15,14)
109 1.1 matt #define TCR_SH0 __BITS(13,12)
110 1.1 matt #define TCR_ORGN1 __BITS(11,10)
111 1.1 matt #define TCR_IRGN1 __BITS(9,8)
112 1.1 matt #define TCR_EPD0 __BIT(7) // Walk Disable for TTBR0
113 1.1 matt #define TCR_T0SZ __BITS(5,0) // Size offset for TTBR0_EL1
114 1.1 matt
115 1.1 matt #define TTBR_ASID __BITS(63, 48)
116 1.1 matt #define TTBR_BADDR __BITS(47, 0)
117 1.1 matt
118 1.1 matt #elif defined(__arm__)
119 1.1 matt
120 1.1 matt #include <arm/pte.h>
121 1.1 matt
122 1.1 matt #endif /* __aarch64__/__arm__ */
123 1.1 matt
124 1.1 matt #endif /* _AARCH64_PTE_H_ */
125