xref: /openbmc/linux/arch/hexagon/include/uapi/asm/registers.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
23ed8d115SDavid Howells /*
33ed8d115SDavid Howells  * Register definitions for the Hexagon architecture
43ed8d115SDavid Howells  */
53ed8d115SDavid Howells 
6e1858b2aSRichard Kuo 
73ed8d115SDavid Howells #ifndef _ASM_REGISTERS_H
83ed8d115SDavid Howells #define _ASM_REGISTERS_H
93ed8d115SDavid Howells 
103ed8d115SDavid Howells #ifndef __ASSEMBLY__
113ed8d115SDavid Howells 
123ed8d115SDavid Howells /*  See kernel/entry.S for further documentation.  */
133ed8d115SDavid Howells 
143ed8d115SDavid Howells /*
153ed8d115SDavid Howells  * Entry code copies the event record out of guest registers into
163ed8d115SDavid Howells  * this structure (which is on the stack).
173ed8d115SDavid Howells  */
183ed8d115SDavid Howells 
193ed8d115SDavid Howells struct hvm_event_record {
203ed8d115SDavid Howells 	unsigned long vmel;     /* Event Linkage (return address) */
213ed8d115SDavid Howells 	unsigned long vmest;    /* Event context - pre-event SSR values */
223ed8d115SDavid Howells 	unsigned long vmpsp;    /* Previous stack pointer */
233ed8d115SDavid Howells 	unsigned long vmbadva;  /* Bad virtual address for addressing events */
243ed8d115SDavid Howells };
253ed8d115SDavid Howells 
263ed8d115SDavid Howells struct pt_regs {
273ed8d115SDavid Howells 	long restart_r0;        /* R0 checkpoint for syscall restart */
283ed8d115SDavid Howells 	long syscall_nr;        /* Only used in system calls */
293ed8d115SDavid Howells 	union {
303ed8d115SDavid Howells 		struct {
313ed8d115SDavid Howells 			unsigned long usr;
323ed8d115SDavid Howells 			unsigned long preds;
333ed8d115SDavid Howells 		};
343ed8d115SDavid Howells 		long long int predsusr;
353ed8d115SDavid Howells 	};
363ed8d115SDavid Howells 	union {
373ed8d115SDavid Howells 		struct {
383ed8d115SDavid Howells 			unsigned long m0;
393ed8d115SDavid Howells 			unsigned long m1;
403ed8d115SDavid Howells 		};
413ed8d115SDavid Howells 		long long int m1m0;
423ed8d115SDavid Howells 	};
433ed8d115SDavid Howells 	union {
443ed8d115SDavid Howells 		struct {
453ed8d115SDavid Howells 			unsigned long sa1;
463ed8d115SDavid Howells 			unsigned long lc1;
473ed8d115SDavid Howells 		};
483ed8d115SDavid Howells 		long long int lc1sa1;
493ed8d115SDavid Howells 	};
503ed8d115SDavid Howells 	union {
513ed8d115SDavid Howells 		struct {
523ed8d115SDavid Howells 			unsigned long sa0;
533ed8d115SDavid Howells 			unsigned long lc0;
543ed8d115SDavid Howells 		};
553ed8d115SDavid Howells 		long long int lc0sa0;
563ed8d115SDavid Howells 	};
573ed8d115SDavid Howells 	union {
583ed8d115SDavid Howells 		struct {
593ed8d115SDavid Howells 			unsigned long ugp;
6060c4ba99SRichard Kuo 			unsigned long gp;
613ed8d115SDavid Howells 		};
6260c4ba99SRichard Kuo 		long long int gpugp;
6360c4ba99SRichard Kuo 	};
6460c4ba99SRichard Kuo 	union {
6560c4ba99SRichard Kuo 		struct {
6660c4ba99SRichard Kuo 			unsigned long cs0;
6760c4ba99SRichard Kuo 			unsigned long cs1;
6860c4ba99SRichard Kuo 		};
6960c4ba99SRichard Kuo 		long long int cs1cs0;
703ed8d115SDavid Howells 	};
713ed8d115SDavid Howells 	/*
723ed8d115SDavid Howells 	* Be extremely careful with rearranging these, if at all.  Some code
733ed8d115SDavid Howells 	* assumes the 32 registers exist exactly like this in memory;
743ed8d115SDavid Howells 	* e.g. kernel/ptrace.c
753ed8d115SDavid Howells 	* e.g. kernel/signal.c (restore_sigcontext)
763ed8d115SDavid Howells 	*/
773ed8d115SDavid Howells 	union {
783ed8d115SDavid Howells 		struct {
793ed8d115SDavid Howells 			unsigned long r00;
803ed8d115SDavid Howells 			unsigned long r01;
813ed8d115SDavid Howells 		};
823ed8d115SDavid Howells 		long long int r0100;
833ed8d115SDavid Howells 	};
843ed8d115SDavid Howells 	union {
853ed8d115SDavid Howells 		struct {
863ed8d115SDavid Howells 			unsigned long r02;
873ed8d115SDavid Howells 			unsigned long r03;
883ed8d115SDavid Howells 		};
893ed8d115SDavid Howells 		long long int r0302;
903ed8d115SDavid Howells 	};
913ed8d115SDavid Howells 	union {
923ed8d115SDavid Howells 		struct {
933ed8d115SDavid Howells 			unsigned long r04;
943ed8d115SDavid Howells 			unsigned long r05;
953ed8d115SDavid Howells 		};
963ed8d115SDavid Howells 		long long int r0504;
973ed8d115SDavid Howells 	};
983ed8d115SDavid Howells 	union {
993ed8d115SDavid Howells 		struct {
1003ed8d115SDavid Howells 			unsigned long r06;
1013ed8d115SDavid Howells 			unsigned long r07;
1023ed8d115SDavid Howells 		};
1033ed8d115SDavid Howells 		long long int r0706;
1043ed8d115SDavid Howells 	};
1053ed8d115SDavid Howells 	union {
1063ed8d115SDavid Howells 		struct {
1073ed8d115SDavid Howells 			unsigned long r08;
1083ed8d115SDavid Howells 			unsigned long r09;
1093ed8d115SDavid Howells 		};
1103ed8d115SDavid Howells 		long long int r0908;
1113ed8d115SDavid Howells 	};
1123ed8d115SDavid Howells 	union {
1133ed8d115SDavid Howells 	       struct {
1143ed8d115SDavid Howells 			unsigned long r10;
1153ed8d115SDavid Howells 			unsigned long r11;
1163ed8d115SDavid Howells 	       };
1173ed8d115SDavid Howells 	       long long int r1110;
1183ed8d115SDavid Howells 	};
1193ed8d115SDavid Howells 	union {
1203ed8d115SDavid Howells 	       struct {
1213ed8d115SDavid Howells 			unsigned long r12;
1223ed8d115SDavid Howells 			unsigned long r13;
1233ed8d115SDavid Howells 	       };
1243ed8d115SDavid Howells 	       long long int r1312;
1253ed8d115SDavid Howells 	};
1263ed8d115SDavid Howells 	union {
1273ed8d115SDavid Howells 	       struct {
1283ed8d115SDavid Howells 			unsigned long r14;
1293ed8d115SDavid Howells 			unsigned long r15;
1303ed8d115SDavid Howells 	       };
1313ed8d115SDavid Howells 	       long long int r1514;
1323ed8d115SDavid Howells 	};
1333ed8d115SDavid Howells 	union {
1343ed8d115SDavid Howells 		struct {
1353ed8d115SDavid Howells 			unsigned long r16;
1363ed8d115SDavid Howells 			unsigned long r17;
1373ed8d115SDavid Howells 		};
1383ed8d115SDavid Howells 		long long int r1716;
1393ed8d115SDavid Howells 	};
1403ed8d115SDavid Howells 	union {
1413ed8d115SDavid Howells 		struct {
1423ed8d115SDavid Howells 			unsigned long r18;
1433ed8d115SDavid Howells 			unsigned long r19;
1443ed8d115SDavid Howells 		};
1453ed8d115SDavid Howells 		long long int r1918;
1463ed8d115SDavid Howells 	};
1473ed8d115SDavid Howells 	union {
1483ed8d115SDavid Howells 		struct {
1493ed8d115SDavid Howells 			unsigned long r20;
1503ed8d115SDavid Howells 			unsigned long r21;
1513ed8d115SDavid Howells 		};
1523ed8d115SDavid Howells 		long long int r2120;
1533ed8d115SDavid Howells 	};
1543ed8d115SDavid Howells 	union {
1553ed8d115SDavid Howells 		struct {
1563ed8d115SDavid Howells 			unsigned long r22;
1573ed8d115SDavid Howells 			unsigned long r23;
1583ed8d115SDavid Howells 		};
1593ed8d115SDavid Howells 		long long int r2322;
1603ed8d115SDavid Howells 	};
1613ed8d115SDavid Howells 	union {
1623ed8d115SDavid Howells 		struct {
1633ed8d115SDavid Howells 			unsigned long r24;
1643ed8d115SDavid Howells 			unsigned long r25;
1653ed8d115SDavid Howells 		};
1663ed8d115SDavid Howells 		long long int r2524;
1673ed8d115SDavid Howells 	};
1683ed8d115SDavid Howells 	union {
1693ed8d115SDavid Howells 		struct {
1703ed8d115SDavid Howells 			unsigned long r26;
1713ed8d115SDavid Howells 			unsigned long r27;
1723ed8d115SDavid Howells 		};
1733ed8d115SDavid Howells 		long long int r2726;
1743ed8d115SDavid Howells 	};
1753ed8d115SDavid Howells 	union {
1763ed8d115SDavid Howells 		struct {
1773ed8d115SDavid Howells 			unsigned long r28;
1783ed8d115SDavid Howells 			unsigned long r29;
1793ed8d115SDavid Howells 	       };
1803ed8d115SDavid Howells 	       long long int r2928;
1813ed8d115SDavid Howells 	};
1823ed8d115SDavid Howells 	union {
1833ed8d115SDavid Howells 		struct {
1843ed8d115SDavid Howells 			unsigned long r30;
1853ed8d115SDavid Howells 			unsigned long r31;
1863ed8d115SDavid Howells 		};
1873ed8d115SDavid Howells 		long long int r3130;
1883ed8d115SDavid Howells 	};
1893ed8d115SDavid Howells 	/* VM dispatch pushes event record onto stack - we can build on it */
1903ed8d115SDavid Howells 	struct hvm_event_record hvmer;
1913ed8d115SDavid Howells };
1923ed8d115SDavid Howells 
1933ed8d115SDavid Howells /* Defines to conveniently access the values  */
1943ed8d115SDavid Howells 
1953ed8d115SDavid Howells /*
1963ed8d115SDavid Howells  * As of the VM spec 0.5, these registers are now set/retrieved via a
1973ed8d115SDavid Howells  * VM call.  On the in-bound side, we just fetch the values
1983ed8d115SDavid Howells  * at the entry points and stuff them into the old record in pt_regs.
1993ed8d115SDavid Howells  * However, on the outbound side, probably at VM rte, we set the
2003ed8d115SDavid Howells  * registers back.
2013ed8d115SDavid Howells  */
2023ed8d115SDavid Howells 
2033ed8d115SDavid Howells #define pt_elr(regs) ((regs)->hvmer.vmel)
2043ed8d115SDavid Howells #define pt_set_elr(regs, val) ((regs)->hvmer.vmel = (val))
2053ed8d115SDavid Howells #define pt_cause(regs) ((regs)->hvmer.vmest & (HVM_VMEST_CAUSE_MSK))
2063ed8d115SDavid Howells #define user_mode(regs) \
2073ed8d115SDavid Howells 	(((regs)->hvmer.vmest & (HVM_VMEST_UM_MSK << HVM_VMEST_UM_SFT)) != 0)
2083ed8d115SDavid Howells #define ints_enabled(regs) \
2093ed8d115SDavid Howells 	(((regs)->hvmer.vmest & (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)) != 0)
2103ed8d115SDavid Howells #define pt_psp(regs) ((regs)->hvmer.vmpsp)
2113ed8d115SDavid Howells #define pt_badva(regs) ((regs)->hvmer.vmbadva)
2123ed8d115SDavid Howells 
2137777746cSRichard Kuo #define pt_set_singlestep(regs) ((regs)->hvmer.vmest |= (1<<HVM_VMEST_SS_SFT))
2147777746cSRichard Kuo #define pt_clr_singlestep(regs) ((regs)->hvmer.vmest &= ~(1<<HVM_VMEST_SS_SFT))
2157777746cSRichard Kuo 
2163ed8d115SDavid Howells #define pt_set_rte_sp(regs, sp) do {\
21793f9d110SRichard Kuo 	pt_psp(regs) = (regs)->r29 = (sp);\
2183ed8d115SDavid Howells 	} while (0)
2193ed8d115SDavid Howells 
2203ed8d115SDavid Howells #define pt_set_kmode(regs) \
2213ed8d115SDavid Howells 	(regs)->hvmer.vmest = (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)
2223ed8d115SDavid Howells 
2233ed8d115SDavid Howells #define pt_set_usermode(regs) \
2243ed8d115SDavid Howells 	(regs)->hvmer.vmest = (HVM_VMEST_UM_MSK << HVM_VMEST_UM_SFT) \
2253ed8d115SDavid Howells 			    | (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)
2263ed8d115SDavid Howells 
2273ed8d115SDavid Howells #endif  /*  ifndef __ASSEMBLY  */
2283ed8d115SDavid Howells 
2293ed8d115SDavid Howells #endif
230