162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* asmmacro.h: Assembler macros.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef _SPARC_ASMMACRO_H
862306a36Sopenharmony_ci#define _SPARC_ASMMACRO_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* All trap entry points _must_ begin with this macro or else you
1162306a36Sopenharmony_ci * lose.  It makes sure the kernel has a proper window so that
1262306a36Sopenharmony_ci * c-code can be called.
1362306a36Sopenharmony_ci */
1462306a36Sopenharmony_ci#define SAVE_ALL_HEAD \
1562306a36Sopenharmony_ci	sethi	%hi(trap_setup), %l4; \
1662306a36Sopenharmony_ci	jmpl	%l4 + %lo(trap_setup), %l6;
1762306a36Sopenharmony_ci#define SAVE_ALL \
1862306a36Sopenharmony_ci	SAVE_ALL_HEAD \
1962306a36Sopenharmony_ci	 nop;
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* All traps low-level code here must end with this macro. */
2262306a36Sopenharmony_ci#define RESTORE_ALL b ret_trap_entry; clr %l6;
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Support for run-time patching of single instructions.
2562306a36Sopenharmony_ci * This is used to handle the differences in the ASI for
2662306a36Sopenharmony_ci * MMUREGS for LEON and SUN.
2762306a36Sopenharmony_ci *
2862306a36Sopenharmony_ci * Sample:
2962306a36Sopenharmony_ci * LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %o0
3062306a36Sopenharmony_ci * SUN_PI_(lda [%g0] ASI_M_MMUREGS, %o0
3162306a36Sopenharmony_ci * PI == Patch Instruction
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci * For LEON we will use the first variant,
3462306a36Sopenharmony_ci * and for all other we will use the SUN variant.
3562306a36Sopenharmony_ci * The order is important.
3662306a36Sopenharmony_ci */
3762306a36Sopenharmony_ci#define LEON_PI(...)				\
3862306a36Sopenharmony_ci662:	__VA_ARGS__
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define SUN_PI_(...)				\
4162306a36Sopenharmony_ci	.section .leon_1insn_patch, "ax";	\
4262306a36Sopenharmony_ci	.word 662b;				\
4362306a36Sopenharmony_ci	__VA_ARGS__;				\
4462306a36Sopenharmony_ci	.previous
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#endif /* !(_SPARC_ASMMACRO_H) */
47