xref: /linux/arch/sparc/include/asm/asmmacro.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a439fe51SSam Ravnborg /* asmmacro.h: Assembler macros.
3a439fe51SSam Ravnborg  *
4a439fe51SSam Ravnborg  * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
5a439fe51SSam Ravnborg  */
6a439fe51SSam Ravnborg 
7a439fe51SSam Ravnborg #ifndef _SPARC_ASMMACRO_H
8a439fe51SSam Ravnborg #define _SPARC_ASMMACRO_H
9a439fe51SSam Ravnborg 
10a439fe51SSam Ravnborg /* All trap entry points _must_ begin with this macro or else you
11a439fe51SSam Ravnborg  * lose.  It makes sure the kernel has a proper window so that
12a439fe51SSam Ravnborg  * c-code can be called.
13a439fe51SSam Ravnborg  */
14a439fe51SSam Ravnborg #define SAVE_ALL_HEAD \
15a439fe51SSam Ravnborg 	sethi	%hi(trap_setup), %l4; \
16a439fe51SSam Ravnborg 	jmpl	%l4 + %lo(trap_setup), %l6;
17a439fe51SSam Ravnborg #define SAVE_ALL \
18a439fe51SSam Ravnborg 	SAVE_ALL_HEAD \
19a439fe51SSam Ravnborg 	 nop;
20a439fe51SSam Ravnborg 
21a439fe51SSam Ravnborg /* All traps low-level code here must end with this macro. */
22a439fe51SSam Ravnborg #define RESTORE_ALL b ret_trap_entry; clr %l6;
23a439fe51SSam Ravnborg 
245b8b93c4SSam Ravnborg /* Support for run-time patching of single instructions.
255b8b93c4SSam Ravnborg  * This is used to handle the differences in the ASI for
265b8b93c4SSam Ravnborg  * MMUREGS for LEON and SUN.
275b8b93c4SSam Ravnborg  *
285b8b93c4SSam Ravnborg  * Sample:
295b8b93c4SSam Ravnborg  * LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %o0
305b8b93c4SSam Ravnborg  * SUN_PI_(lda [%g0] ASI_M_MMUREGS, %o0
315b8b93c4SSam Ravnborg  * PI == Patch Instruction
325b8b93c4SSam Ravnborg  *
335b8b93c4SSam Ravnborg  * For LEON we will use the first variant,
345b8b93c4SSam Ravnborg  * and for all other we will use the SUN variant.
355b8b93c4SSam Ravnborg  * The order is important.
365b8b93c4SSam Ravnborg  */
375b8b93c4SSam Ravnborg #define LEON_PI(...)				\
385b8b93c4SSam Ravnborg 662:	__VA_ARGS__
395b8b93c4SSam Ravnborg 
405b8b93c4SSam Ravnborg #define SUN_PI_(...)				\
415b8b93c4SSam Ravnborg 	.section .leon_1insn_patch, "ax";	\
425b8b93c4SSam Ravnborg 	.word 662b;				\
435b8b93c4SSam Ravnborg 	__VA_ARGS__;				\
445b8b93c4SSam Ravnborg 	.previous
455b8b93c4SSam Ravnborg 
46a439fe51SSam Ravnborg #endif /* !(_SPARC_ASMMACRO_H) */
47