소스 검색

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 년 전
부모
커밋
4dc3f8141f
4개의 변경된 파일22개의 추가작업 그리고 21개의 파일을 삭제
  1. 9
    4
      src/arch/x86/core/x86_io.c
  2. 1
    1
      src/arch/x86/include/bits/io.h
  3. 12
    6
      src/arch/x86/include/ipxe/x86_io.h
  4. 0
    10
      src/arch/x86_64/include/bits/io.h

src/arch/i386/core/x86_io.c → src/arch/x86/core/x86_io.c 파일 보기

@@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
35 35
  *
36 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 39
 	uint64_t data;
40 40
         __asm__ __volatile__ ( "pushl %%edx\n\t"
41 41
 			       "pushl %%eax\n\t"
@@ -56,7 +56,7 @@ static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
56 56
  *
57 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 60
 	__asm__ __volatile__ ( "pushl %%edx\n\t"
61 61
 			       "pushl %%eax\n\t"
62 62
 			       "movq (%%esp), %%mm0\n\t"
@@ -75,11 +75,9 @@ PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
75 75
 PROVIDE_IOAPI_INLINE ( x86, readb );
76 76
 PROVIDE_IOAPI_INLINE ( x86, readw );
77 77
 PROVIDE_IOAPI_INLINE ( x86, readl );
78
-PROVIDE_IOAPI ( x86, readq, x86_readq );
79 78
 PROVIDE_IOAPI_INLINE ( x86, writeb );
80 79
 PROVIDE_IOAPI_INLINE ( x86, writew );
81 80
 PROVIDE_IOAPI_INLINE ( x86, writel );
82
-PROVIDE_IOAPI ( x86, writeq, x86_writeq );
83 81
 PROVIDE_IOAPI_INLINE ( x86, inb );
84 82
 PROVIDE_IOAPI_INLINE ( x86, inw );
85 83
 PROVIDE_IOAPI_INLINE ( x86, inl );
@@ -94,3 +92,10 @@ PROVIDE_IOAPI_INLINE ( x86, outsw );
94 92
 PROVIDE_IOAPI_INLINE ( x86, outsl );
95 93
 PROVIDE_IOAPI_INLINE ( x86, iodelay );
96 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 파일 보기

@@ -3,7 +3,7 @@
3 3
 
4 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 파일 보기

@@ -5,14 +5,14 @@
5 5
  *
6 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 9
  * I/O space, and the inX/outX instructions for accesses to
10 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 18
 FILE_LICENCE ( GPL2_OR_LATER );
@@ -59,7 +59,7 @@ IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
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,6 +71,9 @@ IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) {		      \
71 71
 X86_READX ( readb, uint8_t );
72 72
 X86_READX ( readw, uint16_t );
73 73
 X86_READX ( readl, uint32_t );
74
+#ifdef __x86_64__
75
+X86_READX ( readq, uint64_t );
76
+#endif
74 77
 
75 78
 #define X86_WRITEX( _api_func, _type )					      \
76 79
 static inline __always_inline void					      \
@@ -81,6 +84,9 @@ IOAPI_INLINE ( x86, _api_func ) ( _type data,				      \
81 84
 X86_WRITEX ( writeb, uint8_t );
82 85
 X86_WRITEX ( writew, uint16_t );
83 86
 X86_WRITEX ( writel, uint32_t );
87
+#ifdef __x86_64__
88
+X86_WRITEX ( writeq, uint64_t );
89
+#endif
84 90
 
85 91
 /*
86 92
  * PIO reads and writes up to 32 bits

+ 0
- 10
src/arch/x86_64/include/bits/io.h 파일 보기

@@ -1,10 +0,0 @@
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…
취소
저장