Browse Source

[linda] Use standard readq() and writeq() implementations

This driver is the original source of the current readq() and writeq()
implementations for 32-bit iPXE.  Switch to using the now-centralised
definitions, to avoid including architecture-specific code in an
otherwise architecture-independent driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
5229662b7f
1 changed files with 8 additions and 26 deletions
  1. 8
    26
      src/drivers/infiniband/linda.c

+ 8
- 26
src/drivers/infiniband/linda.c View File

112
  * This card requires atomic 64-bit accesses.  Strange things happen
112
  * This card requires atomic 64-bit accesses.  Strange things happen
113
  * if you try to use 32-bit accesses; sometimes they work, sometimes
113
  * if you try to use 32-bit accesses; sometimes they work, sometimes
114
  * they don't, sometimes you get random data.
114
  * they don't, sometimes you get random data.
115
- *
116
- * These accessors use the "movq" MMX instruction, and so won't work
117
- * on really old Pentiums (which won't have PCIe anyway, so this is
118
- * something of a moot point).
119
  */
115
  */
120
 
116
 
121
 /**
117
 /**
122
  * Read Linda qword register
118
  * Read Linda qword register
123
  *
119
  *
124
  * @v linda		Linda device
120
  * @v linda		Linda device
125
- * @v dwords		Register buffer to read into
121
+ * @v qword		Register buffer to read into
126
  * @v offset		Register offset
122
  * @v offset		Register offset
127
  */
123
  */
128
-static void linda_readq ( struct linda *linda, uint32_t *dwords,
124
+static void linda_readq ( struct linda *linda, uint64_t *qword,
129
 			  unsigned long offset ) {
125
 			  unsigned long offset ) {
130
-	void *addr = ( linda->regs + offset );
131
-
132
-	__asm__ __volatile__ ( "movq (%1), %%mm0\n\t"
133
-			       "movq %%mm0, (%0)\n\t"
134
-			       : : "r" ( dwords ), "r" ( addr ) : "memory" );
135
-
136
-	DBGIO ( "[%08lx] => %08x%08x\n",
137
-		virt_to_phys ( addr ), dwords[1], dwords[0] );
126
+	*qword = readq ( linda->regs + offset );
138
 }
127
 }
139
 #define linda_readq( _linda, _ptr, _offset ) \
128
 #define linda_readq( _linda, _ptr, _offset ) \
140
-	linda_readq ( (_linda), (_ptr)->u.dwords, (_offset) )
129
+	linda_readq ( (_linda), (_ptr)->u.qwords, (_offset) )
141
 #define linda_readq_array8b( _linda, _ptr, _offset, _idx ) \
130
 #define linda_readq_array8b( _linda, _ptr, _offset, _idx ) \
142
 	linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
131
 	linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
143
 #define linda_readq_array64k( _linda, _ptr, _offset, _idx ) \
132
 #define linda_readq_array64k( _linda, _ptr, _offset, _idx ) \
147
  * Write Linda qword register
136
  * Write Linda qword register
148
  *
137
  *
149
  * @v linda		Linda device
138
  * @v linda		Linda device
150
- * @v dwords		Register buffer to write
139
+ * @v qword		Register buffer to write
151
  * @v offset		Register offset
140
  * @v offset		Register offset
152
  */
141
  */
153
-static void linda_writeq ( struct linda *linda, const uint32_t *dwords,
142
+static void linda_writeq ( struct linda *linda, const uint64_t *qword,
154
 			   unsigned long offset ) {
143
 			   unsigned long offset ) {
155
-	void *addr = ( linda->regs + offset );
156
-
157
-	DBGIO ( "[%08lx] <= %08x%08x\n",
158
-		virt_to_phys ( addr ), dwords[1], dwords[0] );
159
-
160
-	__asm__ __volatile__ ( "movq (%0), %%mm0\n\t"
161
-			       "movq %%mm0, (%1)\n\t"
162
-			       : : "r" ( dwords ), "r" ( addr ) : "memory" );
144
+	writeq ( *qword, ( linda->regs + offset ) );
163
 }
145
 }
164
 #define linda_writeq( _linda, _ptr, _offset ) \
146
 #define linda_writeq( _linda, _ptr, _offset ) \
165
-	linda_writeq ( (_linda), (_ptr)->u.dwords, (_offset) )
147
+	linda_writeq ( (_linda), (_ptr)->u.qwords, (_offset) )
166
 #define linda_writeq_array8b( _linda, _ptr, _offset, _idx ) \
148
 #define linda_writeq_array8b( _linda, _ptr, _offset, _idx ) \
167
 	linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
149
 	linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
168
 #define linda_writeq_array64k( _linda, _ptr, _offset, _idx ) \
150
 #define linda_writeq_array64k( _linda, _ptr, _offset, _idx ) \

Loading…
Cancel
Save