Kaynağa Gözat

[ioapi] Absorb virt_to_phys() and phys_to_virt() into the I/O API

tags/v0.9.6
Michael Brown 16 yıl önce
ebeveyn
işleme
aef6d0df5c

+ 5
- 2
src/arch/i386/core/x86_io.c Dosyayı Görüntüle

@@ -65,10 +65,13 @@ static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
65 65
 			       : : "A" ( data ), "r" ( io_addr ) );
66 66
 }
67 67
 
68
-PROVIDE_IOAPI_INLINE ( x86, iounmap );
69
-PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
68
+PROVIDE_IOAPI_INLINE ( x86, virt_to_phys );
69
+PROVIDE_IOAPI_INLINE ( x86, phys_to_virt );
70 70
 PROVIDE_IOAPI_INLINE ( x86, virt_to_bus );
71 71
 PROVIDE_IOAPI_INLINE ( x86, bus_to_virt );
72
+PROVIDE_IOAPI_INLINE ( x86, ioremap );
73
+PROVIDE_IOAPI_INLINE ( x86, iounmap );
74
+PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
72 75
 PROVIDE_IOAPI_INLINE ( x86, readb );
73 76
 PROVIDE_IOAPI_INLINE ( x86, readw );
74 77
 PROVIDE_IOAPI_INLINE ( x86, readl );

+ 20
- 10
src/arch/i386/include/gpxe/x86_io.h Dosyayı Görüntüle

@@ -28,6 +28,26 @@
28 28
  *
29 29
  */
30 30
 
31
+static inline __always_inline unsigned long
32
+IOAPI_INLINE ( x86, virt_to_phys ) ( volatile const void *addr ) {
33
+	return ( ( ( unsigned long ) addr ) + virt_offset );
34
+}
35
+
36
+static inline __always_inline void *
37
+IOAPI_INLINE ( x86, phys_to_virt ) ( unsigned long phys_addr ) {
38
+	return ( ( void * ) ( phys_addr - virt_offset ) );
39
+}
40
+
41
+static inline __always_inline unsigned long
42
+IOAPI_INLINE ( x86, virt_to_bus ) ( volatile const void *addr ) {
43
+	return virt_to_phys ( addr );
44
+}
45
+
46
+static inline __always_inline void *
47
+IOAPI_INLINE ( x86, bus_to_virt ) ( unsigned long bus_addr ) {
48
+	return phys_to_virt ( bus_addr );
49
+}
50
+
31 51
 static inline __always_inline void *
32 52
 IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
33 53
 	return phys_to_virt ( bus_addr );
@@ -43,16 +63,6 @@ IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
43 63
 	return virt_to_phys ( io_addr );
44 64
 }
45 65
 
46
-static inline __always_inline unsigned long
47
-IOAPI_INLINE ( x86, virt_to_bus ) ( volatile const void *addr ) {
48
-	return virt_to_phys ( addr );
49
-}
50
-
51
-static inline __always_inline void *
52
-IOAPI_INLINE ( x86, bus_to_virt ) ( unsigned long bus_addr ) {
53
-	return phys_to_virt ( bus_addr );
54
-}
55
-
56 66
 /*
57 67
  * MMIO reads and writes up to 32 bits
58 68
  *

+ 0
- 12
src/arch/i386/include/virtaddr.h Dosyayı Görüntüle

@@ -32,18 +32,6 @@
32 32
 /* Variables in virtaddr.S */
33 33
 extern unsigned long virt_offset;
34 34
 
35
-/*
36
- * Convert between virtual and physical addresses
37
- *
38
- */
39
-static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
40
-	return ( ( unsigned long ) virt_addr ) + virt_offset;
41
-}
42
-
43
-static inline void * phys_to_virt ( unsigned long phys_addr ) {
44
-	return ( void * ) ( phys_addr - virt_offset );
45
-}
46
-
47 35
 #else /* KEEP_IT_REAL */
48 36
 
49 37
 #include <stdint.h>

+ 35
- 15
src/include/gpxe/io.h Dosyayı Görüntüle

@@ -149,28 +149,24 @@
149 149
 	} while ( 0 )
150 150
 
151 151
 /**
152
- * Map bus address as an I/O address
152
+ * Convert virtual address to a physical address
153 153
  *
154
- * @v bus_addr		Bus address
155
- * @v len		Length of region
156
- * @ret io_addr		I/O address
154
+ * @v addr		Virtual address
155
+ * @ret phys_addr	Physical address
157 156
  */
158
-void * ioremap ( unsigned long bus_addr, size_t len );
157
+unsigned long virt_to_phys ( volatile const void *addr );
159 158
 
160 159
 /**
161
- * Unmap I/O address
160
+ * Convert physical address to a virtual address
162 161
  *
163
- * @v io_addr		I/O address
164
- */
165
-void iounmap ( volatile const void *io_addr );
166
-
167
-/**
168
- * Convert I/O address to bus address (for debug only)
162
+ * @v addr		Virtual address
163
+ * @ret phys_addr	Physical address
169 164
  *
170
- * @v io_addr		I/O address
171
- * @ret bus_addr	Bus address
165
+ * This operation isn't actually valid within our memory model, and is
166
+ * impossible to achieve under -DKEEP_IT_REAL.  Some drivers haven't
167
+ * been updated to avoid it yet, though.
172 168
  */
173
-unsigned long io_to_bus ( volatile const void *io_addr );
169
+void * phys_to_virt ( unsigned long phys_addr );
174 170
 
175 171
 /**
176 172
  * Convert virtual address to a bus address
@@ -192,6 +188,30 @@ unsigned long virt_to_bus ( volatile const void *addr );
192 188
  */
193 189
 void * bus_to_virt ( unsigned long bus_addr );
194 190
 
191
+/**
192
+ * Map bus address as an I/O address
193
+ *
194
+ * @v bus_addr		Bus address
195
+ * @v len		Length of region
196
+ * @ret io_addr		I/O address
197
+ */
198
+void * ioremap ( unsigned long bus_addr, size_t len );
199
+
200
+/**
201
+ * Unmap I/O address
202
+ *
203
+ * @v io_addr		I/O address
204
+ */
205
+void iounmap ( volatile const void *io_addr );
206
+
207
+/**
208
+ * Convert I/O address to bus address (for debug only)
209
+ *
210
+ * @v io_addr		I/O address
211
+ * @ret bus_addr	Bus address
212
+ */
213
+unsigned long io_to_bus ( volatile const void *io_addr );
214
+
195 215
 /**
196 216
  * Read byte from memory-mapped device
197 217
  *

Loading…
İptal
Kaydet