rw_mmr.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2002-2004 Silicon Graphics, Inc. All Rights Reserved.
  7. */
  8. #ifndef _ASM_IA64_SN_RW_MMR_H
  9. #define _ASM_IA64_SN_RW_MMR_H
  10. /*
  11. * This file contains macros used to access MMR registers via
  12. * uncached physical addresses.
  13. * pio_phys_read_mmr - read an MMR
  14. * pio_phys_write_mmr - write an MMR
  15. * pio_atomic_phys_write_mmrs - atomically write 1 or 2 MMRs with psr.ic=0
  16. * Second MMR will be skipped if address is NULL
  17. *
  18. * Addresses passed to these routines should be uncached physical addresses
  19. * ie., 0x80000....
  20. */
  21. extern inline long
  22. pio_phys_read_mmr(volatile long *mmr)
  23. {
  24. long val;
  25. asm volatile
  26. ("mov r2=psr;;"
  27. "rsm psr.i | psr.dt;;"
  28. "srlz.i;;"
  29. "ld8.acq %0=[%1];;"
  30. "mov psr.l=r2;;"
  31. "srlz.i;;"
  32. : "=r"(val)
  33. : "r"(mmr)
  34. : "r2");
  35. return val;
  36. }
  37. extern inline void
  38. pio_phys_write_mmr(volatile long *mmr, long val)
  39. {
  40. asm volatile
  41. ("mov r2=psr;;"
  42. "rsm psr.i | psr.dt;;"
  43. "srlz.i;;"
  44. "st8.rel [%0]=%1;;"
  45. "mov psr.l=r2;;"
  46. "srlz.i;;"
  47. :: "r"(mmr), "r"(val)
  48. : "r2", "memory");
  49. }
  50. extern inline void
  51. pio_atomic_phys_write_mmrs(volatile long *mmr1, long val1, volatile long *mmr2, long val2)
  52. {
  53. asm volatile
  54. ("mov r2=psr;;"
  55. "rsm psr.i | psr.dt | psr.ic;;"
  56. "cmp.ne p9,p0=%2,r0;"
  57. "srlz.i;;"
  58. "st8.rel [%0]=%1;"
  59. "(p9) st8.rel [%2]=%3;;"
  60. "mov psr.l=r2;;"
  61. "srlz.i;;"
  62. :: "r"(mmr1), "r"(val1), "r"(mmr2), "r"(val2)
  63. : "p9", "r2", "memory");
  64. }
  65. #endif /* _ASM_IA64_SN_RW_MMR_H */