asm.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * (C) Copyright 2007 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /* FSL macros */
  25. #define NGET(val, fslnum) \
  26. __asm__ __volatile__ ("nget %0, rfsl" #fslnum :"=r" (val));
  27. #define GET(val, fslnum) \
  28. __asm__ __volatile__ ("get %0, rfsl" #fslnum :"=r" (val));
  29. #define NCGET(val, fslnum) \
  30. __asm__ __volatile__ ("ncget %0, rfsl" #fslnum :"=r" (val));
  31. #define CGET(val, fslnum) \
  32. __asm__ __volatile__ ("cget %0, rfsl" #fslnum :"=r" (val));
  33. #define NPUT(val, fslnum) \
  34. __asm__ __volatile__ ("nput %0, rfsl" #fslnum ::"r" (val));
  35. #define PUT(val, fslnum) \
  36. __asm__ __volatile__ ("put %0, rfsl" #fslnum ::"r" (val));
  37. #define NCPUT(val, fslnum) \
  38. __asm__ __volatile__ ("ncput %0, rfsl" #fslnum ::"r" (val));
  39. #define CPUT(val, fslnum) \
  40. __asm__ __volatile__ ("cput %0, rfsl" #fslnum ::"r" (val));
  41. /* CPU dependent */
  42. /* machine status register */
  43. #define MFS(val, reg) \
  44. __asm__ __volatile__ ("mfs %0," #reg :"=r" (val));
  45. #define MTS(val, reg) \
  46. __asm__ __volatile__ ("mts " #reg ", %0"::"r" (val));
  47. /* get return address from interrupt */
  48. #define R14(val) \
  49. __asm__ __volatile__ ("addi %0, r14, 0":"=r" (val));
  50. #define NOP __asm__ __volatile__ ("nop");
  51. /* use machine status registe USE_MSR_REG */
  52. #ifdef XILINX_USE_MSR_INSTR
  53. #define MSRSET(val) \
  54. __asm__ __volatile__ ("msrset r0," #val );
  55. #define MSRCLR(val) \
  56. __asm__ __volatile__ ("msrclr r0," #val );
  57. #else
  58. #define MSRSET(val) \
  59. { \
  60. register unsigned tmp; \
  61. __asm__ __volatile__ (" \
  62. mfs %0, rmsr; \
  63. ori %0, %0, "#val"; \
  64. mts rmsr, %0; \
  65. nop;" \
  66. : "=r" (tmp) \
  67. : "d" (val) \
  68. : "memory"); \
  69. }
  70. #define MSRCLR(val) \
  71. { \
  72. register unsigned tmp; \
  73. __asm__ __volatile__ (" \
  74. mfs %0, rmsr; \
  75. andi %0, %0, ~"#val"; \
  76. mts rmsr, %0; \
  77. nop;" \
  78. : "=r" (tmp) \
  79. : "d" (val) \
  80. : "memory"); \
  81. }
  82. #endif