1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ |
---|
2 | /* |
---|
3 | * vmx_mm_def.h: |
---|
4 | * Copyright (c) 2004, Intel Corporation. |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify it |
---|
7 | * under the terms and conditions of the GNU General Public License, |
---|
8 | * version 2, as published by the Free Software Foundation. |
---|
9 | * |
---|
10 | * This program is distributed in the hope it will be useful, but WITHOUT |
---|
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
13 | * more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License along with |
---|
16 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
17 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
---|
18 | * |
---|
19 | * Kun Tian (Kevin Tian) (kevin.tian@intel.com) |
---|
20 | */ |
---|
21 | #ifndef _MM_DEF_H_ |
---|
22 | #define _MM_DEF_H_ |
---|
23 | |
---|
24 | |
---|
25 | /* VHPT size 4M */ |
---|
26 | //#define VHPT_SIZE_PS 22 |
---|
27 | //#define VHPT_SIZE (1 << VHPT_SIZE_PS) |
---|
28 | #define ARCH_PAGE_SHIFT 12 |
---|
29 | #define ARCH_PAGE_SIZE PSIZE(ARCH_PAGE_SHIFT) |
---|
30 | #define MAX_PHYS_ADDR_BITS 50 |
---|
31 | #define GUEST_IMPL_VA_MSB 59 |
---|
32 | #define PMASK(size) (~((size) - 1)) |
---|
33 | #define PSIZE(size) (1UL<<(size)) |
---|
34 | //#define PAGE_SIZE_4K PSIZE(12) |
---|
35 | #define POFFSET(vaddr, ps) ((vaddr) & (PSIZE(ps) - 1)) |
---|
36 | #define PPN_2_PA(ppn) ((ppn)<<12) |
---|
37 | #define CLEARLSB(ppn, nbits) ((((uint64_t)ppn) >> (nbits)) << (nbits)) |
---|
38 | #define PAGEALIGN(va, ps) CLEARLSB(va, ps) |
---|
39 | |
---|
40 | #define TLB_AR_R 0 |
---|
41 | #define TLB_AR_RX 1 |
---|
42 | #define TLB_AR_RW 2 |
---|
43 | #define TLB_AR_RWX 3 |
---|
44 | #define TLB_AR_R_RW 4 |
---|
45 | #define TLB_AR_RX_RWX 5 |
---|
46 | #define TLB_AR_RWX_RW 6 |
---|
47 | #define TLB_AR_XP 7 |
---|
48 | |
---|
49 | #define IA64_ISR_CODE_MASK0 0xf |
---|
50 | #define IA64_UNIMPL_DADDR_FAULT 0x30 |
---|
51 | #define IA64_UNIMPL_IADDR_TRAP 0x10 |
---|
52 | #define IA64_RESERVED_REG_FAULT 0x30 |
---|
53 | #define IA64_REG_NAT_CONSUMPTION_FAULT 0x10 |
---|
54 | #define IA64_NAT_CONSUMPTION_FAULT 0x20 |
---|
55 | #define IA64_PRIV_OP_FAULT 0x10 |
---|
56 | |
---|
57 | #define DEFER_NONE 0 |
---|
58 | #define DEFER_ALWAYS 0x1 |
---|
59 | #define DEFER_DM 0x100 /* bit 8 */ |
---|
60 | #define DEFER_DP 0X200 /* bit 9 */ |
---|
61 | #define DEFER_DK 0x400 /* bit 10 */ |
---|
62 | #define DEFER_DX 0x800 /* bit 11 */ |
---|
63 | #define DEFER_DR 0x1000 /* bit 12 */ |
---|
64 | #define DEFER_DA 0x2000 /* bit 13 */ |
---|
65 | #define DEFER_DD 0x4000 /* bit 14 */ |
---|
66 | |
---|
67 | #define ACCESS_RIGHT(a) ((a) & (ACCESS_FETCHADD - 1)) |
---|
68 | |
---|
69 | #define ACCESS_READ 0x1 |
---|
70 | #define ACCESS_WRITE 0x2 |
---|
71 | #define ACCESS_EXECUTE 0x4 |
---|
72 | #define ACCESS_XP0 0x8 |
---|
73 | #define ACCESS_XP1 0x10 |
---|
74 | #define ACCESS_XP2 0x20 |
---|
75 | #define ACCESS_FETCHADD 0x40 |
---|
76 | #define ACCESS_XCHG 0x80 |
---|
77 | #define ACCESS_CMPXCHG 0x100 |
---|
78 | |
---|
79 | #define ACCESS_SIZE_1 0x10000 |
---|
80 | #define ACCESS_SIZE_2 0x20000 |
---|
81 | #define ACCESS_SIZE_4 0x40000 |
---|
82 | #define ACCESS_SIZE_8 0x80000 |
---|
83 | #define ACCESS_SIZE_10 0x100000 |
---|
84 | #define ACCESS_SIZE_16 0x200000 |
---|
85 | |
---|
86 | #define STLB_TC 0 |
---|
87 | #define STLB_TR 1 |
---|
88 | |
---|
89 | #define IA64_RR_SHIFT 61 |
---|
90 | |
---|
91 | #define PHYS_PAGE_SHIFT PPN_SHIFT |
---|
92 | |
---|
93 | #define STLB_SZ_SHIFT 8 // 256 |
---|
94 | #define STLB_SIZE (1UL<<STLB_SZ_SHIFT) |
---|
95 | #define STLB_PPS_SHIFT 12 |
---|
96 | #define STLB_PPS (1UL<<STLB_PPS_SHIFT) |
---|
97 | #define GUEST_TRNUM 8 |
---|
98 | |
---|
99 | /* Virtual address memory attributes encoding */ |
---|
100 | #define VA_MATTR_WB 0x0 |
---|
101 | #define VA_MATTR_UC 0x4 |
---|
102 | #define VA_MATTR_UCE 0x5 |
---|
103 | #define VA_MATTR_WC 0x6 |
---|
104 | #define VA_MATTR_NATPAGE 0x7 |
---|
105 | |
---|
106 | #define VRN_MASK 0xe000000000000000 |
---|
107 | #define PTA_BASE_MASK 0x3fffffffffffL |
---|
108 | #define PTA_BASE_SHIFT 15 |
---|
109 | #define VHPT_OFFSET_MASK 0x7fff |
---|
110 | |
---|
111 | #define BITS_SHIFT_256MB 28 |
---|
112 | #define SIZE_256MB (1UL<<BITS_SHIFT_256MB) |
---|
113 | #define TLB_GR_RV_BITS ((1UL<<1) | (3UL<<50)) |
---|
114 | #define HPA_MAPPING_ATTRIBUTE 0x61 //ED:0;AR:0;PL:0;D:1;A:1;P:1 |
---|
115 | #define VPN_2_VRN(vpn) ((vpn << PPN_SHIFT) >> IA64_VRN_SHIFT) |
---|
116 | |
---|
117 | #ifndef __ASSEMBLY__ |
---|
118 | typedef enum { INSTRUCTION, DATA, REGISTER } miss_type; |
---|
119 | |
---|
120 | //typedef enum { MVHPT, STLB } vtlb_loc_type_t; |
---|
121 | typedef enum { DATA_REF, NA_REF, INST_REF, RSE_REF } vhpt_ref_t; |
---|
122 | |
---|
123 | typedef enum { |
---|
124 | PIB_MMIO=0, |
---|
125 | VGA_BUFF, |
---|
126 | CHIPSET_IO, |
---|
127 | LOW_MMIO, |
---|
128 | LEGACY_IO, |
---|
129 | IO_SAPIC, |
---|
130 | NOT_IO |
---|
131 | } mmio_type_t; |
---|
132 | |
---|
133 | typedef struct mmio_list { |
---|
134 | mmio_type_t iot; |
---|
135 | u64 start; // start address of this memory IO block |
---|
136 | u64 end; // end address (include this one) |
---|
137 | } mmio_list_t; |
---|
138 | |
---|
139 | static __inline__ uint64_t |
---|
140 | bits_v(uint64_t v, uint32_t bs, uint32_t be) |
---|
141 | { |
---|
142 | uint64_t result; |
---|
143 | __asm __volatile("shl %0=%1, %2;; shr.u %0=%0, %3;;" |
---|
144 | : "=r" (result): "r"(v), "r"(63-be), "r" (bs+63-be) ); |
---|
145 | return result; |
---|
146 | } |
---|
147 | |
---|
148 | #define bits(val, bs, be) \ |
---|
149 | ({ \ |
---|
150 | u64 ret; \ |
---|
151 | \ |
---|
152 | __asm __volatile("extr.u %0=%1, %2, %3" \ |
---|
153 | : "=r" (ret): "r"(val), \ |
---|
154 | "M" ((bs)), \ |
---|
155 | "M" ((be) - (bs) + 1) ); \ |
---|
156 | ret; \ |
---|
157 | }) |
---|
158 | |
---|
159 | /* |
---|
160 | * clear bits (pos, len) from v. |
---|
161 | * |
---|
162 | */ |
---|
163 | #define clearbits(v, pos, len) \ |
---|
164 | ({ \ |
---|
165 | u64 ret; \ |
---|
166 | \ |
---|
167 | __asm __volatile("dep.z %0=%1, %2, %3" \ |
---|
168 | : "=r" (ret): "r"(v), \ |
---|
169 | "M" ((pos)), \ |
---|
170 | "M" ((len))); \ |
---|
171 | ret; \ |
---|
172 | }) |
---|
173 | #endif |
---|
174 | |
---|
175 | #endif |
---|