xref: /openbmc/linux/arch/ia64/include/asm/asmmacro.h (revision dafb9320671316fbd030b1d2e0ab9b96597223cb)
17f30491cSTony Luck #ifndef _ASM_IA64_ASMMACRO_H
27f30491cSTony Luck #define _ASM_IA64_ASMMACRO_H
37f30491cSTony Luck 
47f30491cSTony Luck /*
57f30491cSTony Luck  * Copyright (C) 2000-2001, 2003-2004 Hewlett-Packard Co
67f30491cSTony Luck  *	David Mosberger-Tang <davidm@hpl.hp.com>
77f30491cSTony Luck  */
87f30491cSTony Luck 
97f30491cSTony Luck 
107f30491cSTony Luck #define ENTRY(name)				\
117f30491cSTony Luck 	.align 32;				\
127f30491cSTony Luck 	.proc name;				\
137f30491cSTony Luck name:
147f30491cSTony Luck 
157f30491cSTony Luck #define ENTRY_MIN_ALIGN(name)			\
167f30491cSTony Luck 	.align 16;				\
177f30491cSTony Luck 	.proc name;				\
187f30491cSTony Luck name:
197f30491cSTony Luck 
207f30491cSTony Luck #define GLOBAL_ENTRY(name)			\
217f30491cSTony Luck 	.global name;				\
227f30491cSTony Luck 	ENTRY(name)
237f30491cSTony Luck 
247f30491cSTony Luck #define END(name)				\
257f30491cSTony Luck 	.endp name
267f30491cSTony Luck 
277f30491cSTony Luck /*
287f30491cSTony Luck  * Helper macros to make unwind directives more readable:
297f30491cSTony Luck  */
307f30491cSTony Luck 
317f30491cSTony Luck /* prologue_gr: */
327f30491cSTony Luck #define ASM_UNW_PRLG_RP			0x8
337f30491cSTony Luck #define ASM_UNW_PRLG_PFS		0x4
347f30491cSTony Luck #define ASM_UNW_PRLG_PSP		0x2
357f30491cSTony Luck #define ASM_UNW_PRLG_PR			0x1
367f30491cSTony Luck #define ASM_UNW_PRLG_GRSAVE(ninputs)	(32+(ninputs))
377f30491cSTony Luck 
387f30491cSTony Luck /*
397f30491cSTony Luck  * Helper macros for accessing user memory.
407f30491cSTony Luck  *
417f30491cSTony Luck  * When adding any new .section/.previous entries here, make sure to
427f30491cSTony Luck  * also add it to the DISCARD section in arch/ia64/kernel/gate.lds.S or
437f30491cSTony Luck  * unpleasant things will happen.
447f30491cSTony Luck  */
457f30491cSTony Luck 
467f30491cSTony Luck 	.section "__ex_table", "a"		// declare section & section attributes
477f30491cSTony Luck 	.previous
487f30491cSTony Luck 
497f30491cSTony Luck # define EX(y,x...)				\
507f30491cSTony Luck 	.xdata4 "__ex_table", 99f-., y-.;	\
517f30491cSTony Luck   [99:]	x
527f30491cSTony Luck # define EXCLR(y,x...)				\
537f30491cSTony Luck 	.xdata4 "__ex_table", 99f-., y-.+4;	\
547f30491cSTony Luck   [99:]	x
557f30491cSTony Luck 
567f30491cSTony Luck /*
577f30491cSTony Luck  * Tag MCA recoverable instruction ranges.
587f30491cSTony Luck  */
597f30491cSTony Luck 
607f30491cSTony Luck 	.section "__mca_table", "a"		// declare section & section attributes
617f30491cSTony Luck 	.previous
627f30491cSTony Luck 
637f30491cSTony Luck # define MCA_RECOVER_RANGE(y)			\
647f30491cSTony Luck 	.xdata4 "__mca_table", y-., 99f-.;	\
657f30491cSTony Luck   [99:]
667f30491cSTony Luck 
677f30491cSTony Luck /*
687f30491cSTony Luck  * Mark instructions that need a load of a virtual address patched to be
697f30491cSTony Luck  * a load of a physical address.  We use this either in critical performance
707f30491cSTony Luck  * path (ivt.S - TLB miss processing) or in places where it might not be
717f30491cSTony Luck  * safe to use a "tpa" instruction (mca_asm.S - error recovery).
727f30491cSTony Luck  */
73*dafb9320SDenys Vlasenko 	.section ".data..patch.vtop", "a"	// declare section & section attributes
747f30491cSTony Luck 	.previous
757f30491cSTony Luck 
767f30491cSTony Luck #define	LOAD_PHYSICAL(pr, reg, obj)		\
777f30491cSTony Luck [1:](pr)movl reg = obj;				\
78*dafb9320SDenys Vlasenko 	.xdata4 ".data..patch.vtop", 1b-.
797f30491cSTony Luck 
807f30491cSTony Luck /*
817f30491cSTony Luck  * For now, we always put in the McKinley E9 workaround.  On CPUs that don't need it,
827f30491cSTony Luck  * we'll patch out the work-around bundles with NOPs, so their impact is minimal.
837f30491cSTony Luck  */
847f30491cSTony Luck #define DO_MCKINLEY_E9_WORKAROUND
857f30491cSTony Luck 
867f30491cSTony Luck #ifdef DO_MCKINLEY_E9_WORKAROUND
87*dafb9320SDenys Vlasenko 	.section ".data..patch.mckinley_e9", "a"
887f30491cSTony Luck 	.previous
897f30491cSTony Luck /* workaround for Itanium 2 Errata 9: */
907f30491cSTony Luck # define FSYS_RETURN					\
91*dafb9320SDenys Vlasenko 	.xdata4 ".data..patch.mckinley_e9", 1f-.;	\
927f30491cSTony Luck 1:{ .mib;						\
937f30491cSTony Luck 	nop.m 0;					\
947f30491cSTony Luck 	mov r16=ar.pfs;					\
957f30491cSTony Luck 	br.call.sptk.many b7=2f;;			\
967f30491cSTony Luck   };							\
977f30491cSTony Luck 2:{ .mib;						\
987f30491cSTony Luck 	nop.m 0;					\
997f30491cSTony Luck 	mov ar.pfs=r16;					\
1007f30491cSTony Luck 	br.ret.sptk.many b6;;				\
1017f30491cSTony Luck   }
1027f30491cSTony Luck #else
1037f30491cSTony Luck # define FSYS_RETURN	br.ret.sptk.many b6
1047f30491cSTony Luck #endif
1057f30491cSTony Luck 
1067f30491cSTony Luck /*
1077f30491cSTony Luck  * If physical stack register size is different from DEF_NUM_STACK_REG,
1087f30491cSTony Luck  * dynamically patch the kernel for correct size.
1097f30491cSTony Luck  */
110*dafb9320SDenys Vlasenko 	.section ".data..patch.phys_stack_reg", "a"
1117f30491cSTony Luck 	.previous
1127f30491cSTony Luck #define LOAD_PHYS_STACK_REG_SIZE(reg)			\
1137f30491cSTony Luck [1:]	adds reg=IA64_NUM_PHYS_STACK_REG*8+8,r0;	\
114*dafb9320SDenys Vlasenko 	.xdata4 ".data..patch.phys_stack_reg", 1b-.
1157f30491cSTony Luck 
1167f30491cSTony Luck /*
1177f30491cSTony Luck  * Up until early 2004, use of .align within a function caused bad unwind info.
1187f30491cSTony Luck  * TEXT_ALIGN(n) expands into ".align n" if a fixed GAS is available or into nothing
1197f30491cSTony Luck  * otherwise.
1207f30491cSTony Luck  */
1217f30491cSTony Luck #ifdef HAVE_WORKING_TEXT_ALIGN
1227f30491cSTony Luck # define TEXT_ALIGN(n)	.align n
1237f30491cSTony Luck #else
1247f30491cSTony Luck # define TEXT_ALIGN(n)
1257f30491cSTony Luck #endif
1267f30491cSTony Luck 
1277f30491cSTony Luck #ifdef HAVE_SERIALIZE_DIRECTIVE
1287f30491cSTony Luck # define dv_serialize_data		.serialize.data
1297f30491cSTony Luck # define dv_serialize_instruction	.serialize.instruction
1307f30491cSTony Luck #else
1317f30491cSTony Luck # define dv_serialize_data
1327f30491cSTony Luck # define dv_serialize_instruction
1337f30491cSTony Luck #endif
1347f30491cSTony Luck 
1357f30491cSTony Luck #endif /* _ASM_IA64_ASMMACRO_H */
136