ioasm.h 2.6 KB

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