ioasm.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef S390_CIO_IOASM_H
  2. #define S390_CIO_IOASM_H
  3. #include <asm/chpid.h>
  4. #include <asm/schid.h>
  5. #include "orb.h"
  6. #include "cio.h"
  7. /*
  8. * TPI info structure
  9. */
  10. struct tpi_info {
  11. struct subchannel_id schid;
  12. __u32 intparm; /* interruption parameter */
  13. __u32 adapter_IO : 1;
  14. __u32 reserved2 : 1;
  15. __u32 isc : 3;
  16. __u32 reserved3 : 12;
  17. __u32 int_type : 3;
  18. __u32 reserved4 : 12;
  19. } __attribute__ ((packed));
  20. /*
  21. * Some S390 specific IO instructions as inline
  22. */
  23. static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
  24. {
  25. register struct subchannel_id reg1 asm ("1") = schid;
  26. int ccode = -EIO;
  27. asm volatile(
  28. " stsch 0(%3)\n"
  29. "0: ipm %0\n"
  30. " srl %0,28\n"
  31. "1:\n"
  32. EX_TABLE(0b,1b)
  33. : "+d" (ccode), "=m" (*addr)
  34. : "d" (reg1), "a" (addr)
  35. : "cc");
  36. return ccode;
  37. }
  38. static inline int msch(struct subchannel_id schid, struct schib *addr)
  39. {
  40. register struct subchannel_id reg1 asm ("1") = schid;
  41. int ccode;
  42. asm volatile(
  43. " msch 0(%2)\n"
  44. " ipm %0\n"
  45. " srl %0,28"
  46. : "=d" (ccode)
  47. : "d" (reg1), "a" (addr), "m" (*addr)
  48. : "cc");
  49. return ccode;
  50. }
  51. static inline int msch_err(struct subchannel_id schid, struct schib *addr)
  52. {
  53. register struct subchannel_id reg1 asm ("1") = schid;
  54. int ccode = -EIO;
  55. asm volatile(
  56. " msch 0(%2)\n"
  57. "0: ipm %0\n"
  58. " srl %0,28\n"
  59. "1:\n"
  60. EX_TABLE(0b,1b)
  61. : "+d" (ccode)
  62. : "d" (reg1), "a" (addr), "m" (*addr)
  63. : "cc");
  64. return ccode;
  65. }
  66. static inline int tsch(struct subchannel_id schid, struct irb *addr)
  67. {
  68. register struct subchannel_id reg1 asm ("1") = schid;
  69. int ccode;
  70. asm volatile(
  71. " tsch 0(%3)\n"
  72. " ipm %0\n"
  73. " srl %0,28"
  74. : "=d" (ccode), "=m" (*addr)
  75. : "d" (reg1), "a" (addr)
  76. : "cc");
  77. return ccode;
  78. }
  79. static inline int ssch(struct subchannel_id schid, union orb *addr)
  80. {
  81. register struct subchannel_id reg1 asm("1") = schid;
  82. int ccode = -EIO;
  83. asm volatile(
  84. " ssch 0(%2)\n"
  85. "0: ipm %0\n"
  86. " srl %0,28\n"
  87. "1:\n"
  88. EX_TABLE(0b, 1b)
  89. : "+d" (ccode)
  90. : "d" (reg1), "a" (addr), "m" (*addr)
  91. : "cc", "memory");
  92. return ccode;
  93. }
  94. static inline int csch(struct subchannel_id schid)
  95. {
  96. register struct subchannel_id reg1 asm("1") = schid;
  97. int ccode;
  98. asm volatile(
  99. " csch\n"
  100. " ipm %0\n"
  101. " srl %0,28"
  102. : "=d" (ccode)
  103. : "d" (reg1)
  104. : "cc");
  105. return ccode;
  106. }
  107. static inline int tpi(struct tpi_info *addr)
  108. {
  109. int ccode;
  110. asm volatile(
  111. " tpi 0(%2)\n"
  112. " ipm %0\n"
  113. " srl %0,28"
  114. : "=d" (ccode), "=m" (*addr)
  115. : "a" (addr)
  116. : "cc");
  117. return ccode;
  118. }
  119. static inline int chsc(void *chsc_area)
  120. {
  121. typedef struct { char _[4096]; } addr_type;
  122. int cc;
  123. asm volatile(
  124. " .insn rre,0xb25f0000,%2,0\n"
  125. " ipm %0\n"
  126. " srl %0,28\n"
  127. : "=d" (cc), "=m" (*(addr_type *) chsc_area)
  128. : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
  129. : "cc");
  130. return cc;
  131. }
  132. static inline int rchp(struct chp_id chpid)
  133. {
  134. register struct chp_id reg1 asm ("1") = chpid;
  135. int ccode;
  136. asm volatile(
  137. " lr 1,%1\n"
  138. " rchp\n"
  139. " ipm %0\n"
  140. " srl %0,28"
  141. : "=d" (ccode) : "d" (reg1) : "cc");
  142. return ccode;
  143. }
  144. #endif