rse.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * Copyright (C) 1998, 1999 Hewlett-Packard Co
  6. * Copyright (C) 1998, 1999 David Mosberger-Tang <[email protected]>
  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. static __inline__ unsigned long
  14. ia64_rse_slot_num (unsigned long *addr)
  15. {
  16. return (((unsigned long) addr) >> 3) & 0x3f;
  17. }
  18. /*
  19. * Return TRUE if ADDR is the address of an RNAT slot.
  20. */
  21. static __inline__ unsigned long
  22. ia64_rse_is_rnat_slot (unsigned long *addr)
  23. {
  24. return ia64_rse_slot_num(addr) == 0x3f;
  25. }
  26. /*
  27. * Returns the address of the RNAT slot that covers the slot at
  28. * address SLOT_ADDR.
  29. */
  30. static __inline__ unsigned long *
  31. ia64_rse_rnat_addr (unsigned long *slot_addr)
  32. {
  33. return (unsigned long *) ((unsigned long) slot_addr | (0x3f << 3));
  34. }
  35. /*
  36. * Calculate the number of registers in the dirty partition starting at BSPSTORE and
  37. * ending at BSP. This isn't simply (BSP-BSPSTORE)/8 because every 64th slot stores
  38. * ar.rnat.
  39. */
  40. static __inline__ unsigned long
  41. ia64_rse_num_regs (unsigned long *bspstore, unsigned long *bsp)
  42. {
  43. unsigned long slots = (bsp - bspstore);
  44. return slots - (ia64_rse_slot_num(bspstore) + slots)/0x40;
  45. }
  46. /*
  47. * The inverse of the above: given bspstore and the number of
  48. * registers, calculate ar.bsp.
  49. */
  50. static __inline__ unsigned long *
  51. ia64_rse_skip_regs (unsigned long *addr, long num_regs)
  52. {
  53. long delta = ia64_rse_slot_num(addr) + num_regs;
  54. if (num_regs < 0)
  55. delta -= 0x3e;
  56. return addr + num_regs + delta/0x3f;
  57. }
  58. #endif /* _ASM_IA64_RSE_H */