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