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 | { |
| 28 | int ccode; |
| 29 | |
| 30 | __asm__ __volatile__( |
| 31 | " lr 1,%1\n" |
| 32 | " stsch 0(%2)\n" |
| 33 | " ipm %0\n" |
| 34 | " srl %0,28" |
| 35 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 36 | : "d" (schid), "a" (addr), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | : "cc", "1" ); |
| 38 | return ccode; |
| 39 | } |
| 40 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 41 | static inline int stsch_err(struct subchannel_id schid, |
| 42 | volatile struct schib *addr) |
| 43 | { |
| 44 | int ccode; |
| 45 | |
| 46 | __asm__ __volatile__( |
| 47 | " lhi %0,%3\n" |
| 48 | " lr 1,%1\n" |
| 49 | " stsch 0(%2)\n" |
| 50 | "0: ipm %0\n" |
| 51 | " srl %0,28\n" |
| 52 | "1:\n" |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 53 | #ifdef CONFIG_64BIT |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 54 | ".section __ex_table,\"a\"\n" |
| 55 | " .align 8\n" |
| 56 | " .quad 0b,1b\n" |
| 57 | ".previous" |
| 58 | #else |
| 59 | ".section __ex_table,\"a\"\n" |
| 60 | " .align 4\n" |
| 61 | " .long 0b,1b\n" |
| 62 | ".previous" |
| 63 | #endif |
| 64 | : "=&d" (ccode) |
| 65 | : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr) |
| 66 | : "cc", "1" ); |
| 67 | return ccode; |
| 68 | } |
| 69 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 70 | static inline int msch(struct subchannel_id schid, |
| 71 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | { |
| 73 | int ccode; |
| 74 | |
| 75 | __asm__ __volatile__( |
| 76 | " lr 1,%1\n" |
| 77 | " msch 0(%2)\n" |
| 78 | " ipm %0\n" |
| 79 | " srl %0,28" |
| 80 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 81 | : "d" (schid), "a" (addr), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | : "cc", "1" ); |
| 83 | return ccode; |
| 84 | } |
| 85 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 86 | static inline int msch_err(struct subchannel_id schid, |
| 87 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
| 89 | int ccode; |
| 90 | |
| 91 | __asm__ __volatile__( |
| 92 | " lhi %0,%3\n" |
| 93 | " lr 1,%1\n" |
| 94 | " msch 0(%2)\n" |
| 95 | "0: ipm %0\n" |
| 96 | " srl %0,28\n" |
| 97 | "1:\n" |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 98 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | ".section __ex_table,\"a\"\n" |
| 100 | " .align 8\n" |
| 101 | " .quad 0b,1b\n" |
| 102 | ".previous" |
| 103 | #else |
| 104 | ".section __ex_table,\"a\"\n" |
| 105 | " .align 4\n" |
| 106 | " .long 0b,1b\n" |
| 107 | ".previous" |
| 108 | #endif |
| 109 | : "=&d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 110 | : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | : "cc", "1" ); |
| 112 | return ccode; |
| 113 | } |
| 114 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 115 | static inline int tsch(struct subchannel_id schid, |
| 116 | volatile struct irb *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | { |
| 118 | int ccode; |
| 119 | |
| 120 | __asm__ __volatile__( |
| 121 | " lr 1,%1\n" |
| 122 | " tsch 0(%2)\n" |
| 123 | " ipm %0\n" |
| 124 | " srl %0,28" |
| 125 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 126 | : "d" (schid), "a" (addr), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | : "cc", "1" ); |
| 128 | return ccode; |
| 129 | } |
| 130 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 131 | static inline int tpi( volatile struct tpi_info *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { |
| 133 | int ccode; |
| 134 | |
| 135 | __asm__ __volatile__( |
| 136 | " tpi 0(%1)\n" |
| 137 | " ipm %0\n" |
| 138 | " srl %0,28" |
| 139 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 140 | : "a" (addr), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | : "cc", "1" ); |
| 142 | return ccode; |
| 143 | } |
| 144 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 145 | static inline int ssch(struct subchannel_id schid, |
| 146 | volatile struct orb *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
| 148 | int ccode; |
| 149 | |
| 150 | __asm__ __volatile__( |
| 151 | " lr 1,%1\n" |
| 152 | " ssch 0(%2)\n" |
| 153 | " ipm %0\n" |
| 154 | " srl %0,28" |
| 155 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 156 | : "d" (schid), "a" (addr), "m" (*addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | : "cc", "1" ); |
| 158 | return ccode; |
| 159 | } |
| 160 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 161 | static inline int rsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
| 163 | int ccode; |
| 164 | |
| 165 | __asm__ __volatile__( |
| 166 | " lr 1,%1\n" |
| 167 | " rsch\n" |
| 168 | " ipm %0\n" |
| 169 | " srl %0,28" |
| 170 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 171 | : "d" (schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | : "cc", "1" ); |
| 173 | return ccode; |
| 174 | } |
| 175 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 176 | static inline int csch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | { |
| 178 | int ccode; |
| 179 | |
| 180 | __asm__ __volatile__( |
| 181 | " lr 1,%1\n" |
| 182 | " csch\n" |
| 183 | " ipm %0\n" |
| 184 | " srl %0,28" |
| 185 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 186 | : "d" (schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | : "cc", "1" ); |
| 188 | return ccode; |
| 189 | } |
| 190 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 191 | static inline int hsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | { |
| 193 | int ccode; |
| 194 | |
| 195 | __asm__ __volatile__( |
| 196 | " lr 1,%1\n" |
| 197 | " hsch\n" |
| 198 | " ipm %0\n" |
| 199 | " srl %0,28" |
| 200 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 201 | : "d" (schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | : "cc", "1" ); |
| 203 | return ccode; |
| 204 | } |
| 205 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 206 | static inline int xsch(struct subchannel_id schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
| 208 | int ccode; |
| 209 | |
| 210 | __asm__ __volatile__( |
| 211 | " lr 1,%1\n" |
| 212 | " .insn rre,0xb2760000,%1,0\n" |
| 213 | " ipm %0\n" |
| 214 | " srl %0,28" |
| 215 | : "=d" (ccode) |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 216 | : "d" (schid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | : "cc", "1" ); |
| 218 | return ccode; |
| 219 | } |
| 220 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 221 | static inline int chsc(void *chsc_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 223 | typedef struct { char _[4096]; } addr_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | int cc; |
| 225 | |
| 226 | __asm__ __volatile__ ( |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 227 | ".insn rre,0xb25f0000,%2,0 \n\t" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | "ipm %0 \n\t" |
| 229 | "srl %0,28 \n\t" |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 230 | : "=d" (cc), "=m" (*(addr_type *) chsc_area) |
| 231 | : "d" (chsc_area), "m" (*(addr_type *) chsc_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | : "cc" ); |
| 233 | |
| 234 | return cc; |
| 235 | } |
| 236 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 237 | static inline int iac( void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
| 239 | int ccode; |
| 240 | |
| 241 | __asm__ __volatile__( |
| 242 | " iac 1\n" |
| 243 | " ipm %0\n" |
| 244 | " srl %0,28" |
| 245 | : "=d" (ccode) : : "cc", "1" ); |
| 246 | return ccode; |
| 247 | } |
| 248 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 249 | static inline int rchp(int chpid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | int ccode; |
| 252 | |
| 253 | __asm__ __volatile__( |
| 254 | " lr 1,%1\n" |
| 255 | " rchp\n" |
| 256 | " ipm %0\n" |
| 257 | " srl %0,28" |
| 258 | : "=d" (ccode) |
| 259 | : "d" (chpid) |
| 260 | : "cc", "1" ); |
| 261 | return ccode; |
| 262 | } |
| 263 | |
| 264 | #endif |