18c2ecf20Sopenharmony_ci; SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci;
38c2ecf20Sopenharmony_ci;  Port on Texas Instruments TMS320C6x architecture
48c2ecf20Sopenharmony_ci;
58c2ecf20Sopenharmony_ci;  Copyright (C) 2004-2011 Texas Instruments Incorporated
68c2ecf20Sopenharmony_ci;  Author: Aurelien Jacquiot (aurelien.jacquiot@virtuallogix.com)
78c2ecf20Sopenharmony_ci;  Updated for 2.6.34: Mark Salter <msalter@redhat.com>
88c2ecf20Sopenharmony_ci;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/sys.h>
118c2ecf20Sopenharmony_ci#include <linux/linkage.h>
128c2ecf20Sopenharmony_ci#include <asm/thread_info.h>
138c2ecf20Sopenharmony_ci#include <asm/asm-offsets.h>
148c2ecf20Sopenharmony_ci#include <asm/unistd.h>
158c2ecf20Sopenharmony_ci#include <asm/errno.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci; Registers naming
188c2ecf20Sopenharmony_ci#define DP	B14
198c2ecf20Sopenharmony_ci#define SP	B15
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef CONFIG_PREEMPTION
228c2ecf20Sopenharmony_ci#define resume_kernel restore_all
238c2ecf20Sopenharmony_ci#endif
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	.altmacro
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	.macro MASK_INT reg
288c2ecf20Sopenharmony_ci	MVC	.S2	CSR,reg
298c2ecf20Sopenharmony_ci	CLR	.S2	reg,0,0,reg
308c2ecf20Sopenharmony_ci	MVC	.S2	reg,CSR
318c2ecf20Sopenharmony_ci	.endm
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	.macro UNMASK_INT reg
348c2ecf20Sopenharmony_ci	MVC	.S2	CSR,reg
358c2ecf20Sopenharmony_ci	SET	.S2	reg,0,0,reg
368c2ecf20Sopenharmony_ci	MVC	.S2	reg,CSR
378c2ecf20Sopenharmony_ci	.endm
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	.macro GET_THREAD_INFO reg
408c2ecf20Sopenharmony_ci	SHR	.S1X	SP,THREAD_SHIFT,reg
418c2ecf20Sopenharmony_ci	SHL	.S1	reg,THREAD_SHIFT,reg
428c2ecf20Sopenharmony_ci	.endm
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	;;
458c2ecf20Sopenharmony_ci	;;  This defines the normal kernel pt_regs layout.
468c2ecf20Sopenharmony_ci	;;
478c2ecf20Sopenharmony_ci	.macro SAVE_ALL __rp __tsr
488c2ecf20Sopenharmony_ci	STW	.D2T2	B0,*SP--[2]		; save original B0
498c2ecf20Sopenharmony_ci	MVKL	.S2	current_ksp,B0
508c2ecf20Sopenharmony_ci	MVKH	.S2	current_ksp,B0
518c2ecf20Sopenharmony_ci	LDW	.D2T2	*B0,B1			; KSP
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	NOP	3
548c2ecf20Sopenharmony_ci	STW	.D2T2	B1,*+SP[1]		; save original B1
558c2ecf20Sopenharmony_ci	XOR	.D2	SP,B1,B0		; (SP ^ KSP)
568c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP[1],B1		; restore B0/B1
578c2ecf20Sopenharmony_ci	LDW	.D2T2	*++SP[2],B0
588c2ecf20Sopenharmony_ci	SHR	.S2	B0,THREAD_SHIFT,B0	; 0 if already using kstack
598c2ecf20Sopenharmony_ci  [B0]	STDW	.D2T2	SP:DP,*--B1[1]		; user: save user sp/dp kstack
608c2ecf20Sopenharmony_ci  [B0]	MV	.S2	B1,SP			;    and switch to kstack
618c2ecf20Sopenharmony_ci||[!B0] STDW	.D2T2	SP:DP,*--SP[1]		; kernel: save on current stack
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	SUBAW	.D2	SP,2,SP
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	ADD	.D1X	SP,-8,A15
668c2ecf20Sopenharmony_ci ||	STDW	.D2T1	A15:A14,*SP--[16]	; save A15:A14
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	STDW	.D2T2	B13:B12,*SP--[1]
698c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A13:A12,*A15--[1]
708c2ecf20Sopenharmony_ci ||	MVC	.S2	__rp,B13
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	STDW	.D2T2	B11:B10,*SP--[1]
738c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A11:A10,*A15--[1]
748c2ecf20Sopenharmony_ci ||	MVC	.S2	CSR,B12
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	STDW	.D2T2	B9:B8,*SP--[1]
778c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A9:A8,*A15--[1]
788c2ecf20Sopenharmony_ci ||	MVC	.S2	RILC,B11
798c2ecf20Sopenharmony_ci	STDW	.D2T2	B7:B6,*SP--[1]
808c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A7:A6,*A15--[1]
818c2ecf20Sopenharmony_ci ||	MVC	.S2	ILC,B10
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	STDW	.D2T2	B5:B4,*SP--[1]
848c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A5:A4,*A15--[1]
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	STDW	.D2T2	B3:B2,*SP--[1]
878c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A3:A2,*A15--[1]
888c2ecf20Sopenharmony_ci ||	MVC	.S2	__tsr,B5
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	STDW	.D2T2	B1:B0,*SP--[1]
918c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A1:A0,*A15--[1]
928c2ecf20Sopenharmony_ci ||	MV	.S1X	B5,A5
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	STDW	.D2T2	B31:B30,*SP--[1]
958c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A31:A30,*A15--[1]
968c2ecf20Sopenharmony_ci	STDW	.D2T2	B29:B28,*SP--[1]
978c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A29:A28,*A15--[1]
988c2ecf20Sopenharmony_ci	STDW	.D2T2	B27:B26,*SP--[1]
998c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A27:A26,*A15--[1]
1008c2ecf20Sopenharmony_ci	STDW	.D2T2	B25:B24,*SP--[1]
1018c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A25:A24,*A15--[1]
1028c2ecf20Sopenharmony_ci	STDW	.D2T2	B23:B22,*SP--[1]
1038c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A23:A22,*A15--[1]
1048c2ecf20Sopenharmony_ci	STDW	.D2T2	B21:B20,*SP--[1]
1058c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A21:A20,*A15--[1]
1068c2ecf20Sopenharmony_ci	STDW	.D2T2	B19:B18,*SP--[1]
1078c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A19:A18,*A15--[1]
1088c2ecf20Sopenharmony_ci	STDW	.D2T2	B17:B16,*SP--[1]
1098c2ecf20Sopenharmony_ci ||	STDW	.D1T1	A17:A16,*A15--[1]
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	STDW	.D2T2	B13:B12,*SP--[1]	; save PC and CSR
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	STDW	.D2T2	B11:B10,*SP--[1]	; save RILC and ILC
1148c2ecf20Sopenharmony_ci	STDW	.D2T1	A5:A4,*SP--[1]		; save TSR and orig A4
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	;; We left an unused word on the stack just above pt_regs.
1178c2ecf20Sopenharmony_ci	;; It is used to save whether or not this frame is due to
1188c2ecf20Sopenharmony_ci	;; a syscall. It is cleared here, but the syscall handler
1198c2ecf20Sopenharmony_ci	;; sets it to a non-zero value.
1208c2ecf20Sopenharmony_ci	MVK	.L2	0,B1
1218c2ecf20Sopenharmony_ci	STW	.D2T2	B1,*+SP(REGS__END+8)	; clear syscall flag
1228c2ecf20Sopenharmony_ci	.endm
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	.macro RESTORE_ALL __rp __tsr
1258c2ecf20Sopenharmony_ci	LDDW	.D2T2	*++SP[1],B9:B8		; get TSR (B9)
1268c2ecf20Sopenharmony_ci	LDDW	.D2T2	*++SP[1],B11:B10	; get RILC (B11) and ILC (B10)
1278c2ecf20Sopenharmony_ci	LDDW	.D2T2	*++SP[1],B13:B12	; get PC (B13) and CSR (B12)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	ADDAW	.D1X	SP,30,A15
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A17:A16
1328c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B17:B16
1338c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A19:A18
1348c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B19:B18
1358c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A21:A20
1368c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B21:B20
1378c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A23:A22
1388c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B23:B22
1398c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A25:A24
1408c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B25:B24
1418c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A27:A26
1428c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B27:B26
1438c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A29:A28
1448c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B29:B28
1458c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A31:A30
1468c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B31:B30
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A1:A0
1498c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B1:B0
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A3:A2
1528c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B3:B2
1538c2ecf20Sopenharmony_ci ||	MVC	.S2	B9,__tsr
1548c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A5:A4
1558c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B5:B4
1568c2ecf20Sopenharmony_ci ||	MVC	.S2	B11,RILC
1578c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A7:A6
1588c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B7:B6
1598c2ecf20Sopenharmony_ci ||	MVC	.S2	B10,ILC
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A9:A8
1628c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B9:B8
1638c2ecf20Sopenharmony_ci ||	MVC	.S2	B13,__rp
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A11:A10
1668c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B11:B10
1678c2ecf20Sopenharmony_ci ||	MVC	.S2	B12,CSR
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	LDDW	.D1T1	*++A15[1],A13:A12
1708c2ecf20Sopenharmony_ci ||	LDDW	.D2T2	*++SP[1],B13:B12
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	MV	.D2X	A15,SP
1738c2ecf20Sopenharmony_ci ||	MVKL	.S1	current_ksp,A15
1748c2ecf20Sopenharmony_ci	MVKH	.S1	current_ksp,A15
1758c2ecf20Sopenharmony_ci ||	ADDAW	.D1X	SP,6,A14
1768c2ecf20Sopenharmony_ci	STW	.D1T1	A14,*A15	; save kernel stack pointer
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	LDDW	.D2T1	*++SP[1],A15:A14
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	B	.S2	__rp		; return from interruption
1818c2ecf20Sopenharmony_ci	LDDW	.D2T2	*+SP[1],SP:DP
1828c2ecf20Sopenharmony_ci	NOP	4
1838c2ecf20Sopenharmony_ci	.endm
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	.section .text
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	;;
1888c2ecf20Sopenharmony_ci	;; Jump to schedule() then return to ret_from_exception
1898c2ecf20Sopenharmony_ci	;;
1908c2ecf20Sopenharmony_ci_reschedule:
1918c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
1928c2ecf20Sopenharmony_ci	MVKL	.S1	schedule,A0
1938c2ecf20Sopenharmony_ci	MVKH	.S1	schedule,A0
1948c2ecf20Sopenharmony_ci	B	.S2X	A0
1958c2ecf20Sopenharmony_ci#else
1968c2ecf20Sopenharmony_ci	B	.S1	schedule
1978c2ecf20Sopenharmony_ci#endif
1988c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_exception,B3,4
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	;;
2018c2ecf20Sopenharmony_ci	;; Called before syscall handler when process is being debugged
2028c2ecf20Sopenharmony_ci	;;
2038c2ecf20Sopenharmony_citracesys_on:
2048c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
2058c2ecf20Sopenharmony_ci	MVKL	.S1	syscall_trace_entry,A0
2068c2ecf20Sopenharmony_ci	MVKH	.S1	syscall_trace_entry,A0
2078c2ecf20Sopenharmony_ci	B	.S2X	A0
2088c2ecf20Sopenharmony_ci#else
2098c2ecf20Sopenharmony_ci	B	.S1	syscall_trace_entry
2108c2ecf20Sopenharmony_ci#endif
2118c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_syscall_trace,B3,3
2128c2ecf20Sopenharmony_ci	ADD	.S1X	8,SP,A4
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ciret_from_syscall_trace:
2158c2ecf20Sopenharmony_ci	;; tracing returns (possibly new) syscall number
2168c2ecf20Sopenharmony_ci	MV	.D2X	A4,B0
2178c2ecf20Sopenharmony_ci ||	MVK	.S2	__NR_syscalls,B1
2188c2ecf20Sopenharmony_ci	CMPLTU	.L2	B0,B1,B1
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci [!B1]	BNOP	.S2	ret_from_syscall_function,5
2218c2ecf20Sopenharmony_ci ||	MVK	.S1	-ENOSYS,A4
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci	;; reload syscall args from (possibly modified) stack frame
2248c2ecf20Sopenharmony_ci	;; and get syscall handler addr from sys_call_table:
2258c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B4+8),B4
2268c2ecf20Sopenharmony_ci ||	MVKL	.S2	sys_call_table,B1
2278c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A6+8),A6
2288c2ecf20Sopenharmony_ci ||	MVKH	.S2	sys_call_table,B1
2298c2ecf20Sopenharmony_ci	LDW	.D2T2	*+B1[B0],B0
2308c2ecf20Sopenharmony_ci ||	MVKL	.S2	ret_from_syscall_function,B3
2318c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B6+8),B6
2328c2ecf20Sopenharmony_ci ||	MVKH	.S2	ret_from_syscall_function,B3
2338c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A8+8),A8
2348c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B8+8),B8
2358c2ecf20Sopenharmony_ci	NOP
2368c2ecf20Sopenharmony_ci	; B0 = sys_call_table[__NR_*]
2378c2ecf20Sopenharmony_ci	BNOP	.S2	B0,5			; branch to syscall handler
2388c2ecf20Sopenharmony_ci ||	LDW	.D2T1	*+SP(REGS_ORIG_A4+8),A4
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_cisyscall_exit_work:
2418c2ecf20Sopenharmony_ci	AND	.D1	_TIF_SYSCALL_TRACE,A2,A0
2428c2ecf20Sopenharmony_ci [!A0]	BNOP	.S1	work_pending,5
2438c2ecf20Sopenharmony_ci [A0]	B	.S2	syscall_trace_exit
2448c2ecf20Sopenharmony_ci	ADDKPC	.S2	resume_userspace,B3,1
2458c2ecf20Sopenharmony_ci	MVC	.S2	CSR,B1
2468c2ecf20Sopenharmony_ci	SET	.S2	B1,0,0,B1
2478c2ecf20Sopenharmony_ci	MVC	.S2	B1,CSR		; enable ints
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ciwork_pending:
2508c2ecf20Sopenharmony_ci	AND	.D1	_TIF_NEED_RESCHED,A2,A0
2518c2ecf20Sopenharmony_ci [!A0]	BNOP	.S1	work_notifysig,5
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ciwork_resched:
2548c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
2558c2ecf20Sopenharmony_ci	MVKL	.S1	schedule,A1
2568c2ecf20Sopenharmony_ci	MVKH	.S1	schedule,A1
2578c2ecf20Sopenharmony_ci	B	.S2X	A1
2588c2ecf20Sopenharmony_ci#else
2598c2ecf20Sopenharmony_ci	B	.S2	schedule
2608c2ecf20Sopenharmony_ci#endif
2618c2ecf20Sopenharmony_ci	ADDKPC	.S2	work_rescheduled,B3,4
2628c2ecf20Sopenharmony_ciwork_rescheduled:
2638c2ecf20Sopenharmony_ci	;; make sure we don't miss an interrupt setting need_resched or
2648c2ecf20Sopenharmony_ci	;; sigpending between sampling and the rti
2658c2ecf20Sopenharmony_ci	MASK_INT B2
2668c2ecf20Sopenharmony_ci	GET_THREAD_INFO A12
2678c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A12(THREAD_INFO_FLAGS),A2
2688c2ecf20Sopenharmony_ci	MVK	.S1	_TIF_WORK_MASK,A1
2698c2ecf20Sopenharmony_ci	MVK	.S1	_TIF_NEED_RESCHED,A3
2708c2ecf20Sopenharmony_ci	NOP	2
2718c2ecf20Sopenharmony_ci	AND	.D1	A1,A2,A0
2728c2ecf20Sopenharmony_ci ||	AND	.S1	A3,A2,A1
2738c2ecf20Sopenharmony_ci [!A0]	BNOP	.S1	restore_all,5
2748c2ecf20Sopenharmony_ci [A1]	BNOP	.S1	work_resched,5
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ciwork_notifysig:
2778c2ecf20Sopenharmony_ci	;; enable interrupts for do_notify_resume()
2788c2ecf20Sopenharmony_ci	UNMASK_INT B2
2798c2ecf20Sopenharmony_ci	B	.S2	do_notify_resume
2808c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS__END+8),A6 ; syscall flag
2818c2ecf20Sopenharmony_ci	ADDKPC	.S2	resume_userspace,B3,1
2828c2ecf20Sopenharmony_ci	ADD	.S1X	8,SP,A4		; pt_regs pointer is first arg
2838c2ecf20Sopenharmony_ci	MV	.D2X	A2,B4		; thread_info flags is second arg
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	;;
2868c2ecf20Sopenharmony_ci	;; On C64x+, the return way from exception and interrupt
2878c2ecf20Sopenharmony_ci	;; is a little bit different
2888c2ecf20Sopenharmony_ci	;;
2898c2ecf20Sopenharmony_ciENTRY(ret_from_exception)
2908c2ecf20Sopenharmony_ci#ifdef CONFIG_PREEMPTION
2918c2ecf20Sopenharmony_ci	MASK_INT B2
2928c2ecf20Sopenharmony_ci#endif
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ciENTRY(ret_from_interrupt)
2958c2ecf20Sopenharmony_ci	;;
2968c2ecf20Sopenharmony_ci	;; Check if we are comming from user mode.
2978c2ecf20Sopenharmony_ci	;;
2988c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_TSR+8),B0
2998c2ecf20Sopenharmony_ci	MVK	.S2	0x40,B1
3008c2ecf20Sopenharmony_ci	NOP	3
3018c2ecf20Sopenharmony_ci	AND	.D2	B0,B1,B0
3028c2ecf20Sopenharmony_ci [!B0]	BNOP	.S2	resume_kernel,5
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ciresume_userspace:
3058c2ecf20Sopenharmony_ci	;; make sure we don't miss an interrupt setting need_resched or
3068c2ecf20Sopenharmony_ci	;; sigpending between sampling and the rti
3078c2ecf20Sopenharmony_ci	MASK_INT B2
3088c2ecf20Sopenharmony_ci	GET_THREAD_INFO A12
3098c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A12(THREAD_INFO_FLAGS),A2
3108c2ecf20Sopenharmony_ci	MVK	.S1	_TIF_WORK_MASK,A1
3118c2ecf20Sopenharmony_ci	MVK	.S1	_TIF_NEED_RESCHED,A3
3128c2ecf20Sopenharmony_ci	NOP	2
3138c2ecf20Sopenharmony_ci	AND	.D1	A1,A2,A0
3148c2ecf20Sopenharmony_ci [A0]	BNOP	.S1	work_pending,5
3158c2ecf20Sopenharmony_ci	BNOP	.S1	restore_all,5
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	;;
3188c2ecf20Sopenharmony_ci	;; System call handling
3198c2ecf20Sopenharmony_ci	;; B0 = syscall number (in sys_call_table)
3208c2ecf20Sopenharmony_ci	;; A4,B4,A6,B6,A8,B8 = arguments of the syscall function
3218c2ecf20Sopenharmony_ci	;; A4 is the return value register
3228c2ecf20Sopenharmony_ci	;;
3238c2ecf20Sopenharmony_cisystem_call_saved:
3248c2ecf20Sopenharmony_ci	MVK	.L2	1,B2
3258c2ecf20Sopenharmony_ci	STW	.D2T2	B2,*+SP(REGS__END+8)	; set syscall flag
3268c2ecf20Sopenharmony_ci	MVC	.S2	B2,ECR			; ack the software exception
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	UNMASK_INT B2			; re-enable global IT
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_cisystem_call_saved_noack:
3318c2ecf20Sopenharmony_ci	;; Check system call number
3328c2ecf20Sopenharmony_ci	MVK	.S2	__NR_syscalls,B1
3338c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
3348c2ecf20Sopenharmony_ci ||	MVKL	.S1	sys_ni_syscall,A0
3358c2ecf20Sopenharmony_ci#endif
3368c2ecf20Sopenharmony_ci	CMPLTU	.L2	B0,B1,B1
3378c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
3388c2ecf20Sopenharmony_ci ||	MVKH	.S1	sys_ni_syscall,A0
3398c2ecf20Sopenharmony_ci#endif
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	;; Check for ptrace
3428c2ecf20Sopenharmony_ci	GET_THREAD_INFO A12
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
3458c2ecf20Sopenharmony_ci [!B1]	B	.S2X	A0
3468c2ecf20Sopenharmony_ci#else
3478c2ecf20Sopenharmony_ci [!B1]	B	.S2	sys_ni_syscall
3488c2ecf20Sopenharmony_ci#endif
3498c2ecf20Sopenharmony_ci [!B1]	ADDKPC	.S2	ret_from_syscall_function,B3,4
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	;; Get syscall handler addr from sys_call_table
3528c2ecf20Sopenharmony_ci	;; call tracesys_on or call syscall handler
3538c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A12(THREAD_INFO_FLAGS),A2
3548c2ecf20Sopenharmony_ci ||	MVKL	.S2	sys_call_table,B1
3558c2ecf20Sopenharmony_ci	MVKH	.S2	sys_call_table,B1
3568c2ecf20Sopenharmony_ci	LDW	.D2T2	*+B1[B0],B0
3578c2ecf20Sopenharmony_ci	NOP	2
3588c2ecf20Sopenharmony_ci	; A2 = thread_info flags
3598c2ecf20Sopenharmony_ci	AND	.D1	_TIF_SYSCALL_TRACE,A2,A2
3608c2ecf20Sopenharmony_ci [A2]	BNOP	.S1	tracesys_on,5
3618c2ecf20Sopenharmony_ci	;; B0 = _sys_call_table[__NR_*]
3628c2ecf20Sopenharmony_ci	B	.S2	B0
3638c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_syscall_function,B3,4
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ciret_from_syscall_function:
3668c2ecf20Sopenharmony_ci	STW	.D2T1	A4,*+SP(REGS_A4+8)	; save return value in A4
3678c2ecf20Sopenharmony_ci						; original A4 is in orig_A4
3688c2ecf20Sopenharmony_cisyscall_exit:
3698c2ecf20Sopenharmony_ci	;; make sure we don't miss an interrupt setting need_resched or
3708c2ecf20Sopenharmony_ci	;; sigpending between sampling and the rti
3718c2ecf20Sopenharmony_ci	MASK_INT B2
3728c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A12(THREAD_INFO_FLAGS),A2
3738c2ecf20Sopenharmony_ci	MVK	.S1	_TIF_ALLWORK_MASK,A1
3748c2ecf20Sopenharmony_ci	NOP	3
3758c2ecf20Sopenharmony_ci	AND	.D1	A1,A2,A2 ; check for work to do
3768c2ecf20Sopenharmony_ci [A2]	BNOP	.S1	syscall_exit_work,5
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cirestore_all:
3798c2ecf20Sopenharmony_ci	RESTORE_ALL NRP,NTSR
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci	;;
3828c2ecf20Sopenharmony_ci	;; After a fork we jump here directly from resume,
3838c2ecf20Sopenharmony_ci	;; so that A4 contains the previous task structure.
3848c2ecf20Sopenharmony_ci	;;
3858c2ecf20Sopenharmony_ciENTRY(ret_from_fork)
3868c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
3878c2ecf20Sopenharmony_ci	MVKL	.S1	schedule_tail,A0
3888c2ecf20Sopenharmony_ci	MVKH	.S1	schedule_tail,A0
3898c2ecf20Sopenharmony_ci	B	.S2X	A0
3908c2ecf20Sopenharmony_ci#else
3918c2ecf20Sopenharmony_ci	B	.S2	schedule_tail
3928c2ecf20Sopenharmony_ci#endif
3938c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_fork_2,B3,4
3948c2ecf20Sopenharmony_ciret_from_fork_2:
3958c2ecf20Sopenharmony_ci	;; return 0 in A4 for child process
3968c2ecf20Sopenharmony_ci	GET_THREAD_INFO A12
3978c2ecf20Sopenharmony_ci	BNOP	.S2	syscall_exit,3
3988c2ecf20Sopenharmony_ci	MVK	.L2	0,B0
3998c2ecf20Sopenharmony_ci	STW	.D2T2	B0,*+SP(REGS_A4+8)
4008c2ecf20Sopenharmony_ciENDPROC(ret_from_fork)
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ciENTRY(ret_from_kernel_thread)
4038c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
4048c2ecf20Sopenharmony_ci	MVKL	.S1	schedule_tail,A0
4058c2ecf20Sopenharmony_ci	MVKH	.S1	schedule_tail,A0
4068c2ecf20Sopenharmony_ci	B	.S2X	A0
4078c2ecf20Sopenharmony_ci#else
4088c2ecf20Sopenharmony_ci	B	.S2	schedule_tail
4098c2ecf20Sopenharmony_ci#endif
4108c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_A0+8),B10 /* get fn  */
4118c2ecf20Sopenharmony_ci	ADDKPC	.S2	0f,B3,3
4128c2ecf20Sopenharmony_ci0:
4138c2ecf20Sopenharmony_ci	B	.S2	B10		   /* call fn */
4148c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A1+8),A4 /* get arg */
4158c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_fork_2,B3,3
4168c2ecf20Sopenharmony_ciENDPROC(ret_from_kernel_thread)
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci	;;
4198c2ecf20Sopenharmony_ci	;; These are the interrupt handlers, responsible for calling c6x_do_IRQ()
4208c2ecf20Sopenharmony_ci	;;
4218c2ecf20Sopenharmony_ci	.macro SAVE_ALL_INT
4228c2ecf20Sopenharmony_ci	SAVE_ALL IRP,ITSR
4238c2ecf20Sopenharmony_ci	.endm
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	.macro CALL_INT int
4268c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
4278c2ecf20Sopenharmony_ci	MVKL	.S1	c6x_do_IRQ,A0
4288c2ecf20Sopenharmony_ci	MVKH	.S1	c6x_do_IRQ,A0
4298c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,1
4308c2ecf20Sopenharmony_ci	MVK	.S1	int,A4
4318c2ecf20Sopenharmony_ci	ADDAW	.D2	SP,2,B4
4328c2ecf20Sopenharmony_ci	MVKL	.S2	ret_from_interrupt,B3
4338c2ecf20Sopenharmony_ci	MVKH	.S2	ret_from_interrupt,B3
4348c2ecf20Sopenharmony_ci#else
4358c2ecf20Sopenharmony_ci	CALLP   .S2	c6x_do_IRQ,B3
4368c2ecf20Sopenharmony_ci ||	MVK	.S1	int,A4
4378c2ecf20Sopenharmony_ci ||	ADDAW	.D2	SP,2,B4
4388c2ecf20Sopenharmony_ci	B	.S1	ret_from_interrupt
4398c2ecf20Sopenharmony_ci	NOP	5
4408c2ecf20Sopenharmony_ci#endif
4418c2ecf20Sopenharmony_ci	.endm
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ciENTRY(_int4_handler)
4448c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4458c2ecf20Sopenharmony_ci	CALL_INT 4
4468c2ecf20Sopenharmony_ciENDPROC(_int4_handler)
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ciENTRY(_int5_handler)
4498c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4508c2ecf20Sopenharmony_ci	CALL_INT 5
4518c2ecf20Sopenharmony_ciENDPROC(_int5_handler)
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ciENTRY(_int6_handler)
4548c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4558c2ecf20Sopenharmony_ci	CALL_INT 6
4568c2ecf20Sopenharmony_ciENDPROC(_int6_handler)
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ciENTRY(_int7_handler)
4598c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4608c2ecf20Sopenharmony_ci	CALL_INT 7
4618c2ecf20Sopenharmony_ciENDPROC(_int7_handler)
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ciENTRY(_int8_handler)
4648c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4658c2ecf20Sopenharmony_ci	CALL_INT 8
4668c2ecf20Sopenharmony_ciENDPROC(_int8_handler)
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ciENTRY(_int9_handler)
4698c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4708c2ecf20Sopenharmony_ci	CALL_INT 9
4718c2ecf20Sopenharmony_ciENDPROC(_int9_handler)
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ciENTRY(_int10_handler)
4748c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4758c2ecf20Sopenharmony_ci	CALL_INT 10
4768c2ecf20Sopenharmony_ciENDPROC(_int10_handler)
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ciENTRY(_int11_handler)
4798c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4808c2ecf20Sopenharmony_ci	CALL_INT 11
4818c2ecf20Sopenharmony_ciENDPROC(_int11_handler)
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ciENTRY(_int12_handler)
4848c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4858c2ecf20Sopenharmony_ci	CALL_INT 12
4868c2ecf20Sopenharmony_ciENDPROC(_int12_handler)
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ciENTRY(_int13_handler)
4898c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4908c2ecf20Sopenharmony_ci	CALL_INT 13
4918c2ecf20Sopenharmony_ciENDPROC(_int13_handler)
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ciENTRY(_int14_handler)
4948c2ecf20Sopenharmony_ci	SAVE_ALL_INT
4958c2ecf20Sopenharmony_ci	CALL_INT 14
4968c2ecf20Sopenharmony_ciENDPROC(_int14_handler)
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ciENTRY(_int15_handler)
4998c2ecf20Sopenharmony_ci	SAVE_ALL_INT
5008c2ecf20Sopenharmony_ci	CALL_INT 15
5018c2ecf20Sopenharmony_ciENDPROC(_int15_handler)
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	;;
5048c2ecf20Sopenharmony_ci	;; Handler for uninitialized and spurious interrupts
5058c2ecf20Sopenharmony_ci	;;
5068c2ecf20Sopenharmony_ciENTRY(_bad_interrupt)
5078c2ecf20Sopenharmony_ci	B	.S2	IRP
5088c2ecf20Sopenharmony_ci	NOP	5
5098c2ecf20Sopenharmony_ciENDPROC(_bad_interrupt)
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci	;;
5128c2ecf20Sopenharmony_ci	;; Entry for NMI/exceptions/syscall
5138c2ecf20Sopenharmony_ci	;;
5148c2ecf20Sopenharmony_ciENTRY(_nmi_handler)
5158c2ecf20Sopenharmony_ci	SAVE_ALL NRP,NTSR
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	MVC	.S2	EFR,B2
5188c2ecf20Sopenharmony_ci	CMPEQ	.L2	1,B2,B2
5198c2ecf20Sopenharmony_ci ||	MVC	.S2	TSR,B1
5208c2ecf20Sopenharmony_ci	CLR	.S2	B1,10,10,B1
5218c2ecf20Sopenharmony_ci	MVC	.S2	B1,TSR
5228c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
5238c2ecf20Sopenharmony_ci [!B2]	MVKL	.S1	process_exception,A0
5248c2ecf20Sopenharmony_ci [!B2]	MVKH	.S1	process_exception,A0
5258c2ecf20Sopenharmony_ci [!B2]	B	.S2X	A0
5268c2ecf20Sopenharmony_ci#else
5278c2ecf20Sopenharmony_ci [!B2]	B	.S2	process_exception
5288c2ecf20Sopenharmony_ci#endif
5298c2ecf20Sopenharmony_ci [B2]	B	.S2	system_call_saved
5308c2ecf20Sopenharmony_ci [!B2]	ADDAW	.D2	SP,2,B1
5318c2ecf20Sopenharmony_ci [!B2]	MV	.D1X	B1,A4
5328c2ecf20Sopenharmony_ci	ADDKPC	.S2	ret_from_trap,B3,2
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_ciret_from_trap:
5358c2ecf20Sopenharmony_ci	MV	.D2X	A4,B0
5368c2ecf20Sopenharmony_ci [!B0]	BNOP	.S2	ret_from_exception,5
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
5398c2ecf20Sopenharmony_ci	MVKL	.S2	system_call_saved_noack,B3
5408c2ecf20Sopenharmony_ci	MVKH	.S2	system_call_saved_noack,B3
5418c2ecf20Sopenharmony_ci#endif
5428c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B0+8),B0
5438c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A4+8),A4
5448c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B4+8),B4
5458c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A6+8),A6
5468c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B6+8),B6
5478c2ecf20Sopenharmony_ci	LDW	.D2T1	*+SP(REGS_A8+8),A8
5488c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
5498c2ecf20Sopenharmony_ci ||	B	.S2	B3
5508c2ecf20Sopenharmony_ci#else
5518c2ecf20Sopenharmony_ci ||	B	.S2	system_call_saved_noack
5528c2ecf20Sopenharmony_ci#endif
5538c2ecf20Sopenharmony_ci	LDW	.D2T2	*+SP(REGS_B8+8),B8
5548c2ecf20Sopenharmony_ci	NOP	4
5558c2ecf20Sopenharmony_ciENDPROC(_nmi_handler)
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	;;
5588c2ecf20Sopenharmony_ci	;; Jump to schedule() then return to ret_from_isr
5598c2ecf20Sopenharmony_ci	;;
5608c2ecf20Sopenharmony_ci#ifdef	CONFIG_PREEMPTION
5618c2ecf20Sopenharmony_ciresume_kernel:
5628c2ecf20Sopenharmony_ci	GET_THREAD_INFO A12
5638c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A12(THREAD_INFO_PREEMPT_COUNT),A1
5648c2ecf20Sopenharmony_ci	NOP	4
5658c2ecf20Sopenharmony_ci [A1]	BNOP	.S2	restore_all,5
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cipreempt_schedule:
5688c2ecf20Sopenharmony_ci	GET_THREAD_INFO A2
5698c2ecf20Sopenharmony_ci	LDW	.D1T1	*+A2(THREAD_INFO_FLAGS),A1
5708c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
5718c2ecf20Sopenharmony_ci	MVKL	.S2	preempt_schedule_irq,B0
5728c2ecf20Sopenharmony_ci	MVKH	.S2	preempt_schedule_irq,B0
5738c2ecf20Sopenharmony_ci	NOP	2
5748c2ecf20Sopenharmony_ci#else
5758c2ecf20Sopenharmony_ci	NOP	4
5768c2ecf20Sopenharmony_ci#endif
5778c2ecf20Sopenharmony_ci	AND	.D1	_TIF_NEED_RESCHED,A1,A1
5788c2ecf20Sopenharmony_ci [!A1]	BNOP	.S2	restore_all,5
5798c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
5808c2ecf20Sopenharmony_ci	B	.S2	B0
5818c2ecf20Sopenharmony_ci#else
5828c2ecf20Sopenharmony_ci	B	.S2	preempt_schedule_irq
5838c2ecf20Sopenharmony_ci#endif
5848c2ecf20Sopenharmony_ci	ADDKPC	.S2	preempt_schedule,B3,4
5858c2ecf20Sopenharmony_ci#endif /* CONFIG_PREEMPTION */
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ciENTRY(enable_exception)
5888c2ecf20Sopenharmony_ci	DINT
5898c2ecf20Sopenharmony_ci	MVC	.S2	TSR,B0
5908c2ecf20Sopenharmony_ci	MVC	.S2	B3,NRP
5918c2ecf20Sopenharmony_ci	MVK	.L2	0xc,B1
5928c2ecf20Sopenharmony_ci	OR	.D2	B0,B1,B0
5938c2ecf20Sopenharmony_ci	MVC	.S2	B0,TSR			;  Set GEE and XEN in TSR
5948c2ecf20Sopenharmony_ci	B	.S2	NRP
5958c2ecf20Sopenharmony_ci	NOP	5
5968c2ecf20Sopenharmony_ciENDPROC(enable_exception)
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	;;
5998c2ecf20Sopenharmony_ci	;; Special system calls
6008c2ecf20Sopenharmony_ci	;; return address is in B3
6018c2ecf20Sopenharmony_ci	;;
6028c2ecf20Sopenharmony_ciENTRY(sys_rt_sigreturn)
6038c2ecf20Sopenharmony_ci	ADD	.D1X	SP,8,A4
6048c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6058c2ecf20Sopenharmony_ci ||	MVKL	.S1	do_rt_sigreturn,A0
6068c2ecf20Sopenharmony_ci	MVKH	.S1	do_rt_sigreturn,A0
6078c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,5
6088c2ecf20Sopenharmony_ci#else
6098c2ecf20Sopenharmony_ci ||	B	.S2	do_rt_sigreturn
6108c2ecf20Sopenharmony_ci	NOP	5
6118c2ecf20Sopenharmony_ci#endif
6128c2ecf20Sopenharmony_ciENDPROC(sys_rt_sigreturn)
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ciENTRY(sys_pread_c6x)
6158c2ecf20Sopenharmony_ci	MV	.D2X	A8,B7
6168c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6178c2ecf20Sopenharmony_ci ||	MVKL	.S1	sys_pread64,A0
6188c2ecf20Sopenharmony_ci	MVKH	.S1	sys_pread64,A0
6198c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,5
6208c2ecf20Sopenharmony_ci#else
6218c2ecf20Sopenharmony_ci ||	B	.S2	sys_pread64
6228c2ecf20Sopenharmony_ci	NOP	5
6238c2ecf20Sopenharmony_ci#endif
6248c2ecf20Sopenharmony_ciENDPROC(sys_pread_c6x)
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ciENTRY(sys_pwrite_c6x)
6278c2ecf20Sopenharmony_ci	MV	.D2X	A8,B7
6288c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6298c2ecf20Sopenharmony_ci ||	MVKL	.S1	sys_pwrite64,A0
6308c2ecf20Sopenharmony_ci	MVKH	.S1	sys_pwrite64,A0
6318c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,5
6328c2ecf20Sopenharmony_ci#else
6338c2ecf20Sopenharmony_ci ||	B	.S2	sys_pwrite64
6348c2ecf20Sopenharmony_ci	NOP	5
6358c2ecf20Sopenharmony_ci#endif
6368c2ecf20Sopenharmony_ciENDPROC(sys_pwrite_c6x)
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci;; On Entry
6398c2ecf20Sopenharmony_ci;;   A4 - path
6408c2ecf20Sopenharmony_ci;;   B4 - offset_lo (LE), offset_hi (BE)
6418c2ecf20Sopenharmony_ci;;   A6 - offset_lo (BE), offset_hi (LE)
6428c2ecf20Sopenharmony_ciENTRY(sys_truncate64_c6x)
6438c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN
6448c2ecf20Sopenharmony_ci	MV	.S2	B4,B5
6458c2ecf20Sopenharmony_ci	MV	.D2X	A6,B4
6468c2ecf20Sopenharmony_ci#else
6478c2ecf20Sopenharmony_ci	MV	.D2X	A6,B5
6488c2ecf20Sopenharmony_ci#endif
6498c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6508c2ecf20Sopenharmony_ci ||	MVKL	.S1	sys_truncate64,A0
6518c2ecf20Sopenharmony_ci	MVKH	.S1	sys_truncate64,A0
6528c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,5
6538c2ecf20Sopenharmony_ci#else
6548c2ecf20Sopenharmony_ci ||	B	.S2	sys_truncate64
6558c2ecf20Sopenharmony_ci	NOP	5
6568c2ecf20Sopenharmony_ci#endif
6578c2ecf20Sopenharmony_ciENDPROC(sys_truncate64_c6x)
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_ci;; On Entry
6608c2ecf20Sopenharmony_ci;;   A4 - fd
6618c2ecf20Sopenharmony_ci;;   B4 - offset_lo (LE), offset_hi (BE)
6628c2ecf20Sopenharmony_ci;;   A6 - offset_lo (BE), offset_hi (LE)
6638c2ecf20Sopenharmony_ciENTRY(sys_ftruncate64_c6x)
6648c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN
6658c2ecf20Sopenharmony_ci	MV	.S2	B4,B5
6668c2ecf20Sopenharmony_ci	MV	.D2X	A6,B4
6678c2ecf20Sopenharmony_ci#else
6688c2ecf20Sopenharmony_ci	MV	.D2X	A6,B5
6698c2ecf20Sopenharmony_ci#endif
6708c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6718c2ecf20Sopenharmony_ci ||	MVKL	.S1	sys_ftruncate64,A0
6728c2ecf20Sopenharmony_ci	MVKH	.S1	sys_ftruncate64,A0
6738c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,5
6748c2ecf20Sopenharmony_ci#else
6758c2ecf20Sopenharmony_ci ||	B	.S2	sys_ftruncate64
6768c2ecf20Sopenharmony_ci	NOP	5
6778c2ecf20Sopenharmony_ci#endif
6788c2ecf20Sopenharmony_ciENDPROC(sys_ftruncate64_c6x)
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci;; On Entry
6818c2ecf20Sopenharmony_ci;;   A4 - fd
6828c2ecf20Sopenharmony_ci;;   B4 - offset_lo (LE), offset_hi (BE)
6838c2ecf20Sopenharmony_ci;;   A6 - offset_lo (BE), offset_hi (LE)
6848c2ecf20Sopenharmony_ci;;   B6 - len_lo (LE), len_hi (BE)
6858c2ecf20Sopenharmony_ci;;   A8 - len_lo (BE), len_hi (LE)
6868c2ecf20Sopenharmony_ci;;   B8 - advice
6878c2ecf20Sopenharmony_ciENTRY(sys_fadvise64_64_c6x)
6888c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
6898c2ecf20Sopenharmony_ci	MVKL	.S1	sys_fadvise64_64,A0
6908c2ecf20Sopenharmony_ci	MVKH	.S1	sys_fadvise64_64,A0
6918c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,2
6928c2ecf20Sopenharmony_ci#else
6938c2ecf20Sopenharmony_ci	B	.S2	sys_fadvise64_64
6948c2ecf20Sopenharmony_ci	NOP	2
6958c2ecf20Sopenharmony_ci#endif
6968c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN
6978c2ecf20Sopenharmony_ci	MV	.L2	B4,B5
6988c2ecf20Sopenharmony_ci ||	MV	.D2X	A6,B4
6998c2ecf20Sopenharmony_ci	MV	.L1	A8,A6
7008c2ecf20Sopenharmony_ci ||	MV	.D1X	B6,A7
7018c2ecf20Sopenharmony_ci#else
7028c2ecf20Sopenharmony_ci	MV	.D2X	A6,B5
7038c2ecf20Sopenharmony_ci	MV	.L1	A8,A7
7048c2ecf20Sopenharmony_ci ||	MV	.D1X	B6,A6
7058c2ecf20Sopenharmony_ci#endif
7068c2ecf20Sopenharmony_ci	MV	.L2	B8,B6
7078c2ecf20Sopenharmony_ciENDPROC(sys_fadvise64_64_c6x)
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_ci;; On Entry
7108c2ecf20Sopenharmony_ci;;   A4 - fd
7118c2ecf20Sopenharmony_ci;;   B4 - mode
7128c2ecf20Sopenharmony_ci;;   A6 - offset_hi
7138c2ecf20Sopenharmony_ci;;   B6 - offset_lo
7148c2ecf20Sopenharmony_ci;;   A8 - len_hi
7158c2ecf20Sopenharmony_ci;;   B8 - len_lo
7168c2ecf20Sopenharmony_ciENTRY(sys_fallocate_c6x)
7178c2ecf20Sopenharmony_ci#ifdef CONFIG_C6X_BIG_KERNEL
7188c2ecf20Sopenharmony_ci	MVKL	.S1	sys_fallocate,A0
7198c2ecf20Sopenharmony_ci	MVKH	.S1	sys_fallocate,A0
7208c2ecf20Sopenharmony_ci	BNOP	.S2X	A0,1
7218c2ecf20Sopenharmony_ci#else
7228c2ecf20Sopenharmony_ci	B	.S2	sys_fallocate
7238c2ecf20Sopenharmony_ci	NOP
7248c2ecf20Sopenharmony_ci#endif
7258c2ecf20Sopenharmony_ci	MV	.D1	A6,A7
7268c2ecf20Sopenharmony_ci	MV	.D1X	B6,A6
7278c2ecf20Sopenharmony_ci	MV	.D2X	A8,B7
7288c2ecf20Sopenharmony_ci	MV	.D2	B8,B6
7298c2ecf20Sopenharmony_ciENDPROC(sys_fallocate_c6x)
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci	;; put this in .neardata for faster access when using DSBT mode
7328c2ecf20Sopenharmony_ci	.section .neardata,"aw",@progbits
7338c2ecf20Sopenharmony_ci	.global	current_ksp
7348c2ecf20Sopenharmony_ci	.hidden	current_ksp
7358c2ecf20Sopenharmony_cicurrent_ksp:
7368c2ecf20Sopenharmony_ci	.word	init_thread_union + THREAD_START_SP
737