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 | |
Peter Oberparleiter | e5854a5 | 2007-04-27 16:01:31 +0200 | [diff] [blame] | 4 | #include <asm/chpid.h> |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 5 | #include <asm/schid.h> |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | /* |
| 8 | * TPI info structure |
| 9 | */ |
| 10 | struct tpi_info { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 11 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 22 | /* |
| 23 | * Some S390 specific IO instructions as inline |
| 24 | */ |
| 25 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 26 | static inline int stsch(struct subchannel_id schid, |
| 27 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 29 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | int ccode; |
| 31 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 32 | asm volatile( |
| 33 | " stsch 0(%2)\n" |
| 34 | " ipm %0\n" |
| 35 | " srl %0,28" |
| 36 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | return ccode; |
| 38 | } |
| 39 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 40 | static inline int stsch_err(struct subchannel_id schid, |
| 41 | volatile struct schib *addr) |
| 42 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 43 | register struct subchannel_id reg1 asm ("1") = schid; |
| 44 | int ccode = -EIO; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 45 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 46 | asm volatile( |
| 47 | " stsch 0(%2)\n" |
| 48 | "0: ipm %0\n" |
| 49 | " srl %0,28\n" |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 50 | "1:\n" |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 51 | EX_TABLE(0b,1b) |
| 52 | : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 53 | return ccode; |
| 54 | } |
| 55 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 56 | static inline int msch(struct subchannel_id schid, |
| 57 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 59 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | int ccode; |
| 61 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 62 | asm volatile( |
| 63 | " msch 0(%2)\n" |
| 64 | " ipm %0\n" |
| 65 | " srl %0,28" |
| 66 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | return ccode; |
| 68 | } |
| 69 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 70 | static inline int msch_err(struct subchannel_id schid, |
| 71 | volatile struct schib *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 73 | register struct subchannel_id reg1 asm ("1") = schid; |
| 74 | int ccode = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 76 | asm volatile( |
| 77 | " msch 0(%2)\n" |
| 78 | "0: ipm %0\n" |
| 79 | " srl %0,28\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | "1:\n" |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 81 | EX_TABLE(0b,1b) |
| 82 | : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | return ccode; |
| 84 | } |
| 85 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 86 | static inline int tsch(struct subchannel_id schid, |
| 87 | volatile struct irb *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 89 | register struct subchannel_id reg1 asm ("1") = schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | int ccode; |
| 91 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 92 | asm volatile( |
| 93 | " tsch 0(%2)\n" |
| 94 | " ipm %0\n" |
| 95 | " srl %0,28" |
| 96 | : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | return ccode; |
| 98 | } |
| 99 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 100 | static inline int tpi( volatile struct tpi_info *addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | int ccode; |
| 103 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 104 | asm volatile( |
| 105 | " tpi 0(%1)\n" |
| 106 | " ipm %0\n" |
| 107 | " srl %0,28" |
| 108 | : "=d" (ccode) : "a" (addr), "m" (*addr) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | return ccode; |
| 110 | } |
| 111 | |
Cornelia Huck | 4c24da7 | 2005-09-03 15:58:01 -0700 | [diff] [blame] | 112 | static inline int chsc(void *chsc_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 114 | typedef struct { char _[4096]; } addr_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | int cc; |
| 116 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 117 | asm volatile( |
| 118 | " .insn rre,0xb25f0000,%2,0\n" |
| 119 | " ipm %0\n" |
| 120 | " srl %0,28\n" |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 121 | : "=d" (cc), "=m" (*(addr_type *) chsc_area) |
| 122 | : "d" (chsc_area), "m" (*(addr_type *) chsc_area) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 123 | : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | return cc; |
| 125 | } |
| 126 | |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 127 | static inline int rchp(struct chp_id chpid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | { |
Peter Oberparleiter | f86635f | 2007-04-27 16:01:26 +0200 | [diff] [blame] | 129 | register struct chp_id reg1 asm ("1") = chpid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | int ccode; |
| 131 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 132 | asm volatile( |
| 133 | " lr 1,%1\n" |
| 134 | " rchp\n" |
| 135 | " ipm %0\n" |
| 136 | " srl %0,28" |
| 137 | : "=d" (ccode) : "d" (reg1) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | return ccode; |
| 139 | } |
| 140 | |
| 141 | #endif |