1*08dbd0f8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2e49ee290SRichard Kuo /*
3e49ee290SRichard Kuo * Declarations for to Hexagon Virtal Machine.
4e49ee290SRichard Kuo *
57c6a5df4SRichard Kuo * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
6e49ee290SRichard Kuo */
7e49ee290SRichard Kuo
8e49ee290SRichard Kuo #ifndef ASM_HEXAGON_VM_H
9e49ee290SRichard Kuo #define ASM_HEXAGON_VM_H
10e49ee290SRichard Kuo
11e49ee290SRichard Kuo /*
12e49ee290SRichard Kuo * In principle, a Linux kernel for the VM could
13e49ee290SRichard Kuo * selectively define the virtual instructions
14e49ee290SRichard Kuo * as inline assembler macros, but for a first pass,
15e49ee290SRichard Kuo * we'll use subroutines for both the VM and the native
16e49ee290SRichard Kuo * kernels. It's costing a subroutine call/return,
17e49ee290SRichard Kuo * but it makes for a single set of entry points
18e49ee290SRichard Kuo * for tracing/debugging.
19e49ee290SRichard Kuo */
20e49ee290SRichard Kuo
218f5a0b9dSRichard Kuo #define HVM_TRAP1_VMVERSION 0
228f5a0b9dSRichard Kuo #define HVM_TRAP1_VMRTE 1
238f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSETVEC 2
248f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSETIE 3
258f5a0b9dSRichard Kuo #define HVM_TRAP1_VMGETIE 4
268f5a0b9dSRichard Kuo #define HVM_TRAP1_VMINTOP 5
278f5a0b9dSRichard Kuo #define HVM_TRAP1_VMCLRMAP 10
288f5a0b9dSRichard Kuo #define HVM_TRAP1_VMNEWMAP 11
298f5a0b9dSRichard Kuo #define HVM_TRAP1_FORMERLY_VMWIRE 12
308f5a0b9dSRichard Kuo #define HVM_TRAP1_VMCACHE 13
318f5a0b9dSRichard Kuo #define HVM_TRAP1_VMGETTIME 14
328f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSETTIME 15
338f5a0b9dSRichard Kuo #define HVM_TRAP1_VMWAIT 16
348f5a0b9dSRichard Kuo #define HVM_TRAP1_VMYIELD 17
358f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSTART 18
368f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSTOP 19
378f5a0b9dSRichard Kuo #define HVM_TRAP1_VMVPID 20
388f5a0b9dSRichard Kuo #define HVM_TRAP1_VMSETREGS 21
398f5a0b9dSRichard Kuo #define HVM_TRAP1_VMGETREGS 22
408f5a0b9dSRichard Kuo #define HVM_TRAP1_VMTIMEROP 24
41e49ee290SRichard Kuo
42e49ee290SRichard Kuo #ifndef __ASSEMBLY__
43e49ee290SRichard Kuo
44e49ee290SRichard Kuo enum VM_CACHE_OPS {
456becd400SChen Gang hvmc_ickill,
466becd400SChen Gang hvmc_dckill,
476becd400SChen Gang hvmc_l2kill,
486becd400SChen Gang hvmc_dccleaninva,
496becd400SChen Gang hvmc_icinva,
506becd400SChen Gang hvmc_idsync,
516becd400SChen Gang hvmc_fetch_cfg
52e49ee290SRichard Kuo };
53e49ee290SRichard Kuo
54e49ee290SRichard Kuo enum VM_INT_OPS {
556becd400SChen Gang hvmi_nop,
566becd400SChen Gang hvmi_globen,
576becd400SChen Gang hvmi_globdis,
586becd400SChen Gang hvmi_locen,
596becd400SChen Gang hvmi_locdis,
606becd400SChen Gang hvmi_affinity,
616becd400SChen Gang hvmi_get,
626becd400SChen Gang hvmi_peek,
636becd400SChen Gang hvmi_status,
646becd400SChen Gang hvmi_post,
656becd400SChen Gang hvmi_clear
66e49ee290SRichard Kuo };
67e49ee290SRichard Kuo
68e49ee290SRichard Kuo extern void _K_VM_event_vector(void);
69e49ee290SRichard Kuo
70e49ee290SRichard Kuo void __vmrte(void);
71e49ee290SRichard Kuo long __vmsetvec(void *);
72e49ee290SRichard Kuo long __vmsetie(long);
73e49ee290SRichard Kuo long __vmgetie(void);
74e49ee290SRichard Kuo long __vmintop(enum VM_INT_OPS, long, long, long, long);
75e49ee290SRichard Kuo long __vmclrmap(void *, unsigned long);
76e49ee290SRichard Kuo long __vmnewmap(void *);
77e49ee290SRichard Kuo long __vmcache(enum VM_CACHE_OPS op, unsigned long addr, unsigned long len);
78e49ee290SRichard Kuo unsigned long long __vmgettime(void);
79e49ee290SRichard Kuo long __vmsettime(unsigned long long);
80e49ee290SRichard Kuo long __vmstart(void *, void *);
81e49ee290SRichard Kuo void __vmstop(void);
82e49ee290SRichard Kuo long __vmwait(void);
83e49ee290SRichard Kuo void __vmyield(void);
84e49ee290SRichard Kuo long __vmvpid(void);
85e49ee290SRichard Kuo
__vmcache_ickill(void)86e49ee290SRichard Kuo static inline long __vmcache_ickill(void)
87e49ee290SRichard Kuo {
886becd400SChen Gang return __vmcache(hvmc_ickill, 0, 0);
89e49ee290SRichard Kuo }
90e49ee290SRichard Kuo
__vmcache_dckill(void)91e49ee290SRichard Kuo static inline long __vmcache_dckill(void)
92e49ee290SRichard Kuo {
936becd400SChen Gang return __vmcache(hvmc_dckill, 0, 0);
94e49ee290SRichard Kuo }
95e49ee290SRichard Kuo
__vmcache_l2kill(void)96e49ee290SRichard Kuo static inline long __vmcache_l2kill(void)
97e49ee290SRichard Kuo {
986becd400SChen Gang return __vmcache(hvmc_l2kill, 0, 0);
99e49ee290SRichard Kuo }
100e49ee290SRichard Kuo
__vmcache_dccleaninva(unsigned long addr,unsigned long len)101e49ee290SRichard Kuo static inline long __vmcache_dccleaninva(unsigned long addr, unsigned long len)
102e49ee290SRichard Kuo {
1036becd400SChen Gang return __vmcache(hvmc_dccleaninva, addr, len);
104e49ee290SRichard Kuo }
105e49ee290SRichard Kuo
__vmcache_icinva(unsigned long addr,unsigned long len)106e49ee290SRichard Kuo static inline long __vmcache_icinva(unsigned long addr, unsigned long len)
107e49ee290SRichard Kuo {
1086becd400SChen Gang return __vmcache(hvmc_icinva, addr, len);
109e49ee290SRichard Kuo }
110e49ee290SRichard Kuo
__vmcache_idsync(unsigned long addr,unsigned long len)111e49ee290SRichard Kuo static inline long __vmcache_idsync(unsigned long addr,
112e49ee290SRichard Kuo unsigned long len)
113e49ee290SRichard Kuo {
1146becd400SChen Gang return __vmcache(hvmc_idsync, addr, len);
115e49ee290SRichard Kuo }
116e49ee290SRichard Kuo
__vmcache_fetch_cfg(unsigned long val)117e49ee290SRichard Kuo static inline long __vmcache_fetch_cfg(unsigned long val)
118e49ee290SRichard Kuo {
1196becd400SChen Gang return __vmcache(hvmc_fetch_cfg, val, 0);
120e49ee290SRichard Kuo }
121e49ee290SRichard Kuo
122e49ee290SRichard Kuo /* interrupt operations */
123e49ee290SRichard Kuo
__vmintop_nop(void)124e49ee290SRichard Kuo static inline long __vmintop_nop(void)
125e49ee290SRichard Kuo {
1266becd400SChen Gang return __vmintop(hvmi_nop, 0, 0, 0, 0);
127e49ee290SRichard Kuo }
128e49ee290SRichard Kuo
__vmintop_globen(long i)129e49ee290SRichard Kuo static inline long __vmintop_globen(long i)
130e49ee290SRichard Kuo {
1316becd400SChen Gang return __vmintop(hvmi_globen, i, 0, 0, 0);
132e49ee290SRichard Kuo }
133e49ee290SRichard Kuo
__vmintop_globdis(long i)134e49ee290SRichard Kuo static inline long __vmintop_globdis(long i)
135e49ee290SRichard Kuo {
1366becd400SChen Gang return __vmintop(hvmi_globdis, i, 0, 0, 0);
137e49ee290SRichard Kuo }
138e49ee290SRichard Kuo
__vmintop_locen(long i)139e49ee290SRichard Kuo static inline long __vmintop_locen(long i)
140e49ee290SRichard Kuo {
1416becd400SChen Gang return __vmintop(hvmi_locen, i, 0, 0, 0);
142e49ee290SRichard Kuo }
143e49ee290SRichard Kuo
__vmintop_locdis(long i)144e49ee290SRichard Kuo static inline long __vmintop_locdis(long i)
145e49ee290SRichard Kuo {
1466becd400SChen Gang return __vmintop(hvmi_locdis, i, 0, 0, 0);
147e49ee290SRichard Kuo }
148e49ee290SRichard Kuo
__vmintop_affinity(long i,long cpu)149e49ee290SRichard Kuo static inline long __vmintop_affinity(long i, long cpu)
150e49ee290SRichard Kuo {
1516becd400SChen Gang return __vmintop(hvmi_affinity, i, cpu, 0, 0);
152e49ee290SRichard Kuo }
153e49ee290SRichard Kuo
__vmintop_get(void)154e49ee290SRichard Kuo static inline long __vmintop_get(void)
155e49ee290SRichard Kuo {
1566becd400SChen Gang return __vmintop(hvmi_get, 0, 0, 0, 0);
157e49ee290SRichard Kuo }
158e49ee290SRichard Kuo
__vmintop_peek(void)159e49ee290SRichard Kuo static inline long __vmintop_peek(void)
160e49ee290SRichard Kuo {
1616becd400SChen Gang return __vmintop(hvmi_peek, 0, 0, 0, 0);
162e49ee290SRichard Kuo }
163e49ee290SRichard Kuo
__vmintop_status(long i)164e49ee290SRichard Kuo static inline long __vmintop_status(long i)
165e49ee290SRichard Kuo {
1666becd400SChen Gang return __vmintop(hvmi_status, i, 0, 0, 0);
167e49ee290SRichard Kuo }
168e49ee290SRichard Kuo
__vmintop_post(long i)169e49ee290SRichard Kuo static inline long __vmintop_post(long i)
170e49ee290SRichard Kuo {
1716becd400SChen Gang return __vmintop(hvmi_post, i, 0, 0, 0);
172e49ee290SRichard Kuo }
173e49ee290SRichard Kuo
__vmintop_clear(long i)174e49ee290SRichard Kuo static inline long __vmintop_clear(long i)
175e49ee290SRichard Kuo {
1766becd400SChen Gang return __vmintop(hvmi_clear, i, 0, 0, 0);
177e49ee290SRichard Kuo }
178e49ee290SRichard Kuo
179e49ee290SRichard Kuo #else /* Only assembly code should reference these */
180e49ee290SRichard Kuo
181e49ee290SRichard Kuo #endif /* __ASSEMBLY__ */
182e49ee290SRichard Kuo
183e49ee290SRichard Kuo /*
184e49ee290SRichard Kuo * Constants for virtual instruction parameters and return values
185e49ee290SRichard Kuo */
186e49ee290SRichard Kuo
1877959bd76SRichard Kuo /* vmnewmap arguments */
1887959bd76SRichard Kuo
1897959bd76SRichard Kuo #define VM_TRANS_TYPE_LINEAR 0
1907959bd76SRichard Kuo #define VM_TRANS_TYPE_TABLE 1
1917959bd76SRichard Kuo #define VM_TLB_INVALIDATE_FALSE 0
1927959bd76SRichard Kuo #define VM_TLB_INVALIDATE_TRUE 1
1937959bd76SRichard Kuo
194e49ee290SRichard Kuo /* vmsetie arguments */
195e49ee290SRichard Kuo
196e49ee290SRichard Kuo #define VM_INT_DISABLE 0
197e49ee290SRichard Kuo #define VM_INT_ENABLE 1
198e49ee290SRichard Kuo
199e49ee290SRichard Kuo /* vmsetimask arguments */
200e49ee290SRichard Kuo
201e49ee290SRichard Kuo #define VM_INT_UNMASK 0
202e49ee290SRichard Kuo #define VM_INT_MASK 1
203e49ee290SRichard Kuo
204e49ee290SRichard Kuo #define VM_NEWMAP_TYPE_LINEAR 0
205e49ee290SRichard Kuo #define VM_NEWMAP_TYPE_PGTABLES 1
206e49ee290SRichard Kuo
207e49ee290SRichard Kuo
208e49ee290SRichard Kuo /*
209e49ee290SRichard Kuo * Event Record definitions useful to both C and Assembler
210e49ee290SRichard Kuo */
211e49ee290SRichard Kuo
212e49ee290SRichard Kuo /* VMEST Layout */
213e49ee290SRichard Kuo
214e49ee290SRichard Kuo #define HVM_VMEST_UM_SFT 31
215e49ee290SRichard Kuo #define HVM_VMEST_UM_MSK 1
216e49ee290SRichard Kuo #define HVM_VMEST_IE_SFT 30
217e49ee290SRichard Kuo #define HVM_VMEST_IE_MSK 1
2188f5a0b9dSRichard Kuo #define HVM_VMEST_SS_SFT 29
2198f5a0b9dSRichard Kuo #define HVM_VMEST_SS_MSK 1
220e49ee290SRichard Kuo #define HVM_VMEST_EVENTNUM_SFT 16
221e49ee290SRichard Kuo #define HVM_VMEST_EVENTNUM_MSK 0xff
222e49ee290SRichard Kuo #define HVM_VMEST_CAUSE_SFT 0
223e49ee290SRichard Kuo #define HVM_VMEST_CAUSE_MSK 0xffff
224e49ee290SRichard Kuo
225e49ee290SRichard Kuo /*
226e49ee290SRichard Kuo * The initial program gets to find a system environment descriptor
227238034e3SAdam Buchbinder * on its stack when it begins execution. The first word is a version
228e49ee290SRichard Kuo * code to indicate what is there. Zero means nothing more.
229e49ee290SRichard Kuo */
230e49ee290SRichard Kuo
231e49ee290SRichard Kuo #define HEXAGON_VM_SED_NULL 0
232e49ee290SRichard Kuo
233e49ee290SRichard Kuo /*
234e49ee290SRichard Kuo * Event numbers for vector binding
235e49ee290SRichard Kuo */
236e49ee290SRichard Kuo
237e49ee290SRichard Kuo #define HVM_EV_RESET 0
238e49ee290SRichard Kuo #define HVM_EV_MACHCHECK 1
239e49ee290SRichard Kuo #define HVM_EV_GENEX 2
240e49ee290SRichard Kuo #define HVM_EV_TRAP 8
241e49ee290SRichard Kuo #define HVM_EV_INTR 15
242e49ee290SRichard Kuo /* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */
243e49ee290SRichard Kuo #define HVM_EV_INTR_0 16
244e49ee290SRichard Kuo #define HVM_MAX_INTR 240
245e49ee290SRichard Kuo
246e49ee290SRichard Kuo /*
247e49ee290SRichard Kuo * Cause values for General Exception
248e49ee290SRichard Kuo */
249e49ee290SRichard Kuo
250e49ee290SRichard Kuo #define HVM_GE_C_BUS 0x01
251e49ee290SRichard Kuo #define HVM_GE_C_XPROT 0x11
252e49ee290SRichard Kuo #define HVM_GE_C_XUSER 0x14
253e49ee290SRichard Kuo #define HVM_GE_C_INVI 0x15
254e49ee290SRichard Kuo #define HVM_GE_C_PRIVI 0x1B
255e49ee290SRichard Kuo #define HVM_GE_C_XMAL 0x1C
2568f5a0b9dSRichard Kuo #define HVM_GE_C_WREG 0x1D
2578f5a0b9dSRichard Kuo #define HVM_GE_C_PCAL 0x1E
258e49ee290SRichard Kuo #define HVM_GE_C_RMAL 0x20
259e49ee290SRichard Kuo #define HVM_GE_C_WMAL 0x21
260e49ee290SRichard Kuo #define HVM_GE_C_RPROT 0x22
261e49ee290SRichard Kuo #define HVM_GE_C_WPROT 0x23
262e49ee290SRichard Kuo #define HVM_GE_C_RUSER 0x24
263e49ee290SRichard Kuo #define HVM_GE_C_WUSER 0x25
264e49ee290SRichard Kuo #define HVM_GE_C_CACHE 0x28
265e49ee290SRichard Kuo
266e49ee290SRichard Kuo /*
267e49ee290SRichard Kuo * Cause codes for Machine Check
268e49ee290SRichard Kuo */
269e49ee290SRichard Kuo
270e49ee290SRichard Kuo #define HVM_MCHK_C_DOWN 0x00
271e49ee290SRichard Kuo #define HVM_MCHK_C_BADSP 0x01
272e49ee290SRichard Kuo #define HVM_MCHK_C_BADEX 0x02
273e49ee290SRichard Kuo #define HVM_MCHK_C_BADPT 0x03
274e49ee290SRichard Kuo #define HVM_MCHK_C_REGWR 0x29
275e49ee290SRichard Kuo
276e49ee290SRichard Kuo #endif
277