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