Browse Source

[ioapi] Generalise i386 raw I/O API to x86

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
4dc3f8141f

src/arch/i386/core/x86_io.c → src/arch/x86/core/x86_io.c View File

35
  *
35
  *
36
  * This routine uses MMX instructions.
36
  * This routine uses MMX instructions.
37
  */
37
  */
38
-static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
38
+static __unused uint64_t i386_readq ( volatile uint64_t *io_addr ) {
39
 	uint64_t data;
39
 	uint64_t data;
40
         __asm__ __volatile__ ( "pushl %%edx\n\t"
40
         __asm__ __volatile__ ( "pushl %%edx\n\t"
41
 			       "pushl %%eax\n\t"
41
 			       "pushl %%eax\n\t"
56
  *
56
  *
57
  * This routine uses MMX instructions.
57
  * This routine uses MMX instructions.
58
  */
58
  */
59
-static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
59
+static __unused void i386_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
60
 	__asm__ __volatile__ ( "pushl %%edx\n\t"
60
 	__asm__ __volatile__ ( "pushl %%edx\n\t"
61
 			       "pushl %%eax\n\t"
61
 			       "pushl %%eax\n\t"
62
 			       "movq (%%esp), %%mm0\n\t"
62
 			       "movq (%%esp), %%mm0\n\t"
75
 PROVIDE_IOAPI_INLINE ( x86, readb );
75
 PROVIDE_IOAPI_INLINE ( x86, readb );
76
 PROVIDE_IOAPI_INLINE ( x86, readw );
76
 PROVIDE_IOAPI_INLINE ( x86, readw );
77
 PROVIDE_IOAPI_INLINE ( x86, readl );
77
 PROVIDE_IOAPI_INLINE ( x86, readl );
78
-PROVIDE_IOAPI ( x86, readq, x86_readq );
79
 PROVIDE_IOAPI_INLINE ( x86, writeb );
78
 PROVIDE_IOAPI_INLINE ( x86, writeb );
80
 PROVIDE_IOAPI_INLINE ( x86, writew );
79
 PROVIDE_IOAPI_INLINE ( x86, writew );
81
 PROVIDE_IOAPI_INLINE ( x86, writel );
80
 PROVIDE_IOAPI_INLINE ( x86, writel );
82
-PROVIDE_IOAPI ( x86, writeq, x86_writeq );
83
 PROVIDE_IOAPI_INLINE ( x86, inb );
81
 PROVIDE_IOAPI_INLINE ( x86, inb );
84
 PROVIDE_IOAPI_INLINE ( x86, inw );
82
 PROVIDE_IOAPI_INLINE ( x86, inw );
85
 PROVIDE_IOAPI_INLINE ( x86, inl );
83
 PROVIDE_IOAPI_INLINE ( x86, inl );
94
 PROVIDE_IOAPI_INLINE ( x86, outsl );
92
 PROVIDE_IOAPI_INLINE ( x86, outsl );
95
 PROVIDE_IOAPI_INLINE ( x86, iodelay );
93
 PROVIDE_IOAPI_INLINE ( x86, iodelay );
96
 PROVIDE_IOAPI_INLINE ( x86, mb );
94
 PROVIDE_IOAPI_INLINE ( x86, mb );
95
+#ifdef __x86_64__
96
+PROVIDE_IOAPI_INLINE ( x86, readq );
97
+PROVIDE_IOAPI_INLINE ( x86, writeq );
98
+#else
99
+PROVIDE_IOAPI ( x86, readq, i386_readq );
100
+PROVIDE_IOAPI ( x86, writeq, i386_writeq );
101
+#endif

src/arch/i386/include/bits/io.h → src/arch/x86/include/bits/io.h View File

3
 
3
 
4
 /** @file
4
 /** @file
5
  *
5
  *
6
- * i386-specific I/O API implementations
6
+ * x86-specific I/O API implementations
7
  *
7
  *
8
  */
8
  */
9
 
9
 

src/arch/i386/include/ipxe/x86_io.h → src/arch/x86/include/ipxe/x86_io.h View File

5
  *
5
  *
6
  * iPXE I/O API for x86
6
  * iPXE I/O API for x86
7
  *
7
  *
8
- * i386 uses direct pointer dereferences for accesses to memory-mapped
8
+ * x86 uses direct pointer dereferences for accesses to memory-mapped
9
  * I/O space, and the inX/outX instructions for accesses to
9
  * I/O space, and the inX/outX instructions for accesses to
10
  * port-mapped I/O space.
10
  * port-mapped I/O space.
11
  *
11
  *
12
- * 64-bit atomic accesses (readq() and writeq()) use MMX instructions,
13
- * and will crash original Pentium and earlier CPUs.  Fortunately, no
14
- * hardware that requires atomic 64-bit accesses will physically fit
15
- * into a machine with such an old CPU anyway.
12
+ * 64-bit atomic accesses (readq() and writeq()) use MMX instructions
13
+ * under i386, and will crash original Pentium and earlier CPUs.
14
+ * Fortunately, no hardware that requires atomic 64-bit accesses will
15
+ * physically fit into a machine with such an old CPU anyway.
16
  */
16
  */
17
 
17
 
18
 FILE_LICENCE ( GPL2_OR_LATER );
18
 FILE_LICENCE ( GPL2_OR_LATER );
59
 }
59
 }
60
 
60
 
61
 /*
61
 /*
62
- * MMIO reads and writes up to 32 bits
62
+ * MMIO reads and writes up to native word size
63
  *
63
  *
64
  */
64
  */
65
 
65
 
71
 X86_READX ( readb, uint8_t );
71
 X86_READX ( readb, uint8_t );
72
 X86_READX ( readw, uint16_t );
72
 X86_READX ( readw, uint16_t );
73
 X86_READX ( readl, uint32_t );
73
 X86_READX ( readl, uint32_t );
74
+#ifdef __x86_64__
75
+X86_READX ( readq, uint64_t );
76
+#endif
74
 
77
 
75
 #define X86_WRITEX( _api_func, _type )					      \
78
 #define X86_WRITEX( _api_func, _type )					      \
76
 static inline __always_inline void					      \
79
 static inline __always_inline void					      \
81
 X86_WRITEX ( writeb, uint8_t );
84
 X86_WRITEX ( writeb, uint8_t );
82
 X86_WRITEX ( writew, uint16_t );
85
 X86_WRITEX ( writew, uint16_t );
83
 X86_WRITEX ( writel, uint32_t );
86
 X86_WRITEX ( writel, uint32_t );
87
+#ifdef __x86_64__
88
+X86_WRITEX ( writeq, uint64_t );
89
+#endif
84
 
90
 
85
 /*
91
 /*
86
  * PIO reads and writes up to 32 bits
92
  * PIO reads and writes up to 32 bits

+ 0
- 10
src/arch/x86_64/include/bits/io.h View File

1
-#ifndef _BITS_IO_H
2
-#define _BITS_IO_H
3
-
4
-/** @file
5
- *
6
- * x86_64-specific I/O API implementations
7
- *
8
- */
9
-
10
-#endif /* _BITS_IO_H */

Loading…
Cancel
Save