18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Declarations for to Hexagon Virtal Machine. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef ASM_HEXAGON_VM_H 98c2ecf20Sopenharmony_ci#define ASM_HEXAGON_VM_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* 128c2ecf20Sopenharmony_ci * In principle, a Linux kernel for the VM could 138c2ecf20Sopenharmony_ci * selectively define the virtual instructions 148c2ecf20Sopenharmony_ci * as inline assembler macros, but for a first pass, 158c2ecf20Sopenharmony_ci * we'll use subroutines for both the VM and the native 168c2ecf20Sopenharmony_ci * kernels. It's costing a subroutine call/return, 178c2ecf20Sopenharmony_ci * but it makes for a single set of entry points 188c2ecf20Sopenharmony_ci * for tracing/debugging. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMVERSION 0 228c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMRTE 1 238c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSETVEC 2 248c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSETIE 3 258c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMGETIE 4 268c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMINTOP 5 278c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMCLRMAP 10 288c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMNEWMAP 11 298c2ecf20Sopenharmony_ci#define HVM_TRAP1_FORMERLY_VMWIRE 12 308c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMCACHE 13 318c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMGETTIME 14 328c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSETTIME 15 338c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMWAIT 16 348c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMYIELD 17 358c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSTART 18 368c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSTOP 19 378c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMVPID 20 388c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMSETREGS 21 398c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMGETREGS 22 408c2ecf20Sopenharmony_ci#define HVM_TRAP1_VMTIMEROP 24 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cienum VM_CACHE_OPS { 458c2ecf20Sopenharmony_ci hvmc_ickill, 468c2ecf20Sopenharmony_ci hvmc_dckill, 478c2ecf20Sopenharmony_ci hvmc_l2kill, 488c2ecf20Sopenharmony_ci hvmc_dccleaninva, 498c2ecf20Sopenharmony_ci hvmc_icinva, 508c2ecf20Sopenharmony_ci hvmc_idsync, 518c2ecf20Sopenharmony_ci hvmc_fetch_cfg 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cienum VM_INT_OPS { 558c2ecf20Sopenharmony_ci hvmi_nop, 568c2ecf20Sopenharmony_ci hvmi_globen, 578c2ecf20Sopenharmony_ci hvmi_globdis, 588c2ecf20Sopenharmony_ci hvmi_locen, 598c2ecf20Sopenharmony_ci hvmi_locdis, 608c2ecf20Sopenharmony_ci hvmi_affinity, 618c2ecf20Sopenharmony_ci hvmi_get, 628c2ecf20Sopenharmony_ci hvmi_peek, 638c2ecf20Sopenharmony_ci hvmi_status, 648c2ecf20Sopenharmony_ci hvmi_post, 658c2ecf20Sopenharmony_ci hvmi_clear 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciextern void _K_VM_event_vector(void); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_civoid __vmrte(void); 718c2ecf20Sopenharmony_cilong __vmsetvec(void *); 728c2ecf20Sopenharmony_cilong __vmsetie(long); 738c2ecf20Sopenharmony_cilong __vmgetie(void); 748c2ecf20Sopenharmony_cilong __vmintop(enum VM_INT_OPS, long, long, long, long); 758c2ecf20Sopenharmony_cilong __vmclrmap(void *, unsigned long); 768c2ecf20Sopenharmony_cilong __vmnewmap(void *); 778c2ecf20Sopenharmony_cilong __vmcache(enum VM_CACHE_OPS op, unsigned long addr, unsigned long len); 788c2ecf20Sopenharmony_ciunsigned long long __vmgettime(void); 798c2ecf20Sopenharmony_cilong __vmsettime(unsigned long long); 808c2ecf20Sopenharmony_cilong __vmstart(void *, void *); 818c2ecf20Sopenharmony_civoid __vmstop(void); 828c2ecf20Sopenharmony_cilong __vmwait(void); 838c2ecf20Sopenharmony_civoid __vmyield(void); 848c2ecf20Sopenharmony_cilong __vmvpid(void); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic inline long __vmcache_ickill(void) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci return __vmcache(hvmc_ickill, 0, 0); 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic inline long __vmcache_dckill(void) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci return __vmcache(hvmc_dckill, 0, 0); 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistatic inline long __vmcache_l2kill(void) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci return __vmcache(hvmc_l2kill, 0, 0); 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistatic inline long __vmcache_dccleaninva(unsigned long addr, unsigned long len) 1028c2ecf20Sopenharmony_ci{ 1038c2ecf20Sopenharmony_ci return __vmcache(hvmc_dccleaninva, addr, len); 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic inline long __vmcache_icinva(unsigned long addr, unsigned long len) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci return __vmcache(hvmc_icinva, addr, len); 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistatic inline long __vmcache_idsync(unsigned long addr, 1128c2ecf20Sopenharmony_ci unsigned long len) 1138c2ecf20Sopenharmony_ci{ 1148c2ecf20Sopenharmony_ci return __vmcache(hvmc_idsync, addr, len); 1158c2ecf20Sopenharmony_ci} 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistatic inline long __vmcache_fetch_cfg(unsigned long val) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci return __vmcache(hvmc_fetch_cfg, val, 0); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* interrupt operations */ 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic inline long __vmintop_nop(void) 1258c2ecf20Sopenharmony_ci{ 1268c2ecf20Sopenharmony_ci return __vmintop(hvmi_nop, 0, 0, 0, 0); 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistatic inline long __vmintop_globen(long i) 1308c2ecf20Sopenharmony_ci{ 1318c2ecf20Sopenharmony_ci return __vmintop(hvmi_globen, i, 0, 0, 0); 1328c2ecf20Sopenharmony_ci} 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_cistatic inline long __vmintop_globdis(long i) 1358c2ecf20Sopenharmony_ci{ 1368c2ecf20Sopenharmony_ci return __vmintop(hvmi_globdis, i, 0, 0, 0); 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic inline long __vmintop_locen(long i) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci return __vmintop(hvmi_locen, i, 0, 0, 0); 1428c2ecf20Sopenharmony_ci} 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistatic inline long __vmintop_locdis(long i) 1458c2ecf20Sopenharmony_ci{ 1468c2ecf20Sopenharmony_ci return __vmintop(hvmi_locdis, i, 0, 0, 0); 1478c2ecf20Sopenharmony_ci} 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistatic inline long __vmintop_affinity(long i, long cpu) 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci return __vmintop(hvmi_affinity, i, cpu, 0, 0); 1528c2ecf20Sopenharmony_ci} 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistatic inline long __vmintop_get(void) 1558c2ecf20Sopenharmony_ci{ 1568c2ecf20Sopenharmony_ci return __vmintop(hvmi_get, 0, 0, 0, 0); 1578c2ecf20Sopenharmony_ci} 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic inline long __vmintop_peek(void) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci return __vmintop(hvmi_peek, 0, 0, 0, 0); 1628c2ecf20Sopenharmony_ci} 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cistatic inline long __vmintop_status(long i) 1658c2ecf20Sopenharmony_ci{ 1668c2ecf20Sopenharmony_ci return __vmintop(hvmi_status, i, 0, 0, 0); 1678c2ecf20Sopenharmony_ci} 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_cistatic inline long __vmintop_post(long i) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci return __vmintop(hvmi_post, i, 0, 0, 0); 1728c2ecf20Sopenharmony_ci} 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistatic inline long __vmintop_clear(long i) 1758c2ecf20Sopenharmony_ci{ 1768c2ecf20Sopenharmony_ci return __vmintop(hvmi_clear, i, 0, 0, 0); 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci#else /* Only assembly code should reference these */ 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci/* 1848c2ecf20Sopenharmony_ci * Constants for virtual instruction parameters and return values 1858c2ecf20Sopenharmony_ci */ 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* vmnewmap arguments */ 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#define VM_TRANS_TYPE_LINEAR 0 1908c2ecf20Sopenharmony_ci#define VM_TRANS_TYPE_TABLE 1 1918c2ecf20Sopenharmony_ci#define VM_TLB_INVALIDATE_FALSE 0 1928c2ecf20Sopenharmony_ci#define VM_TLB_INVALIDATE_TRUE 1 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci/* vmsetie arguments */ 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci#define VM_INT_DISABLE 0 1978c2ecf20Sopenharmony_ci#define VM_INT_ENABLE 1 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* vmsetimask arguments */ 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define VM_INT_UNMASK 0 2028c2ecf20Sopenharmony_ci#define VM_INT_MASK 1 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci#define VM_NEWMAP_TYPE_LINEAR 0 2058c2ecf20Sopenharmony_ci#define VM_NEWMAP_TYPE_PGTABLES 1 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/* 2098c2ecf20Sopenharmony_ci * Event Record definitions useful to both C and Assembler 2108c2ecf20Sopenharmony_ci */ 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci/* VMEST Layout */ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci#define HVM_VMEST_UM_SFT 31 2158c2ecf20Sopenharmony_ci#define HVM_VMEST_UM_MSK 1 2168c2ecf20Sopenharmony_ci#define HVM_VMEST_IE_SFT 30 2178c2ecf20Sopenharmony_ci#define HVM_VMEST_IE_MSK 1 2188c2ecf20Sopenharmony_ci#define HVM_VMEST_SS_SFT 29 2198c2ecf20Sopenharmony_ci#define HVM_VMEST_SS_MSK 1 2208c2ecf20Sopenharmony_ci#define HVM_VMEST_EVENTNUM_SFT 16 2218c2ecf20Sopenharmony_ci#define HVM_VMEST_EVENTNUM_MSK 0xff 2228c2ecf20Sopenharmony_ci#define HVM_VMEST_CAUSE_SFT 0 2238c2ecf20Sopenharmony_ci#define HVM_VMEST_CAUSE_MSK 0xffff 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci/* 2268c2ecf20Sopenharmony_ci * The initial program gets to find a system environment descriptor 2278c2ecf20Sopenharmony_ci * on its stack when it begins execution. The first word is a version 2288c2ecf20Sopenharmony_ci * code to indicate what is there. Zero means nothing more. 2298c2ecf20Sopenharmony_ci */ 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define HEXAGON_VM_SED_NULL 0 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci/* 2348c2ecf20Sopenharmony_ci * Event numbers for vector binding 2358c2ecf20Sopenharmony_ci */ 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci#define HVM_EV_RESET 0 2388c2ecf20Sopenharmony_ci#define HVM_EV_MACHCHECK 1 2398c2ecf20Sopenharmony_ci#define HVM_EV_GENEX 2 2408c2ecf20Sopenharmony_ci#define HVM_EV_TRAP 8 2418c2ecf20Sopenharmony_ci#define HVM_EV_INTR 15 2428c2ecf20Sopenharmony_ci/* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */ 2438c2ecf20Sopenharmony_ci#define HVM_EV_INTR_0 16 2448c2ecf20Sopenharmony_ci#define HVM_MAX_INTR 240 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci/* 2478c2ecf20Sopenharmony_ci * Cause values for General Exception 2488c2ecf20Sopenharmony_ci */ 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci#define HVM_GE_C_BUS 0x01 2518c2ecf20Sopenharmony_ci#define HVM_GE_C_XPROT 0x11 2528c2ecf20Sopenharmony_ci#define HVM_GE_C_XUSER 0x14 2538c2ecf20Sopenharmony_ci#define HVM_GE_C_INVI 0x15 2548c2ecf20Sopenharmony_ci#define HVM_GE_C_PRIVI 0x1B 2558c2ecf20Sopenharmony_ci#define HVM_GE_C_XMAL 0x1C 2568c2ecf20Sopenharmony_ci#define HVM_GE_C_WREG 0x1D 2578c2ecf20Sopenharmony_ci#define HVM_GE_C_PCAL 0x1E 2588c2ecf20Sopenharmony_ci#define HVM_GE_C_RMAL 0x20 2598c2ecf20Sopenharmony_ci#define HVM_GE_C_WMAL 0x21 2608c2ecf20Sopenharmony_ci#define HVM_GE_C_RPROT 0x22 2618c2ecf20Sopenharmony_ci#define HVM_GE_C_WPROT 0x23 2628c2ecf20Sopenharmony_ci#define HVM_GE_C_RUSER 0x24 2638c2ecf20Sopenharmony_ci#define HVM_GE_C_WUSER 0x25 2648c2ecf20Sopenharmony_ci#define HVM_GE_C_CACHE 0x28 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci/* 2678c2ecf20Sopenharmony_ci * Cause codes for Machine Check 2688c2ecf20Sopenharmony_ci */ 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci#define HVM_MCHK_C_DOWN 0x00 2718c2ecf20Sopenharmony_ci#define HVM_MCHK_C_BADSP 0x01 2728c2ecf20Sopenharmony_ci#define HVM_MCHK_C_BADEX 0x02 2738c2ecf20Sopenharmony_ci#define HVM_MCHK_C_BADPT 0x03 2748c2ecf20Sopenharmony_ci#define HVM_MCHK_C_REGWR 0x29 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci#endif 277