28 #define __HV_SIZE_ONE 1
29 #elif !defined(__tile__) && CHIP_VA_WIDTH() > 32
31 #define __HV_SIZE_ONE 1ULL
34 #define __HV_SIZE_ONE 1UL
39 #define HV_LOG2_L1_SPAN 32
43 #define HV_L1_SPAN (__HV_SIZE_ONE << HV_LOG2_L1_SPAN)
48 #define HV_LOG2_DEFAULT_PAGE_SIZE_SMALL 16
54 #define HV_DEFAULT_PAGE_SIZE_SMALL \
55 (__HV_SIZE_ONE << HV_LOG2_DEFAULT_PAGE_SIZE_SMALL)
60 #define HV_LOG2_DEFAULT_PAGE_SIZE_LARGE 24
66 #define HV_DEFAULT_PAGE_SIZE_LARGE \
67 (__HV_SIZE_ONE << HV_LOG2_DEFAULT_PAGE_SIZE_LARGE)
69 #if CHIP_VA_WIDTH() > 32
74 #define HV_LOG2_DEFAULT_PAGE_SIZE_JUMBO 32
80 #define HV_DEFAULT_PAGE_SIZE_JUMBO \
81 (__HV_SIZE_ONE << HV_LOG2_DEFAULT_PAGE_SIZE_JUMBO)
89 #define HV_LOG2_PAGE_TABLE_ALIGN 11
93 #define HV_PAGE_TABLE_ALIGN (__HV_SIZE_ONE << HV_LOG2_PAGE_TABLE_ALIGN)
96 #define HV_GLUE_START_CPA 0x10000
104 #define HV_GLUE_RESERVED_SIZE 0x10000
107 #define HV_DISPATCH_ENTRY_SIZE 32
110 #define _HV_VERSION 11
127 #define _HV_DISPATCH_RESERVED 0
130 #define HV_DISPATCH_INIT 1
133 #define HV_DISPATCH_INSTALL_CONTEXT 2
136 #define HV_DISPATCH_SYSCONF 3
139 #define HV_DISPATCH_GET_RTC 4
142 #define HV_DISPATCH_SET_RTC 5
145 #define HV_DISPATCH_FLUSH_ASID 6
148 #define HV_DISPATCH_FLUSH_PAGE 7
151 #define HV_DISPATCH_FLUSH_PAGES 8
154 #define HV_DISPATCH_RESTART 9
157 #define HV_DISPATCH_HALT 10
160 #define HV_DISPATCH_POWER_OFF 11
163 #define HV_DISPATCH_INQUIRE_PHYSICAL 12
166 #define HV_DISPATCH_INQUIRE_MEMORY_CONTROLLER 13
169 #define HV_DISPATCH_INQUIRE_VIRTUAL 14
172 #define HV_DISPATCH_INQUIRE_ASID 15
175 #define HV_DISPATCH_NANOSLEEP 16
178 #define HV_DISPATCH_CONSOLE_READ_IF_READY 17
181 #define HV_DISPATCH_CONSOLE_WRITE 18
184 #define HV_DISPATCH_DOWNCALL_DISPATCH 19
187 #define HV_DISPATCH_INQUIRE_TOPOLOGY 20
190 #define HV_DISPATCH_FS_FINDFILE 21
193 #define HV_DISPATCH_FS_FSTAT 22
196 #define HV_DISPATCH_FS_PREAD 23
199 #define HV_DISPATCH_PHYSADDR_READ64 24
202 #define HV_DISPATCH_PHYSADDR_WRITE64 25
205 #define HV_DISPATCH_GET_COMMAND_LINE 26
208 #define HV_DISPATCH_SET_CACHING 27
211 #define HV_DISPATCH_BZERO_PAGE 28
214 #define HV_DISPATCH_REGISTER_MESSAGE_STATE 29
217 #define HV_DISPATCH_SEND_MESSAGE 30
220 #define HV_DISPATCH_RECEIVE_MESSAGE 31
223 #define HV_DISPATCH_INQUIRE_CONTEXT 32
226 #define HV_DISPATCH_START_ALL_TILES 33
229 #define HV_DISPATCH_DEV_OPEN 34
232 #define HV_DISPATCH_DEV_CLOSE 35
235 #define HV_DISPATCH_DEV_PREAD 36
238 #define HV_DISPATCH_DEV_PWRITE 37
241 #define HV_DISPATCH_DEV_POLL 38
244 #define HV_DISPATCH_DEV_POLL_CANCEL 39
247 #define HV_DISPATCH_DEV_PREADA 40
250 #define HV_DISPATCH_DEV_PWRITEA 41
253 #define HV_DISPATCH_FLUSH_REMOTE 42
256 #define HV_DISPATCH_CONSOLE_PUTC 43
259 #define HV_DISPATCH_INQUIRE_TILES 44
262 #define HV_DISPATCH_CONFSTR 45
265 #define HV_DISPATCH_REEXEC 46
268 #define HV_DISPATCH_SET_COMMAND_LINE 47
273 #define HV_DISPATCH_CLEAR_INTR 48
276 #define HV_DISPATCH_ENABLE_INTR 49
279 #define HV_DISPATCH_DISABLE_INTR 50
282 #define HV_DISPATCH_RAISE_INTR 51
285 #define HV_DISPATCH_TRIGGER_IPI 52
290 #define HV_DISPATCH_STORE_MAPPING 53
293 #define HV_DISPATCH_INQUIRE_REALPA 54
296 #define HV_DISPATCH_FLUSH_ALL 55
300 #define HV_DISPATCH_GET_IPI_PTE 56
304 #define HV_DISPATCH_SET_PTE_SUPER_SHIFT 57
307 #define _HV_DISPATCH_END 58
310 #ifndef __ASSEMBLER__
313 #include <asm/types.h>
326 #if CHIP_VA_WIDTH() > 32
358 #define HV_EINVAL -801
359 #define HV_ENODEV -802
360 #define HV_ENOENT -803
361 #define HV_EBADF -804
362 #define HV_EFAULT -805
363 #define HV_ERECIP -806
364 #define HV_E2BIG -807
365 #define HV_ENOTSUP -808
366 #define HV_EBUSY -809
367 #define HV_ENOSYS -810
368 #define HV_EPERM -811
369 #define HV_ENOTREADY -812
371 #define HV_ENOMEM -814
372 #define HV_EAGAIN -815
374 #define HV_ERR_MAX -801
375 #define HV_ERR_MIN -815
377 #ifndef __ASSEMBLER__
390 int chip_num,
int chip_rev_num);
444 #define HV_SYSCONF_TEMP_KTOC 273
449 #define HV_SYSCONF_OVERTEMP 999
543 #ifndef __BIG_ENDIAN__
575 #define HV_MAX_IPI_INTERRUPT 7
632 #define HV_RTC_NO_CHIP 0x1
637 #define HV_RTC_LOW_VOLTAGE 0x2
641 #if CHIP_WORD_SIZE() > 32
724 #define HV_CTX_DIRECTIO 0x1
727 #define HV_CTX_PG_SM_4K 0x10
728 #define HV_CTX_PG_SM_16K 0x20
729 #define HV_CTX_PG_SM_64K 0x40
730 #define HV_CTX_PG_SM_MASK 0xf0
732 #ifndef __ASSEMBLER__
975 #define HV_MSH_MIN_DIMM_SIZE_SHIFT 29
978 #define HV_MSH_MAX_DIMMS 8
983 #define HV_MSH_MIN_DIMM_SIZE_SHIFT 26
986 #define HV_MSH_MAX_DIMMS 2
991 #define HV_DIMM_TYPE_SHIFT 0
994 #define HV_DIMM_TYPE_MASK 0xf
997 #define HV_DIMM_SIZE_SHIFT 4
1000 #define HV_DIMM_SIZE_MASK 0xf
1074 #ifndef __BIG_ENDIAN__
1195 #define INT_MESSAGE_RCV_DWNCL INT_BOOT_ACCESS
1197 #define INT_DMATLB_MISS_DWNCL INT_DMA_ASID
1199 #define INT_SNITLB_MISS_DWNCL INT_SNI_ASID
1201 #define INT_DMATLB_ACCESS_DWNCL INT_DMA_CPL
1203 #define INT_DEV_INTR_DWNCL INT_WORLD_ACCESS
1205 #ifndef __ASSEMBLER__
1291 unsigned long long val);
1320 #define HV_COMMAND_LINE_LEN 256
1356 #if CHIP_VA_WIDTH() > 32
1404 #ifndef __BIG_ENDIAN__
1413 #else //__BIG_ENDIAN__
1489 #define HV_MAX_MESSAGE_SIZE 28
1499 #define HV_MSG_TILE 0x0
1500 #define HV_MSG_INTR 0x1
1542 HV_RcvMsgInfo hv_receive_message(HV_MsgState msgstate, HV_VirtAddr buf,
1616 #define HV_DEV_NB_EMPTY 0x1
1618 #define HV_DEV_NB_PARTIAL 0x2
1621 #define HV_DEV_NOCACHE 0x4
1627 #define HV_DEV_ALLFLAGS (HV_DEV_NB_EMPTY | HV_DEV_NB_PARTIAL | \
1656 int hv_dev_pwrite(int devhdl, __hv32 flags, HV_VirtAddr va, __hv32 len,
1661 #if CHIP_VA_WIDTH() > 32
1718 #define HV_DEVPOLL_READ 0x1
1719 #define HV_DEVPOLL_WRITE 0x2
1720 #define HV_DEVPOLL_FLUSH 0x4
1734 int hv_dev_poll_cancel(int devhdl);
1739 #if CHIP_VA_WIDTH() <= 32
1751 #define HV_SGL_MAXLEN 16
1795 int hv_dev_preada(int devhdl, __hv32 flags, __hv32 sgl_len,
1888 unsigned long* cache_cpumask,
1890 unsigned long tlb_pgsize,
unsigned long* tlb_cpumask,
1894 #define HV_FLUSH_EVICT_L2 (1UL << 31)
1897 #define HV_FLUSH_EVICT_L1I (1UL << 30)
1900 #define HV_FLUSH_MAX_CACHE_LEN ((1UL << 30) - 1)
1903 #define HV_FLUSH_ALL -1UL
1908 #define HV_FLUSH_EVICT_L2 (1 << 31)
1911 #define HV_FLUSH_EVICT_L1I (1 << 30)
1914 #define HV_FLUSH_MAX_CACHE_LEN ((1 << 30) - 1)
1917 #define HV_FLUSH_ALL -1
1921 #ifndef __ASSEMBLER__
1924 #define hv_pte_val(pte) ((pte).val)
1927 #define hv_pte(val) ((HV_PTE) { val })
1933 #define HV_LOG2_PTE_SIZE 3
1936 #define HV_PTE_SIZE (1 << HV_LOG2_PTE_SIZE)
1940 #define HV_PTE_INDEX_PRESENT 0
1941 #define HV_PTE_INDEX_MIGRATING 1
1942 #define HV_PTE_INDEX_CLIENT0 2
1943 #define HV_PTE_INDEX_CLIENT1 3
1944 #define HV_PTE_INDEX_NC 4
1945 #define HV_PTE_INDEX_NO_ALLOC_L1 5
1946 #define HV_PTE_INDEX_NO_ALLOC_L2 6
1947 #define HV_PTE_INDEX_CACHED_PRIORITY 7
1948 #define HV_PTE_INDEX_PAGE 8
1949 #define HV_PTE_INDEX_GLOBAL 9
1950 #define HV_PTE_INDEX_USER 10
1951 #define HV_PTE_INDEX_ACCESSED 11
1952 #define HV_PTE_INDEX_DIRTY 12
1955 #define HV_PTE_INDEX_SUPER 15
1956 #define HV_PTE_INDEX_MODE 16
1957 #define HV_PTE_MODE_BITS 3
1958 #define HV_PTE_INDEX_CLIENT2 19
1959 #define HV_PTE_INDEX_LOTAR 20
1961 #define HV_PTE_LOTAR_BITS 12
1964 #define HV_PTE_INDEX_READABLE 32
1965 #define HV_PTE_INDEX_WRITABLE 33
1966 #define HV_PTE_INDEX_EXECUTABLE 34
1967 #define HV_PTE_INDEX_PTFN 35
1969 #define HV_PTE_PTFN_BITS 29
1977 #define HV_PTE_MODE_UNCACHED 1
1985 #define HV_PTE_MODE_CACHE_NO_L3 2
1999 #define HV_PTE_MODE_CACHE_TILE_L3 3
2016 #define HV_PTE_MODE_CACHE_HASH_L3 4
2023 #define HV_PTE_MODE_MMIO 5
2031 #ifdef __ASSEMBLER__
2032 #define __HV_PTE_ONE 1
2034 #define __HV_PTE_ONE 1ULL
2046 #define HV_PTE_PRESENT (__HV_PTE_ONE << HV_PTE_INDEX_PRESENT)
2061 #define HV_PTE_PAGE (__HV_PTE_ONE << HV_PTE_INDEX_PAGE)
2073 #define HV_PTE_SUPER (__HV_PTE_ONE << HV_PTE_INDEX_SUPER)
2093 #define HV_PTE_GLOBAL (__HV_PTE_ONE << HV_PTE_INDEX_GLOBAL)
2106 #define HV_PTE_USER (__HV_PTE_ONE << HV_PTE_INDEX_USER)
2118 #define HV_PTE_ACCESSED (__HV_PTE_ONE << HV_PTE_INDEX_ACCESSED)
2130 #define HV_PTE_DIRTY (__HV_PTE_ONE << HV_PTE_INDEX_DIRTY)
2138 #define HV_PTE_MIGRATING (__HV_PTE_ONE << HV_PTE_INDEX_MIGRATING)
2145 #define HV_PTE_CLIENT0 (__HV_PTE_ONE << HV_PTE_INDEX_CLIENT0)
2152 #define HV_PTE_CLIENT1 (__HV_PTE_ONE << HV_PTE_INDEX_CLIENT1)
2159 #define HV_PTE_CLIENT2 (__HV_PTE_ONE << HV_PTE_INDEX_CLIENT2)
2171 #define HV_PTE_NC (__HV_PTE_ONE << HV_PTE_INDEX_NC)
2184 #define HV_PTE_NO_ALLOC_L1 (__HV_PTE_ONE << HV_PTE_INDEX_NO_ALLOC_L1)
2197 #define HV_PTE_NO_ALLOC_L2 (__HV_PTE_ONE << HV_PTE_INDEX_NO_ALLOC_L2)
2216 #define HV_PTE_CACHED_PRIORITY (__HV_PTE_ONE << \
2217 HV_PTE_INDEX_CACHED_PRIORITY)
2229 #define HV_PTE_READABLE (__HV_PTE_ONE << HV_PTE_INDEX_READABLE)
2239 #define HV_PTE_WRITABLE (__HV_PTE_ONE << HV_PTE_INDEX_WRITABLE)
2251 #define HV_PTE_EXECUTABLE (__HV_PTE_ONE << HV_PTE_INDEX_EXECUTABLE)
2254 #define HV_LOTAR_WIDTH 11
2257 #define HV_XY_TO_LOTAR(x, y) ((HV_LOTAR)(((x) << HV_LOTAR_WIDTH) | (y)))
2260 #define HV_LOTAR_X(lotar) ((lotar) >> HV_LOTAR_WIDTH)
2263 #define HV_LOTAR_Y(lotar) ((lotar) & ((1 << HV_LOTAR_WIDTH) - 1))
2265 #ifndef __ASSEMBLER__
2268 #define _HV_BIT(name, bit) \
2269 static __inline int \
2270 hv_pte_get_##name(HV_PTE pte) \
2272 return (pte.val >> HV_PTE_INDEX_##bit) & 1; \
2275 static __inline HV_PTE \
2276 hv_pte_set_##name(HV_PTE pte) \
2278 pte.val |= 1ULL << HV_PTE_INDEX_##bit; \
2282 static __inline HV_PTE \
2283 hv_pte_clear_##name(HV_PTE pte) \
2285 pte.val &= ~(1ULL << HV_PTE_INDEX_##bit); \
2301 _HV_BIT(executable, EXECUTABLE)
2304 _HV_BIT(no_alloc_l1, NO_ALLOC_L1)
2305 _HV_BIT(no_alloc_l2, NO_ALLOC_L2)
2306 _HV_BIT(cached_priority, CACHED_PRIORITY)
2385 hv_pte_get_lotar(
const HV_PTE pte)
2396 hv_pte_set_lotar(
HV_PTE pte,
unsigned int val)
2410 #define HV_CPA_TO_PTFN(p) ((p) >> HV_LOG2_PAGE_TABLE_ALIGN)
2413 #define HV_PTFN_TO_CPA(p) (((HV_PhysAddr)(p)) << HV_LOG2_PAGE_TABLE_ALIGN)
2415 #if CHIP_VA_WIDTH() > 32
2424 #define HV_LOG2_L0_ENTRIES (CHIP_VA_WIDTH() - HV_LOG2_L1_SPAN)
2427 #define HV_L0_ENTRIES (1 << HV_LOG2_L0_ENTRIES)
2430 #define HV_LOG2_L0_SIZE (HV_LOG2_PTE_SIZE + HV_LOG2_L0_ENTRIES)
2433 #define HV_L0_SIZE (1 << HV_LOG2_L0_SIZE)
2435 #ifdef __ASSEMBLER__
2438 #define HV_L0_INDEX(va) \
2439 (((va) >> HV_LOG2_L1_SPAN) & (HV_L0_ENTRIES - 1))
2444 #define HV_L0_INDEX(va) \
2445 (((HV_VirtAddr)(va) >> HV_LOG2_L1_SPAN) & (HV_L0_ENTRIES - 1))
2452 #define _HV_LOG2_L1_ENTRIES(log2_page_size_large) \
2453 (HV_LOG2_L1_SPAN - log2_page_size_large)
2456 #define _HV_L1_ENTRIES(log2_page_size_large) \
2457 (1 << _HV_LOG2_L1_ENTRIES(log2_page_size_large))
2460 #define _HV_LOG2_L1_SIZE(log2_page_size_large) \
2461 (HV_LOG2_PTE_SIZE + _HV_LOG2_L1_ENTRIES(log2_page_size_large))
2464 #define _HV_L1_SIZE(log2_page_size_large) \
2465 (1 << _HV_LOG2_L1_SIZE(log2_page_size_large))
2468 #define _HV_LOG2_L2_ENTRIES(log2_page_size_large, log2_page_size_small) \
2469 (log2_page_size_large - log2_page_size_small)
2472 #define _HV_L2_ENTRIES(log2_page_size_large, log2_page_size_small) \
2473 (1 << _HV_LOG2_L2_ENTRIES(log2_page_size_large, log2_page_size_small))
2476 #define _HV_LOG2_L2_SIZE(log2_page_size_large, log2_page_size_small) \
2477 (HV_LOG2_PTE_SIZE + \
2478 _HV_LOG2_L2_ENTRIES(log2_page_size_large, log2_page_size_small))
2481 #define _HV_L2_SIZE(log2_page_size_large, log2_page_size_small) \
2482 (1 << _HV_LOG2_L2_SIZE(log2_page_size_large, log2_page_size_small))
2484 #ifdef __ASSEMBLER__
2486 #if CHIP_VA_WIDTH() > 32
2489 #define _HV_L1_INDEX(va, log2_page_size_large) \
2490 (((va) >> log2_page_size_large) & (_HV_L1_ENTRIES(log2_page_size_large) - 1))
2495 #define _HV_L1_INDEX(va, log2_page_size_large) \
2496 (((va) >> log2_page_size_large))
2501 #define _HV_L2_INDEX(va, log2_page_size_large, log2_page_size_small) \
2502 (((va) >> log2_page_size_small) & \
2503 (_HV_L2_ENTRIES(log2_page_size_large, log2_page_size_small) - 1))
2507 #if CHIP_VA_WIDTH() > 32
2510 #define _HV_L1_INDEX(va, log2_page_size_large) \
2511 (((HV_VirtAddr)(va) >> log2_page_size_large) & \
2512 (_HV_L1_ENTRIES(log2_page_size_large) - 1))
2517 #define _HV_L1_INDEX(va, log2_page_size_large) \
2518 (((HV_VirtAddr)(va) >> log2_page_size_large))
2523 #define _HV_L2_INDEX(va, log2_page_size_large, log2_page_size_small) \
2524 (((HV_VirtAddr)(va) >> log2_page_size_small) & \
2525 (_HV_L2_ENTRIES(log2_page_size_large, log2_page_size_small) - 1))
2530 #define _HV_PTE_INDEX_PFN(log2_page_size) \
2531 (HV_PTE_INDEX_PTFN + (log2_page_size - HV_LOG2_PAGE_TABLE_ALIGN))
2534 #define _HV_PTE_INDEX_PFN_BITS(log2_page_size) \
2535 (HV_PTE_INDEX_PTFN_BITS - (log2_page_size - HV_LOG2_PAGE_TABLE_ALIGN))
2538 #define _HV_CPA_TO_PFN(p, log2_page_size) ((p) >> log2_page_size)
2541 #define _HV_PFN_TO_CPA(p, log2_page_size) \
2542 (((HV_PhysAddr)(p)) << log2_page_size)
2545 #define _HV_PTFN_TO_PFN(p, log2_page_size) \
2546 ((p) >> (log2_page_size - HV_LOG2_PAGE_TABLE_ALIGN))
2549 #define _HV_PFN_TO_PTFN(p, log2_page_size) \
2550 ((p) << (log2_page_size - HV_LOG2_PAGE_TABLE_ALIGN))