xref: /openbmc/linux/arch/ia64/include/uapi/asm/rse.h (revision e3d786a3)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _ASM_IA64_RSE_H
3 #define _ASM_IA64_RSE_H
4 
5 /*
6  * Copyright (C) 1998, 1999 Hewlett-Packard Co
7  * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com>
8  *
9  * Register stack engine related helper functions.  This file may be
10  * used in applications, so be careful about the name-space and give
11  * some consideration to non-GNU C compilers (though __inline__ is
12  * fine).
13  */
14 
15 static __inline__ unsigned long
16 ia64_rse_slot_num (unsigned long *addr)
17 {
18 	return (((unsigned long) addr) >> 3) & 0x3f;
19 }
20 
21 /*
22  * Return TRUE if ADDR is the address of an RNAT slot.
23  */
24 static __inline__ unsigned long
25 ia64_rse_is_rnat_slot (unsigned long *addr)
26 {
27 	return ia64_rse_slot_num(addr) == 0x3f;
28 }
29 
30 /*
31  * Returns the address of the RNAT slot that covers the slot at
32  * address SLOT_ADDR.
33  */
34 static __inline__ unsigned long *
35 ia64_rse_rnat_addr (unsigned long *slot_addr)
36 {
37 	return (unsigned long *) ((unsigned long) slot_addr | (0x3f << 3));
38 }
39 
40 /*
41  * Calculate the number of registers in the dirty partition starting at BSPSTORE and
42  * ending at BSP.  This isn't simply (BSP-BSPSTORE)/8 because every 64th slot stores
43  * ar.rnat.
44  */
45 static __inline__ unsigned long
46 ia64_rse_num_regs (unsigned long *bspstore, unsigned long *bsp)
47 {
48 	unsigned long slots = (bsp - bspstore);
49 
50 	return slots - (ia64_rse_slot_num(bspstore) + slots)/0x40;
51 }
52 
53 /*
54  * The inverse of the above: given bspstore and the number of
55  * registers, calculate ar.bsp.
56  */
57 static __inline__ unsigned long *
58 ia64_rse_skip_regs (unsigned long *addr, long num_regs)
59 {
60 	long delta = ia64_rse_slot_num(addr) + num_regs;
61 
62 	if (num_regs < 0)
63 		delta -= 0x3e;
64 	return addr + num_regs + delta/0x3f;
65 }
66 
67 #endif /* _ASM_IA64_RSE_H */
68