rse.h 1.6 KB

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