Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef S390_CIO_IOASM_H |
| 2 | #define S390_CIO_IOASM_H |
| 3 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 4 | #include "schid.h" |
| 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | /* |
| 7 | * TPI info structure |
| 8 | */ |
| 9 | struct tpi_info { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 10 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | __u32 intparm; /* interruption parameter */ |
| 12 | __u32 adapter_IO : 1; |
| 13 | __u32 reserved2 : 1; |
| 14 | __u32 isc : 3; |
| 15 | __u32 reserved3 : 12; |
| 16 | __u32 int_type : 3; |
| 17 | __u32 reserved4 : 12; |
| 18 | } __attribute__ ((packed)); |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | * Some S390 specific IO instructions as inline |
| 23 | */ |
| 24 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 25 | static inline int stsch(struct subchannel_id schid, |
| 26 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 28 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | int ccode; |
| 30 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 31 | asm volatile( |
| 32 | " stsch 0(%2)\n" |
| 33 | " ipm %0\n" |
| 34 | " srl %0,28" |
| 35 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | return ccode; |
| 37 | } |
| 38 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 39 | static inline int stsch_err(struct subchannel_id schid, |
| 40 | volatile struct schib *addr) |
| 41 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 42 | register struct subchannel_id reg1 asm ("1") = schid; |
| 43 | int ccode = -EIO; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 44 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 45 | asm volatile( |
| 46 | " stsch 0(%2)\n" |
| 47 | "0: ipm %0\n" |
| 48 | " srl %0,28\n" |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 49 | "1:\n" |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 50 | EX_TABLE(0b,1b) |
| 51 | : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 52 | return ccode; |
| 53 | } |
| 54 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 55 | static inline int msch(struct subchannel_id schid, |
| 56 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 58 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | int ccode; |
| 60 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 61 | asm volatile( |
| 62 | " msch 0(%2)\n" |
| 63 | " ipm %0\n" |
| 64 | " srl %0,28" |
| 65 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | return ccode; |
| 67 | } |
| 68 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 69 | static inline int msch_err(struct subchannel_id schid, |
| 70 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 72 | register struct subchannel_id reg1 asm ("1") = schid; |
| 73 | int ccode = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 75 | asm volatile( |
| 76 | " msch 0(%2)\n" |
| 77 | "0: ipm %0\n" |
| 78 | " srl %0,28\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | "1:\n" |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 80 | EX_TABLE(0b,1b) |
| 81 | : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | return ccode; |
| 83 | } |
| 84 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 85 | static inline int tsch(struct subchannel_id schid, |
| 86 | volatile struct irb *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 88 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | int ccode; |
| 90 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 91 | asm volatile( |
| 92 | " tsch 0(%2)\n" |
| 93 | " ipm %0\n" |
| 94 | " srl %0,28" |
| 95 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return ccode; |
| 97 | } |
| 98 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 99 | static inline int tpi( volatile struct tpi_info *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { |
| 101 | int ccode; |
| 102 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 103 | asm volatile( |
| 104 | " tpi 0(%1)\n" |
| 105 | " ipm %0\n" |
| 106 | " srl %0,28" |
| 107 | : "=d" (ccode) : "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | return ccode; |
| 109 | } |
| 110 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 111 | static inline int ssch(struct subchannel_id schid, |
| 112 | volatile struct orb *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 114 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | int ccode; |
| 116 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 117 | asm volatile( |
| 118 | " ssch 0(%2)\n" |
| 119 | " ipm %0\n" |
| 120 | " srl %0,28" |
| 121 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | return ccode; |
| 123 | } |
| 124 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 125 | static inline int rsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 127 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | int ccode; |
| 129 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 130 | asm volatile( |
| 131 | " rsch\n" |
| 132 | " ipm %0\n" |
| 133 | " srl %0,28" |
| 134 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | return ccode; |
| 136 | } |
| 137 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 138 | static inline int csch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 140 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | int ccode; |
| 142 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 143 | asm volatile( |
| 144 | " csch\n" |
| 145 | " ipm %0\n" |
| 146 | " srl %0,28" |
| 147 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | return ccode; |
| 149 | } |
| 150 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 151 | static inline int hsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 153 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | int ccode; |
| 155 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 156 | asm volatile( |
| 157 | " hsch\n" |
| 158 | " ipm %0\n" |
| 159 | " srl %0,28" |
| 160 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | return ccode; |
| 162 | } |
| 163 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 164 | static inline int xsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 166 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | int ccode; |
| 168 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 169 | asm volatile( |
| 170 | " .insn rre,0xb2760000,%1,0\n" |
| 171 | " ipm %0\n" |
| 172 | " srl %0,28" |
| 173 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | return ccode; |
| 175 | } |
| 176 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 177 | static inline int chsc(void *chsc_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 179 | typedef struct { char _[4096]; } addr_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | int cc; |
| 181 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 182 | asm volatile( |
| 183 | " .insn rre,0xb25f0000,%2,0\n" |
| 184 | " ipm %0\n" |
| 185 | " srl %0,28\n" |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 186 | : "=d" (cc), "=m" (*(addr_type *) chsc_area) |
| 187 | : "d" (chsc_area), "m" (*(addr_type *) chsc_area) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 188 | : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | return cc; |
| 190 | } |
| 191 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 192 | static inline int rchp(int chpid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 194 | register unsigned int reg1 asm ("1") = chpid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | int ccode; |
| 196 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 197 | asm volatile( |
| 198 | " lr 1,%1\n" |
| 199 | " rchp\n" |
| 200 | " ipm %0\n" |
| 201 | " srl %0,28" |
| 202 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | return ccode; |
| 204 | } |
| 205 | |
| 206 | #endif |