18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *	arch/alpha/lib/callback_srm.S
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <asm/console.h>
78c2ecf20Sopenharmony_ci#include <asm/export.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci.text
108c2ecf20Sopenharmony_ci#define HWRPB_CRB_OFFSET 0xc0
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_SRM) || defined(CONFIG_ALPHA_GENERIC)
138c2ecf20Sopenharmony_ci.align 4
148c2ecf20Sopenharmony_cisrm_dispatch:
158c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_GENERIC)
168c2ecf20Sopenharmony_ci	ldl	$4,alpha_using_srm
178c2ecf20Sopenharmony_ci	beq	$4,nosrm
188c2ecf20Sopenharmony_ci#endif
198c2ecf20Sopenharmony_ci	ldq	$0,hwrpb	# gp is set up by CALLBACK macro.
208c2ecf20Sopenharmony_ci	ldl	$25,0($25)	# Pick up the wrapper data.
218c2ecf20Sopenharmony_ci	mov	$20,$21		# Shift arguments right.
228c2ecf20Sopenharmony_ci	mov	$19,$20
238c2ecf20Sopenharmony_ci	ldq	$1,HWRPB_CRB_OFFSET($0)
248c2ecf20Sopenharmony_ci	mov	$18,$19
258c2ecf20Sopenharmony_ci	mov	$17,$18
268c2ecf20Sopenharmony_ci	mov	$16,$17
278c2ecf20Sopenharmony_ci	addq	$0,$1,$2	# CRB address
288c2ecf20Sopenharmony_ci	ldq	$27,0($2)	# DISPATCH procedure descriptor (VMS call std)
298c2ecf20Sopenharmony_ci	extwl	$25,0,$16	# SRM callback function code
308c2ecf20Sopenharmony_ci	ldq	$3,8($27)	# call address
318c2ecf20Sopenharmony_ci	extwl	$25,2,$25	# argument information (VMS calling std)
328c2ecf20Sopenharmony_ci	jmp	($3)		# Return directly to caller of wrapper.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci.align 4
358c2ecf20Sopenharmony_ci.globl	srm_fixup
368c2ecf20Sopenharmony_ci.ent	srm_fixup
378c2ecf20Sopenharmony_cisrm_fixup:
388c2ecf20Sopenharmony_ci	ldgp	$29,0($27)
398c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_GENERIC)
408c2ecf20Sopenharmony_ci	ldl	$4,alpha_using_srm
418c2ecf20Sopenharmony_ci	beq	$4,nosrm
428c2ecf20Sopenharmony_ci#endif
438c2ecf20Sopenharmony_ci	ldq	$0,hwrpb
448c2ecf20Sopenharmony_ci	ldq	$1,HWRPB_CRB_OFFSET($0)
458c2ecf20Sopenharmony_ci	addq	$0,$1,$2	# CRB address
468c2ecf20Sopenharmony_ci	ldq	$27,16($2)	# VA of FIXUP procedure descriptor
478c2ecf20Sopenharmony_ci	ldq	$3,8($27)	# call address
488c2ecf20Sopenharmony_ci	lda	$25,2($31)	# two integer arguments
498c2ecf20Sopenharmony_ci	jmp	($3)		# Return directly to caller of srm_fixup.
508c2ecf20Sopenharmony_ci.end    srm_fixup
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#if defined(CONFIG_ALPHA_GENERIC)
538c2ecf20Sopenharmony_ci.align 3
548c2ecf20Sopenharmony_cinosrm:
558c2ecf20Sopenharmony_ci	lda	$0,-1($31)
568c2ecf20Sopenharmony_ci	ret
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define CALLBACK(NAME, CODE, ARG_CNT) \
608c2ecf20Sopenharmony_ci.align 4; .globl callback_##NAME; .ent callback_##NAME; callback_##NAME##: \
618c2ecf20Sopenharmony_cildgp $29,0($27); br $25,srm_dispatch; .word CODE, ARG_CNT; .end callback_##NAME
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#else /* defined(CONFIG_ALPHA_SRM) || defined(CONFIG_ALPHA_GENERIC) */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define CALLBACK(NAME, CODE, ARG_CNT) \
668c2ecf20Sopenharmony_ci.align 3; .globl callback_##NAME; .ent callback_##NAME; callback_##NAME##: \
678c2ecf20Sopenharmony_cilda $0,-1($31); ret; .end callback_##NAME
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci.align 3
708c2ecf20Sopenharmony_ci.globl	srm_fixup
718c2ecf20Sopenharmony_ci.ent	srm_fixup
728c2ecf20Sopenharmony_cisrm_fixup:
738c2ecf20Sopenharmony_ci	lda	$0,-1($31)
748c2ecf20Sopenharmony_ci	ret
758c2ecf20Sopenharmony_ci.end	srm_fixup
768c2ecf20Sopenharmony_ci#endif /* defined(CONFIG_ALPHA_SRM) || defined(CONFIG_ALPHA_GENERIC) */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciCALLBACK(puts, CCB_PUTS, 4)
798c2ecf20Sopenharmony_ciCALLBACK(open, CCB_OPEN, 3)
808c2ecf20Sopenharmony_ciCALLBACK(close, CCB_CLOSE, 2)
818c2ecf20Sopenharmony_ciCALLBACK(read, CCB_READ, 5)
828c2ecf20Sopenharmony_ciCALLBACK(open_console, CCB_OPEN_CONSOLE, 1)
838c2ecf20Sopenharmony_ciCALLBACK(close_console, CCB_CLOSE_CONSOLE, 1)
848c2ecf20Sopenharmony_ciCALLBACK(getenv, CCB_GET_ENV, 4)
858c2ecf20Sopenharmony_ciCALLBACK(setenv, CCB_SET_ENV, 4)
868c2ecf20Sopenharmony_ciCALLBACK(getc, CCB_GETC, 2)
878c2ecf20Sopenharmony_ciCALLBACK(reset_term, CCB_RESET_TERM, 2)
888c2ecf20Sopenharmony_ciCALLBACK(term_int, CCB_SET_TERM_INT, 3)
898c2ecf20Sopenharmony_ciCALLBACK(term_ctl, CCB_SET_TERM_CTL, 3)
908c2ecf20Sopenharmony_ciCALLBACK(process_keycode, CCB_PROCESS_KEYCODE, 3)
918c2ecf20Sopenharmony_ciCALLBACK(ioctl, CCB_IOCTL, 6)
928c2ecf20Sopenharmony_ciCALLBACK(write, CCB_WRITE, 5)
938c2ecf20Sopenharmony_ciCALLBACK(reset_env, CCB_RESET_ENV, 4)
948c2ecf20Sopenharmony_ciCALLBACK(save_env, CCB_SAVE_ENV, 1)
958c2ecf20Sopenharmony_ciCALLBACK(pswitch, CCB_PSWITCH, 3)
968c2ecf20Sopenharmony_ciCALLBACK(bios_emul, CCB_BIOS_EMUL, 5)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ciEXPORT_SYMBOL(callback_getenv)
998c2ecf20Sopenharmony_ciEXPORT_SYMBOL(callback_setenv)
1008c2ecf20Sopenharmony_ciEXPORT_SYMBOL(callback_save_env)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci.data
1038c2ecf20Sopenharmony_ci__alpha_using_srm:		# For use by bootpheader
1048c2ecf20Sopenharmony_ci	.long 7			# value is not 1 for link debugging
1058c2ecf20Sopenharmony_ci	.weak alpha_using_srm; alpha_using_srm = __alpha_using_srm
1068c2ecf20Sopenharmony_ci__callback_init_done:		# For use by bootpheader
1078c2ecf20Sopenharmony_ci	.long 7			# value is not 1 for link debugging
1088c2ecf20Sopenharmony_ci	.weak callback_init_done; callback_init_done = __callback_init_done
1098c2ecf20Sopenharmony_ci
110